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

simpler-express-authorize

v1.0.4

Published

A simple express middleware to authorize users

Downloads

15

Readme

Simple Express authorization

GitHub License GitHub Repo stars GitHub Sponsors

PLEASE NOTE: UPDATES WILL CURRENTLY BE MINIMAL DUE TO LACK OF SUPPORT!!! TO KEEP THIS PROJECT ALIVE, PLEASE SUPPORT IT BY OPENING GITHUB ISSUES OR BETTER SPONSOR THE PROJECT HERE

Simple Express authorization promises to make authorization in Express super easy. Its the most straightforward and minimal framework on the market. No PassportJS used.

What it includes:

  • Google Auth
  • Email and password Auth
  • Uses MongoDB

If you would like to use different database, or want more control you can clone the Github repository or copy desired code.

How to set it up:

Step 1: install from NPM or clone for more control

npm i simpler-express-authorize

Or

git clone https://github.com/sewellstephens/express-authorize.git

Step 2: Add to your code as follows

const {simpleExpressAuth} = require("simpler-express-authorize");

...

app.use(simpleExpressAuth);

Step 3: Update .env with your values

IMPORTANT: MongoDB URI is required in order to connect to database. If you want to use a different one, you will need to either clone this repo or copy and paste the desired code.

DOMAIN= domain here
FRONTEND_URL= frontend url here
BACKEND_URL= backend url here
GOOGLE_CLIENT_ID= client id here
GOOGLE_CLIENT_SECRET= client secret here
GOOGLE_REDIRECT_URI= google redirect here
JWT_KEY= key here
MAIL_HOST= host here
MAIL_PASSWORD= password here
MAIL_PORT=587
MAIL_SENDER= sender here formatted as ME <[email protected]>
MAIL_USER= mail user here
MONGODB_URI= mongo url here

If you want to only offer password signin, you will need to add a config like so:


const {simpleExpressAuth} = require("simpler-express-authorize");

...

app.use(simpleExpressAuth({
    passwordOnly: true
}));

Or to only offer Google sign in, replace passwordOnly with googleOnly.

Routes to get familiar with

/users/signup (POST)

Sent a post request to signup user with password.

Requires body formatted as follows:

{
    name: usersName,
    email: usersEmail,
    password: usersPassword
}

/users/login (POST)

Send a post request to login user with password.

Requires body formatted as follows:

{
    email: usersEmail,
    password: usersPassword
}

/users/google (GET)

Gets a Google authorization URL based on Client ID and Secret defined in ENV file.

/users/googleCallback (GET)

Add this in when setting up your Google consent prompt.

/users/logout (POST)

Logs out a user.

/users/account (GET)

Gets user information stored in MongoDB.

/users/account (PUT)

Updates user email, password, and/or name.

Requires body formatted as follows:

{
    name: usersName,
    email: usersEmail,
    password: usersPassword
}

/users/activate/:token (GET)

Used when activating account, or when two factor is enabled.

/users/resetToken (POST)

Used for sending password reset email.

/users/resetPassword (POST)

Used for reseting password.

/users/delete (POST)

Used for deleting user.

/users/activateTwoFactor

Used for activating two factor.

Requires body formatted as follows:

{
    enabledState: enabledState
}