Skip to content

Latest commit

 

History

History
85 lines (62 loc) · 2.08 KB

README.md

File metadata and controls

85 lines (62 loc) · 2.08 KB

staging-express

Express.js integration for staging password protection middleware.

npm version Bundle Size License: MIT TypeScript

Installation

npm install staging-express
# or
yarn add staging-express
# or
pnpm add staging-express

Usage

import express from 'express';
import staging from 'staging-express';
import cookieParser from 'cookie-parser';
import session from 'express-session';

const app = express();

// Required middleware
app.use(express.urlencoded({ extended: true }));
app.use(cookieParser());

// Optional: Session support for better UX
app.use(session({
  secret: process.env.SESSION_SECRET || 'your-secret',
  resave: false,
  saveUninitialized: false
}));

// Add password protection
app.use(staging({
  password: process.env.STAGING_PASSWORD,
  siteName: "My Protected Site"
}));

Features

  • Full Express.js middleware integration
  • Session support
  • Built-in cookie handling
  • Custom Node.js optimizations

Configuration

See the main documentation for base options.

Session Support

For better UX with redirects, add session support:

import session from 'express-session';

app.use(session({
  secret: process.env.SESSION_SECRET || 'your-secret',
  resave: false,
  saveUninitialized: false,
  cookie: {
    secure: process.env.NODE_ENV === 'production',
    maxAge: 7 * 24 * 60 * 60 * 1000 // 7 days
  }
}));

Example

A complete working example is available in our repository:

License

MIT