Skip to content
/ nb Public template

Node.js boilerplate - an opinionated project structure with batteries included.

License

Notifications You must be signed in to change notification settings

nameer-rizvi/nb

Repository files navigation

nb

Node.js Boilerplate – An opinionated project structure with batteries included.

Yarn Scripts

Update Dependencies

Update all dependencies in package.json that are specified with a version range (e.g., ^ or ~).

yarn update

Lint Source Code

Run ESLint on the /src directory to check for syntax warnings and errors.

yarn lint

Run Tests

Execute the test suite. Customize this command to match your project's testing framework and configuration (e.g., Jest, Mocha).

yarn test

Test Database Client

Run tests for the database client class, verifying the functionality of all database-related methods.

yarn test-db

Start Redis Server

Start the Redis server. Ensure Redis is installed and configured on your system.

yarn redis

Run Custom Scripts

Execute custom scripts by specifying the script names as a comma-separated environment variable.

SCRIPT=<script-names> yarn script

Build Stylesheet

Compile the Tailwind CSS stylesheet and output it to /server/router.static/css. This command generates the CSS file based on the project's Tailwind configuration.

yarn tw

Run Tailwind CSS Server

Run the Tailwind CSS server in watch mode to automatically compile changes to the stylesheet in /server/router.static/css as you edit styles.

yarn tw-dev

Start Express Server

Start the Express server.

yarn server

Run Express Server in Development Mode

Start the Express server in development mode with nodemon watching for file changes.

yarn server-dev

Run Workers

Run workers defined in /server/workers.js or specified as comma-separated environment variables.

CRONJOB=<cronjob-names> JOB=<job-names> yarn worker

Run Workers in Development Mode

Run workers defined in /server/workers.js or specified as comma-separated environment variables in development mode with nodemon watching for file changes.

yarn worker-dev

PM2 Scripts

Start or restart 'forever' processes defined in ecosystem.config.js.

  • Start processes:
yarn pm2-start
  • Restart processes:
yarn pm2-restart

Helpful Links

Redis

Nginx & Certbot

PM2

Configuration Example

Example configuration for PM2:

// ecosystem.config.js
const ecosystemConfig = {
  apps: [
    {
      name: "app",
      script: "./src/index.js",
      env: {
        NODE_ENV: "production",
        PORT: 3000,
        TZ: "America/New_York",
      },
    },
  ],
};

module.exports = ecosystemConfig;

About

Node.js boilerplate - an opinionated project structure with batteries included.

Topics

Resources

License

Stars

Watchers

Forks