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

@fnet/node-express

v0.3.8

Published

This project provides a basic, customizable framework for setting up a Node.js and Express.js server. It focuses on integrating essential middleware for creating secure and efficient web applications. Users can benefit from a pre-configured setup that man

Readme

@fnet/node-express

This project provides a basic, customizable framework for setting up a Node.js and Express.js server. It focuses on integrating essential middleware for creating secure and efficient web applications. Users can benefit from a pre-configured setup that manages common web app functionalities such as Cross-Origin Resource Sharing (CORS), session management, security headers, and JSON parsing.

How It Works

The project sets up a Node.js server using Express. It integrates several middleware components to handle standard tasks for web applications. The setup includes features like request parsing, IP address detection, CORS support, and session handling with Redis or memory-based fallback. It also incorporates security practices through various helmet configurations to safeguard the application in production environments.

Key Features

  • CORS Support: Configurable CORS middleware to control resource sharing across different origins.
  • Session Management: Supports session persistence using Redis with a fallback to in-memory storage if Redis is unavailable.
  • Security Headers: Utilizes Helmet middleware to apply security headers, enhancing basic security measures.
  • JSON Body Parsing: Handles JSON request bodies with a defined size limit.
  • IP Address Detection: Provides middleware to detect request IP addresses.
  • Health Check Endpoint: Implements a simple /healthz route to verify server health.

Conclusion

This project is particularly useful for developers who need a straightforward and secure Express.js setup with essential middleware for web applications. It lays the groundwork for handling common server-side tasks, making it easier and faster to build a new web server while adhering to good security practices.

Developer Guide for @fnet/node-express

Overview

The @fnet/node-express library provides a streamlined method for setting up a Node.js server using Express. It simplifies the configuration of common middleware, such as CORS, security headers, and session management, making it easier for developers to quickly build and deploy robust HTTP servers. Key features include:

  • Express server setup with JSON parsing and query parsing.
  • Configurable CORS handling.
  • Session management using Redis or an in-memory store as a fallback.
  • Security enhancements through Helmet for setting HTTP headers.
  • IP request logging.
  • A basic /healthz endpoint for health checks.

Installation

To install the library, use either npm or yarn:

npm install @fnet/node-express

or

yarn add @fnet/node-express

Usage

Here's a basic example of how to use the @fnet/node-express library to create a server with custom middleware:

import expressLib from '@fnet/node-express';

(async () => {
  const args = {
    server_port: 3000,
    cors_origin_whitelist: 'http://example.com',
    session_secret: 'my-secret-key',
    isProduction: false, // Boolean indicating if running in production
    apis: [
      {
        use({ app }) {
          // Define custom middleware or routes here
          app.get('/hello', (req, res) => {
            res.send('Hello World');
          });
        }
      }
    ]
  };

  const serverContext = await expressLib(args);

  serverContext.start(); // Starts the server
})();

Examples

Setting Up a Basic Server

import expressLib from '@fnet/node-express';

const runServer = async () => {
  const context = await expressLib({
    server_port: 4000, 
    apis: [
      {
        use({ app }) {
          app.get('/api/status', (req, res) => {
            res.json({ status: "Server is running." });
          });
        }
      }
    ]
  });
  context.start();
};

runServer();

Using Session Management

import expressLib from '@fnet/node-express';

const runWithSession = async () => {
  const context = await expressLib({
    session_secret: 'supersecret!', // Your session secret
    redis_host: 'localhost', // Redis host
    redis_port: 6379, // Redis port
    session_name: 'my-session' // Session name
  });
  context.start();
};

runWithSession();

Customizing CORS

import expressLib from '@fnet/node-express';

const customizeCors = async () => {
  const context = await expressLib({
    cors_origin_whitelist: 'https://myapp.com',
    cors_credentials: true
  });
  context.start();
};

customizeCors();

Acknowledgement

The @fnet/node-express library leverages several excellent open-source libraries, such as Express for handling HTTP requests, Helmet for security, and CORS for middleware. These libraries provide the backbone for this library, making it possible to simplify server creation and configuration.

Input Schema

$schema: https://json-schema.org/draft/2020-12/schema
type: object
properties:
  server_port:
    type: integer
    description: Port on which the server will listen
    default: 8080
  cors_origin_whitelist:
    type: string
    description: List of whitelisted origins for CORS, separated by commas
  cors_credentials:
    type: boolean
    description: Whether CORS requests can include credentials
  cors_max_age:
    type: integer
    description: Maximum age (in seconds) for CORS preflight requests
    default: 3600
  cors_allowed_headers:
    type: string
    description: Headers that are allowed in CORS requests
  cors_methods:
    type: string
    description: HTTP methods that are allowed in CORS requests
  cors_exposed_headers:
    type: string
    description: Headers that are exposed in CORS responses
  redis_host:
    type: string
    description: Hostname for the Redis server
  redis_port:
    type: integer
    description: Port for the Redis server
    default: 6379
  redis_store_prefix:
    type: string
    description: Prefix for Redis store keys
    default: "rsp:"
  session_secret:
    type: string
    description: Secret key for session management
  session_name:
    type: string
    description: Custom session name
  session_cookie_domain:
    type: string
    description: Domain for session cookies
  isProduction:
    type: boolean
    description: Whether the environment is production
  apis:
    type: array
    description: List of APIs to initialize
    items:
      type: object
      properties:
        use:
          type: string
          description: Function name used to initialize API
        onReady:
          type: string
          description: Function name called when API is ready
  mode:
    type: string
    description: Mode operation for the server
    default: start