https://github.com/jeff-li/express-api-sever
An enhanced template for your next project using Express.js and PostgreSQL.
https://github.com/jeff-li/express-api-sever
backend express nodejs postgresql restful-api server swagger-ui template
Last synced: 3 months ago
JSON representation
An enhanced template for your next project using Express.js and PostgreSQL.
- Host: GitHub
- URL: https://github.com/jeff-li/express-api-sever
- Owner: jeff-li
- License: mit
- Created: 2020-01-28T17:42:46.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2023-06-14T01:57:00.000Z (about 3 years ago)
- Last Synced: 2023-06-14T03:15:20.499Z (about 3 years ago)
- Topics: backend, express, nodejs, postgresql, restful-api, server, swagger-ui, template
- Language: JavaScript
- Homepage:
- Size: 256 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
express-api-sever
An enhanced template for your next project using Express.js and PostgreSQL.
[](http://opensource.org/licenses/MIT)
[](https://circleci.com/gh/jeff-li/express-api-sever/tree/master)
[](https://codecov.io/gh/jeff-li/express-api-sever)
This repo is an opinionated template which can save you time when starting a new nodejs backend project. It includes many best practices and useful tools that have benefited me in the past. I tried to keep it a straight-forward API only server so it's not bloated with view engines. Hopefully it can give your project jump-start and you don't have to reconfigure everything from scratch.
## Features
✅ [Dockerized](https://www.docker.com/)
✅ [CircleCI](https://circleci.com/) for continuous integration. Tests results and artifacts stored after each build
✅ [Prettier](https://prettier.io/) enabled
✅ Prevent some well-known web vulnerabilities with [Helmet](https://helmetjs.github.io/)
✅ Unit testing with [Mocha](https://mochajs.org/), [Chai](https://www.chaijs.com/) and [Sinon](https://sinonjs.org/)
✅ [Winston](https://github.com/winstonjs/winston) logger
✅ Connection to PostgreSql databases through [Sequelize](https://sequelize.org/master/) ORM
✅ [Swagger-UI](https://swagger.io/tools/swagger-ui/) API docs generation using [Swagger UI Express](https://github.com/scottie1984/swagger-ui-express)
✅ Automatic reload development server with [Nodemon](https://nodemon.io/)
✅ Code linting with [ESLint](https://eslint.org/)
✅ Track unit-test coverage with [Istanbul](https://istanbul.js.org/)
✅ [Codecov](https://about.codecov.io/) for unit test coverage monitoring
Please feel free to remove features that's not needed in your project.
## Getting Started with Docker
1. Run the development server using Docker Compose:
```bash
docker compose up -d
```
2. Open [http://localhost:3000/api-docs/](http://localhost:3000/api-docs/) with your browser to interact with available API endpoints.
## Getting Started without Docker
1. Update `.env` file with your PostgreSQL database config: `DB_USER`, `DB_PASS`, `DB_DATABASE` and `DB_HOST`
2. Run `npm run dev` to start the development server
3. Open [http://localhost:3000/api-docs/](http://localhost:3000/api-docs/) with your browser to interact with available API endpoints.
## Available Scripts
In the project directory, you can run:
### `npm start`
Run all migration scripts and start server
### `npm run dev`
Run all migration scripts and start development server with nodemon
### `npm test`
Run all unit tests and report coverage
### `npm run test-watch`
Run all unit tests in watch mode
### `npm run report-coverage`
Report current test coverage with `nyc`
### `npm run migrate`
Run Sequelize migration and seed scripts
### `npm run lint`
Run Eslint linter on all .js files
### `npm run format`
Format all .js files with Prettier