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

loki-local-passport

v1.0.12

Published

is a custom strategy that simplifies authenticating with Passport using id and password.

Downloads

6

Readme

loki-local-passport

is a custom strategy that simplifies authenticating with Passport using id and password.

This strategy use persistent in-memory JavaScript Datastore - LokiJS instead of large NoSQL DB like a MongoDB what give for us amazing performance.

Intro

This module give your posibility quickly handle user auth without painfull dev work like configuration and other stuff. Everything what you need is 3 line.  Three line Carl!  You will say but why i need it? It's a simple answer :   Imagine that your are at hackaton and make a prototype of your app. Where you will spend more time in auth module or at the logic of your future startup (I hope you do).

Also this module will be helpfull in a

  • petty projects
  • university projects
  • non-production projects and even more.

Installation

npm install passport-local-passport

Usage

As every passport strategy this one need:

Install this packadges by command :

npm i express express-session  passport body-parser cookie-parser connect-flash

require them and use:

Require all this stuff needed for passport:

const passport = require('passport');


const bodyParser = require('body-parser');
const cookieParser = require('cookie-parser');
const session = require('express-session');
const flash = require('connect-flash');


app.use(bodyParser.urlencoded({ extended: true }));
app.use(cookieParser());
app.use(session({ secret: 'mistery' }));
app.use(passport.initialize());
app.use(passport.session());
app.use(flash());

Require installed module (LokiLocal)

const LokiLocal = require('loki-local-passport');

Add the middleware function LokiLokal.use() to your routes. Example:

app.post(
    '/login',
    LokiLocal.use('login')
  );
  
  app.post(
      '/signup',
      LokiLocal.use('signup')
    );

That`s all what you need to start use it.

If you want control what is going on your can add to middleware LokiLokal.use() object with debug mode. Example:

app.post(
    '/login',
    LokiLocal.use('login', { mode: 'debug' })
  );
  
  app.post(
      '/signup',
      LokiLocal.use('signup',{ mode: 'debug' })
    );

It will print in console all actions.

All of this fields can be placed in your signup form (if not it will have value custom):

  • id required
  • password required
  • name
  • surname
  • email
  • number
  • sex
  • age
  • country

Example of simple app :

const express = require('express');

const passport = require('passport');
const LokiLocal = require('loki-local-passport');

const bodyParser = require('body-parser');
const cookieParser = require('cookie-parser');
const session = require('express-session');
const flash = require('connect-flash');
 


const app = express();
 
app.use(bodyParser.urlencoded({ extended: true }));
app.use(cookieParser());
app.use(session({ secret: 'mistery' }));
app.use(passport.initialize());
app.use(passport.session());
app.use(flash());
 
 
app.post(
    '/login',
    LokiLocal.use('login')
  );
  
app.post(
      '/signup',
      LokiLocal.use('signup')
    );
  
 
 
 
app.listen(8080, () => {
  console.log('Started at the port 8080');
});