npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@realmjs/account-restapi

v3.2.6

Published

REST APIs for Account serverless application

Downloads

6

Readme

@realmjs/account-restapi

This package provides a RESTful API for managing user accounts. It is designed to work seamlessly with the @realmjs/account-form package. The example of usage provided below demonstrates how to integrate this package into an Express.js application.

Installation

npm install @realmjs/account-restapi --save

Configuration

Before using the package, make sure to set the required environment parameters in a .env file. Below are the environment parameters that need to be configured:

COOKIE_SESSION=<cookie-session>
COOKIE_SECRET_KEY=<cookie-secret-key>
EMAIL_NAME_SALTY=<email-name-salty>
EMAIL_DOMAIN_SALTY=<email-domain-salty>
EMAIL_VALIDATION_SIGN_KEY=<email-sign-key>
EMAIL_EXPIRE_VALIDATION_LINK=<24h>

Example Usage

"use strict"

// Load environment variables from .env file
require('dotenv').config({ path: 'account/.env' })

// Import the @realmjs/account-restapi package
const api = require('@realmjs/account-restapi')

// Import and configure helper functions
// It must provide Database interface
const helpers = require('./helpers')
api.helpers(helpers)

// Import necessary modules
const express = require('express')
const app = express()

// Middleware to log requests and introduce a delay
app.use('/',
  (req, res, next) => { console.log(`account: ${req.method.toUpperCase()} request to: ${req.path}`); next() },
  (req, res, next) => setTimeout(_ => next(), 1000),
  api.generate()
);

// Import and use the middleware from @realmjs/account-form
// It generates sign-up, sign-in forms...
const FormMiddleware = require('@realmjs/account-form/ExpressMiddleware')
app.use(...FormMiddleware)

// Set up the server
const PORT = process.argv[2] && parseInt(process.argv[2]) || 3100;
app.listen(PORT, function(err) {
  if (err) {
    console.log('Failed to start server!!!');
    console.log(err);
  } else {
    console.log('------------------------------------------------------------');
    console.log(`- @realmjs/account-demo server is running at port ${PORT}`);
    console.log('------------------------------------------------------------');
  }
})

License

This project is licensed under the MIT License - see the LICENSE file for details.