Nervously Practice Multithreading

    password-protected
    TypeScript icon, indicating that this package has built-in type declarations

    1.0.36 • Public • Published

    Password Protected

    Zero-config, lean Express middleware for password-protecting websites.

    This is useful if you'd like to make any static website or express server password protected.

    There are two other similar packages in NPM, but this one:

    1. Works
    2. Typescript
    3. Better options, with strong defaults

    Examples:

    1. Basic: examples/swagger
    2. With zeit now hosting: https://private-swagger.now.sh (src)

    Basic Usage

    import cookieParser from 'cookie-parser';
    import express from 'express';
    import shrinkRay from 'shrink-ray-current';
    import passwordProtected from 'password-protected';
     
    const app = express();
    app.use(express.urlencoded({extended: true}));
    app.use(cookieParser());
    app.use(shrinkRay());
    app.use(passwordProtected({}));
    app.use(express.static(__dirname + "/private")); // Serve files from the private folder
    app.listen(3000, () => {
        console.info("Express is listening at http://localhost:3000");
    });

    Options

    All options are optional.

    • pageTitle: The html title and h2 tag to display on the page
    • password: Password for the website. Default = 'superpassword'
    • jwtSecret: A secret to sign/secure tokens. Default = 'supersecret'
    • hint: Display helpful text below the login form. Default is none.
    • jwtData: Extra data to store in the token.
    • loginHtmlTemplate: Replace the default login page with whatever you want. The only requirement is that it has a form with input name='password'.

    Install

    npm i password-protected

    DownloadsWeekly Downloads

    1

    Version

    1.0.36

    License

    ISC

    Unpacked Size

    32.9 kB

    Total Files

    17

    Last publish

    Collaborators

    • bdombro