This package provide an auth to your app.

Usage no npm install needed!

<script type="module">
  import resolveAuth from '';



npm version

Provides an authentication mechanism using Passport authentication strategy.


First of all, create file with your strategy and add auth section into for your application (see hacker-news example). Next, choose a type of authentication strategy (see passport-local or [passport-google-oauth]( for example) ) and define options of it. Create your strategy in strategyConstructor function using options. Return an array of tuples { strategy, options } for every used route in your app.


Here is the simple example of local strategy, but you can use any other Passport strategy similarly.

import { Strategy } from 'passport-local'
import jwt from 'jsonwebtoken'
import jwtSecret from './jwtSecret'

const options ={ path, method, callback }) => ({
  strategy: {
    usernameField: 'username',
    passwordField: 'username',
    successRedirect: null
  route: {
    path: '/register',
    method: 'POST'
  callback: async (_, username) =>
    jwt.sign(           // here fake use is created
      {                   // for user storing into db see HakerNews example
        name: username    //

const strategyConstructor = options =>
  new Strategy(
      passReqToCallback: true
    async (req, username, password, done) => {
      try {
        done(null, await options.callback(req, username, password))
      } catch (error) {

export default [{ options, strategyConstructor }]