Boilerplate for express web server in JS.
- install Node.js (ver. 8 or higher) and npm from https://nodejs.org/
git clone
cd express-boilerplate-js
npm i
- add .env file with env variables like in env.example or just rename .env.exapmle -> .env
npm start
You will see this message:
XXXX-XX-XX XX:XX:XX [info]: Server is listening on port 3000
Congratulations! It works.
Feel free to access 127.0.0.1:3000
through browser/Postman to get greeting message form server.
You can also test POST request - pass your name in request body. Check validation model in src/validation/models/post.joi.js
You can run tests (with help of Jest) with command
npm run test
Some pre-build boilerplate tests will execute. You can find them in __test__
directory in project.
Also, you can manually run eslint test with command
npm run test:lint
This boilerplate using:
-
Express [https://github.com/expressjs/express] as core framework
-
Winston [http://github.com/winstonjs/winston] for logging
-
Jest [https://github.com/facebook/jest] for testing
-
Dotenv [https://github.com/motdotla/dotenv] for env loading
-
ESlint [https://github.com/eslint/eslint] for code style
-
Prettier [https://github.com/prettier/prettier] for code formatting
-
Husky [https://github.com/typicode/husky] for git hooks
-
Joi [https://github.com/hapijs/joi] for real-time validation
Q: Why another boring boilerplate?
A: Main idea is to create CLI for bootstrapping new project. Up-to-date boilerplates is a first step to this.
Q: Why no Typescript?
A: Typescript coming soon, it will be in separate repo or at CLI.
Q: Why ... [Winston/Jest/Husky]?
A: For now we use our common stack. We will try to make replacing one library with another as easy as possible (and we will add some choices for CLI).
While CONTRIBUTING.md
still in progress feel free to make merge request, open some issues or contact me directly. Thanks!