Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/bluehalo/node-rest-starter
A Node.js starter containing common components and services as a reference API.
https://github.com/bluehalo/node-rest-starter
Last synced: about 1 month ago
JSON representation
A Node.js starter containing common components and services as a reference API.
- Host: GitHub
- URL: https://github.com/bluehalo/node-rest-starter
- Owner: bluehalo
- Created: 2018-09-20T04:46:06.000Z (over 6 years ago)
- Default Branch: develop
- Last Pushed: 2024-11-06T17:12:11.000Z (about 2 months ago)
- Last Synced: 2024-11-06T18:24:37.496Z (about 2 months ago)
- Language: TypeScript
- Homepage:
- Size: 2.57 MB
- Stars: 14
- Watchers: 18
- Forks: 10
- Open Issues: 9
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Node REST Starter
[![Build Status](https://travis-ci.org/Asymmetrik/node-rest-starter.svg?branch=develop)](https://travis-ci.org/Asymmetrik/node-rest-starter)
[![Maintainability](https://api.codeclimate.com/v1/badges/38b36e9f561532e17b23/maintainability)](https://codeclimate.com/github/Asymmetrik/node-rest-starter/maintainability)
[![Test Coverage](https://api.codeclimate.com/v1/badges/38b36e9f561532e17b23/test_coverage)](https://codeclimate.com/github/Asymmetrik/node-rest-starter/test_coverage)## Getting Started
### Prereqs
#### Required
- nodejs 14.x, 16.x - this project supports `.tool-versions` via [asdf](https://asdf-vm.com/)
- mongodb 4.0, 4.2#### Recommended
- docker - [Start Up](#start-up) contains instructions for installing mongo via docker
### Start Up
1. To get started run `npm run init`(if you do not have mongo running use `npm run init:mongo`)
- This will install the dependencies and setup the `development.js` environment from the template
1. Start the application via `npm start`### Related Commands
- `init` - initalizes project
- `init:mongo` - initalizes project and runs mongodb via docker
- `init:env:dev` - copies development environment config template to usable location
- `init:mongo:up` - uses docker compose to run containerized mongodb
- `init:mongo:express` - uses docker compose to run mongo express at http://localhost:8081 for mongo debugging
- `init:mongo:down` - removes node-rest-starter docker container group
- `start` - runs project and watches for changes and reloads
- `start:dev` - runs with node_env set to development
- `start:prod` - runs compiled version of project## API Documentation
Endpoint Documentation for this application is generated from the `*.routes.js` files in each module.
Model/Schema documentation should be included in with each model and will be compiled from any file matching `*.model.js`.When the application is started, Swagger provides an interface for this API that is available by default at
The existence and path for this Swagger page is configurable via the `apiDocs` parameter, which defaults to:
```json
{
"enabled": true,
"path": "/api-docs"
}
```## Providers
Several services use configurable "providers" in order to easily swap functionality in and out of the application.
For example, the Email Service at `./src/app/core/email/email.service.ts` can be controlled via the `mailer.provider` configuration to use any of the out-of-the-box providers:
1. HTTPS
1. SMTP
1. Log
1. File
1. NoopThe default provider for a service will be included in `dependencies` in NPM's `package.json`. On the other hand, any non-default providers should include their dependencies as `devDependencies` in order to reduce the inclusion of unnecessary modules in production builds.
If a non-default provider is used (e.g., `node-kafka` for the `Event` service), the application instance should include this module in `dependencies` on its own fork, instead of updating the `node-rest-starter` reference application.
## Testing
Tests run as an NPM script. To support development, `npm run test` will watch all files via `nodemon` and will run tests as files are updated.
In order to generate code coverage output via a single run of the test suite, `npm run test:ci` will output coverage results into the top-level `./coverage` directory, both in HTML and LCOV formats.
## Installing on Production
Since Mongoose suggests not automatically creating Mongo indices on-the-fly, the following utility script can be run, targeting the production Mongo instance / cluster, to create/sync all required indices.
`node ./src/sync-indexes.js`