Node.js Boilerplate – An opinionated project structure with batteries included.
Update all dependencies in package.json
that are specified with a version range (e.g., ^
or ~
).
yarn update
Run ESLint on the /src
directory to check for syntax warnings and errors.
yarn lint
Execute the test suite. Customize this command to match your project's testing framework and configuration (e.g., Jest, Mocha).
yarn test
Run tests for the database client class, verifying the functionality of all database-related methods.
yarn test-db
Start the Redis server. Ensure Redis is installed and configured on your system.
yarn redis
Execute custom scripts by specifying the script names as a comma-separated environment variable.
SCRIPT=<script-names> yarn script
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 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 the Express server.
yarn server
Start the Express server in development
mode with nodemon
watching for file changes.
yarn server-dev
Run workers defined in /server/workers.js
or specified as comma-separated environment variables.
CRONJOB=<cronjob-names> JOB=<job-names> yarn worker
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
Start or restart 'forever' processes defined in ecosystem.config.js.
- Start processes:
yarn pm2-start
- Restart processes:
yarn pm2-restart
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;