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

@api-craft/oauth

v1.0.2

Published

Express middleware plugin for OAuth login with Google, Apple, and Meta (Facebook & Instagram). Auto exposes OAuth routes and callbacks.

Downloads

35

Readme

@api-craft/oauth

Express middleware plugin to easily integrate OAuth login with Google, Apple, and Meta (Facebook & Instagram).
Automatically exposes OAuth routes and callback URLs with a configurable filter for selected providers.


Features

  • Plug-and-play OAuth login for Google, Apple, and Meta (Facebook + Instagram)
  • Auto-registers all necessary routes:
    • /auth/google, /auth/google/callback
    • /auth/apple, /auth/apple/callback
    • /auth/meta, /auth/meta/callback
  • Filter to enable only needed providers
  • Hooks to run custom logic after login success or failure
  • Built on passport.js for extensibility and stability
  • Session support included via express-session

Installation

npm install @api-craft/oauth passport passport-google-oauth20 passport-facebook passport-apple express-session

Quick Start

import express from 'express';
import { createOAuthRouter } from '@api-craft/oauth';

const app = express();

const oauthRouter = createOAuthRouter({
  baseUrl: 'https://yourdomain.com/auth',
  providers: {
    google: {
      clientId: process.env.GOOGLE_CLIENT_ID,
      clientSecret: process.env.GOOGLE_CLIENT_SECRET,
      scopes: ['profile', 'email']
    },
    apple: {
      clientId: process.env.APPLE_CLIENT_ID,
      teamId: process.env.APPLE_TEAM_ID,
      keyId: process.env.APPLE_KEY_ID,
      privateKey: process.env.APPLE_PRIVATE_KEY,
    },
    meta: {
      clientId: process.env.META_CLIENT_ID,
      clientSecret: process.env.META_CLIENT_SECRET,
      scopes: ['public_profile', 'email']
    }
  },
  filter: ['google', 'meta'], // Only enable Google and Meta providers
  onSuccess: (req, res, user) => {
    // Custom logic after successful OAuth login
    res.json({ user });
  },
  onFailure: (req, res, error) => {
    // Handle OAuth failure
    res.status(401).json({ error: error.message });
  }
});

app.use('/auth', oauthRouter);

app.listen(3000, () => {
  console.log('Server started on http://localhost:3000');
});

Available Routes

| Route | Method | Description | | --------------------------- | -------- | ------------------------- | | /auth/{provider} | GET | Initiate OAuth login flow | | /auth/{provider}/callback | GET/POST | OAuth callback handler | | /auth/failure | GET | OAuth failure handler |

Example : Custom On Success

onSuccess: async (req, res, user) => {
  // Example: Save or update user in your database
  const existingUser = await User.findOne({ oauthId: user.id });
  if (!existingUser) {
    await User.create({ oauthId: user.id, profile: user });
  }

  // Issue JWT token
  const token = createJwtToken(user);

  // Send response
  res.json({ token, user });
}

Licence

MIT License

Contributions

Contributions and feedback are welcome! Feel free to open issues or pull requests.

Author

@api-craft/oauth by P. Thamilselven Feel free to reach out for any questions or customizations.