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

express-user-management

v1.6.9

Published

A ready-to-use express middleware for authentication.

Downloads

6

Readme

express-user-management

A ready-to-use library for authentication and user management with express.

Uses mongo, passport, and jwt by default.

What does it do?

express-user-management will automatically create API endpoints for :

  • user registration
  • user account activation
  • user login
  • password forgotten
  • password change with a token for the previous route
  • password change when logged in
  • account deletion

It handles everything you need to handle in those routes. You can set various options to adapt it to your project.

It uses nodemailer to send mails, and you can link it easily to your mail service.

Installation

npm i express-user-management

Usage

const userManagement = require('express-user-management');
userManagement.init(expressApp, options);

Options

Here are the available options with their default values :

const options = {
  /* Adapter to use under the hood. */
  adapter: 'passport-mongo',
  /* Table in the database where users are stored */
  usersTable: 'users',
  /* How API key is handled */
  apiKey: {
    /* Table where to look at API keys */
    table: 'projects',
    /* Key in the document that stores the API key */
    documentKey: 'apiKey.apiKey',
  },
  /* URL of the database */
  mongoUrl: '',
  /* Password reset URL. Used in mail templates below */
  passwordResetAdress: 'http://localhost:30000/resetPassword',
  /* Account activation URL. Used in mail templates below */
  accountActivationAdress: 'http://localhost:30000/activate',
  nodeMailerConfig: undefined,
  /* Whether or not you need to handle account activation on your project */
  activationRequired: true,
  /* Mail templates. See dedicated section in the readme for more info */
  mails: {
    activation: {
      subject: 'Activate your account!',
      sender: '[email protected]',
      body: `Almost done!
             Please click this link to activate your account!

             {{accountActivationAdress}}/activate/{{user.activation.code.apiKey}}`,
    },
    passwordReset: {
      subject: 'Password reset link',
      sender: '[email protected]',
      body: `You are receiving this because you (or someone else) have requested the reset of the password for your account.
            Please click on the following link, or paste this into your browser to complete the process:
            {{passwordResetAdress}}{{token}}
            If you did not request this, please ignore this email and your password will remain unchanged.`,
    },
  }

Mailing

node-mailer is used to handle mailing. Simply put in the options the config object you would give to node-mailer directly.

If no configuration object is provided, mails are not being sent but the output is logged.

Hooks

This feature is not implement yet!

In order to allow you to execute some arbitrary code when the endpoints are called, some hooks can be provided to the options.