1.0.0 • Published 7 months ago
@nicholasdigital/express-boilerplate v1.0.0
Express Boilerplate
An opinionated boilerplate for building Express applications with modern tooling: Webpack, Babel, ESLint, Prettier, and Jest.
Features
- Express 5.x: Modern Express server setup
- Webpack: Bundles server code for development and production
- Babel: ESNext syntax, decorators, and class properties support
- ESLint & Prettier: Enforced code style and formatting
- Jest: Out-of-the-box unit testing
- Husky & Commitlint: Git hooks for linting, formatting, and commit message validation
- Path Aliases: Use
@as an alias for thesrcdirectory
Getting Started
Installation
git clone https://github.com/nwpray/express-boilerplate.git
cd express-boilerplate
npm installDevelopment
npm run build:watch # Rebuild on file changes
npm run start:watch # Restart server on changes (nodemon)Production
npm run build
npm startLinting & Formatting
npm run lint # Lint and auto-fix code
npm run format # Format code with PrettierTesting
npm testProject Structure
.
├── src/
│ ├── controllers/
│ │ └── Info.js
│ ├── core/
│ │ └── Controller/
│ └── index.js
├── dist/
├── .babelrc
├── .eslintrc
├── .prettierrc
├── webpack.config.js
├── package.json
└── README.mdExample
A simple controller using decorators:
// src/controllers/Info.js
import Controller from '@/core/Controller';
@Controller()
export default class InfoController {
@Controller.Method('get', '/')
static read(req, res) {
res.send('express-boilerplate');
}
}Scripts
npm run build– Bundle source files with Webpacknpm run build:watch– Watch and rebuild on changesnpm run start– Start the compiled servernpm run start:watch– Start server with nodemonnpm run lint– Lint and fix codenpm run format– Format code with Prettiernpm test– Run tests
License
ISC
Made by Nick Pray