Powerful template project for building a micro-service API server via Express
Why should you use this template project?
- Environment variable configuration
- Streamlined Docker support
- ES2015 syntax and imports
- Strong linting via eslint
- JSON-based Express API
- Basic Mongoose layout (optional)
- API error handling
- Unit testing configuration
The easiest way to run this project is using Docker Compose
docker-compose build
docker-compose up
This will boot up a API server for this project, as well as simple MongoDB server.
To test your server, open your browser to http://localhost:3000/.
If you prefer not to use Docker, follow these steps to run the project locally.
You will need to make sure these dependencies are installed.
- Node.js > 8
- NPM
- MongoDB (optional)
To install the libraries for this project, run this command.
npm install
This project is configured using variables in your environment
file. To initialize this file, copy the contents of TEMPLATE.env
into
your local .env
file and edit it, as desired.
cp TEMPLATE.env .env
nano .env
Use this command to run this project in dev mode.
npm run watch
To use this project in production, you should use the build
command
to compile your code to ES5.
npm run build
After building, use the start
command to run the project.
npm run start
Unit tests and linting can be run using npm
.
npm run build
npm run test
npm run lint