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 🙏

© 2024 – Pkg Stats / Ryan Hefner

configure-express-app

v4.0.2

Published

use npx configure-express-app

Downloads

22

Readme

Express App Generator

Welcome to the Express App Generator! This tool helps you quickly set up an Express application with pre-configured middleware and optional database connections.

npx configure-express-app@latest

Features

  • Auto-detect Node.js version: Automatically adjusts settings based on the installed Node.js version.

  • Example:

    • In node version 20 don't need this env import, Node js supports .env default. Automatically added (Node.js <= 18)
      require('dotenv').config();
    • Auto detect node.js version and automatically added (Node.js >= 20)
      node --env-file=.env server.js
  • Pre-configured Environment Setup:

    • Includes a .env file for environment variables.
  • Pre-installed Modules and Middleware:

    • Express: Web framework for Node.js.
    • Rate Limiter: Middleware to limit repeated requests to public APIs and/or endpoints.
    • Nodemon: Automatically restarts the server for development.
    • Winston: Logging library for application logs.
    • UUID: Generates unique request IDs.
    • Compression: Gzip compression for improved performance.
    • Helmet: Security middleware for HTTP headers.
    • CORS: Middleware to enable Cross-Origin Resource Sharing.
    • Body-Parser: Middleware to parse incoming request bodies.
    • Error Handling: Standardized error responses.
    • HPP: Prevent HTTP Parameter Pollution.
    • Request Logging: Logs request body, params, query, and headers.
    • Prettier: Code formatter for consistent code style.
    • .gitignore: Pre-configured to exclude sensitive files and directories.
  • Database Configuration:

    • Choose from PostgreSQL, MongoDB, or None during setup.
    • Sample database connection is created in the database directory.

Prerequisites

Ensure you have the following software installed on your system:

Installation

To create a new Express app, follow these steps:

  1. Run the Generator:

    npx configure-express-app@latest
  2. Navigate to Your Project Directory:

    cd your-project-name
  3. Pre Installed Dependencies Automatically

  4. Configure Environment Variables:

    Create a .env file in the root of your project and set your environment variables. A sample .env.example file is provided.

    cp .env.example .env

    Edit the .env file as needed.

  5. Run the Application In Production:

    npm start
  6. Development Mode:

    For development mode with live-reloading:

    npm run dev

Project Structure

Your Express app will have the following structure:

Usage

  • Adding Routes: Define your routes in the routes directory. Create new files for different route groups and import them in routes/index.js.

  • Creating Controllers: Implement your business logic in controllers, located in the controllers directory.

  • Using Middleware: Add custom middleware in the middlewares directory.

  • Database Models: Define your database models in the models directory. Ensure your database connection is configured in database/db.js.

  • Environment Variables: Manage configuration settings through the .env file.

Scripts

The following scripts are available:

  • npm start: Start the application.
  • npm run dev: Start the application in development mode with Nodemon.
  • npm run prettify: prettify your code using Prettier.

Security

  • Helmet: Protects against known vulnerabilities by setting HTTP headers appropriately.
  • HPP: Prevents HTTP Parameter Pollution.
  • Express-Mongo-Sanitize: Prevents NoSQL injection attacks.

Contributing

If you'd like to contribute, please fork the repository and use a feature branch. Pull requests are welcome.

License

This project is licensed under the MIT License. See the LICENSE file for details.