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 🙏

© 2026 – Pkg Stats / Ryan Hefner

express-auth-kit

v1.0.1

Published

Complete authentication solution for Express.js applications with multiple database support

Downloads

4

Readme

Express Auth Kit

A complete authentication solution for Express.js applications with support for multiple databases and authentication methods.

Features

  • Multiple Database Support:
    • MongoDB
    • PostgreSQL
    • MySQL
    • Firebase Realtime Database
  • Authentication Methods:
    • Email/Password
    • Google OAuth 2.0
    • GitHub OAuth
    • JWT tokens
  • Security Features:
    • CORS configuration
    • Rate limiting
    • XSS protection (via Helmet)
    • CSRF protection
    • Password hashing (bcrypt)
    • Input validation
    • Session management

Installation

npm install @abhinavtiwari2705/express-auth-kit

Quick Start

const express = require('express');
const AuthKit = require('@abhinavtiwari2705/express-auth-kit');

const app = express();

// Initialize AuthKit with your configuration
const authKit = new AuthKit({
  // Database Configuration
  database: {
    type: 'mongodb', // or 'postgresql', 'mysql', 'firebase'
    uri: 'your-mongodb-uri',
    // For SQL databases
    options: {
      host: 'localhost',
      port: 5432,
      database: 'myapp',
      user: 'username',
      password: 'password'
    }
  },
  
  // Authentication Configuration
  auth: {
    jwtSecret: 'your-jwt-secret',
    jwtExpire: '7d',
    
    // OAuth Configuration
    google: {
      clientId: 'your-google-client-id',
      clientSecret: 'your-google-client-secret'
    },
    github: {
      clientId: 'your-github-client-id',
      clientSecret: 'your-github-client-secret'
    }
  },
  
  // Email Configuration
  smtp: {
    host: 'smtp.gmail.com',
    port: 587,
    user: '[email protected]',
    pass: 'your-app-specific-password'
  },
  
  // Security Configuration
  security: {
    cors: {
      origin: ['http://localhost:3000'],
      credentials: true
    },
    rateLimit: {
      windowMs: 15 * 60 * 1000,
      max: 100
    }
  }
});

// Connect to database
await authKit.connect();

// Use the auth routes
app.use('/api/auth', authKit.getRouter());

// Protected route example
app.get('/api/protected', 
  authKit.protect(), 
  (req, res) => {
    res.json({ message: 'Protected route accessed successfully' });
  }
);

app.listen(3000, () => {
  console.log('Server running on port 3000');
});

Environment Variables

Create a .env file in your project root:

# Database
DB_TYPE=mongodb
DB_URI=mongodb://localhost:27017/myapp
# For SQL databases
DB_HOST=localhost
DB_PORT=5432
DB_NAME=myapp
DB_USER=username
DB_PASSWORD=password

# JWT
JWT_SECRET=your-super-secret-jwt-key
JWT_EXPIRE=7d

# OAuth
GOOGLE_CLIENT_ID=your-google-client-id
GOOGLE_CLIENT_SECRET=your-google-client-secret
GITHUB_CLIENT_ID=your-github-client-id
GITHUB_CLIENT_SECRET=your-github-client-secret

# SMTP
SMTP_HOST=smtp.gmail.com
SMTP_PORT=587
[email protected]
SMTP_PASS=your-app-specific-password

API Endpoints

Authentication

  • POST /api/auth/register - Register new user
  • POST /api/auth/login - Login user
  • GET /api/auth/me - Get current user
  • GET /api/auth/verify/:token - Verify email
  • GET /api/auth/google - Google OAuth login
  • GET /api/auth/github - GitHub OAuth login

Request Examples

Register User

fetch('/api/auth/register', {
  method: 'POST',
  headers: {
    'Content-Type': 'application/json'
  },
  body: JSON.stringify({
    name: 'John Doe',
    email: '[email protected]',
    password: 'password123'
  })
});

Login User

fetch('/api/auth/login', {
  method: 'POST',
  headers: {
    'Content-Type': 'application/json'
  },
  body: JSON.stringify({
    email: '[email protected]',
    password: 'password123'
  })
});

Security Best Practices

  1. Always use HTTPS in production
  2. Set secure cookie options
  3. Implement proper CORS configuration
  4. Use environment variables for sensitive data
  5. Regularly update dependencies
  6. Implement proper input validation
  7. Use rate limiting for API endpoints
  8. Enable CSRF protection for forms

Contributing

  1. Fork the repository
  2. Create your feature branch
  3. Commit your changes
  4. Push to the branch
  5. Create a new Pull Request

License

MIT

Author

Abhinav Tiwari