A modern nodejs API boilerplate, built on top of Express + MongoDB.
See API Docs for functionality.
Live Examples:
Node API Boilerplate provides a starting point for creating a backend web service with nodejs, utilizing modern javascript tools and standards.
This server is designed to be used as an API backend for a web or mobile service, and expects to be consumed by another process.
This decoupled approach ( as opposed to a monolithic approach where an API and web server live on the same process ) makes both the web and api service easier to organize, and provides a more scalable and performent architecture.
See universal-web-boilerplate to create universal, code split web apps.
5/21/2018 - Updated all npm dependencies to latest version. Update to webpack 4.
- async / await to simplify async control flow and error handling
- import / export to enable javsascript modules
- API integration tests run in parallel, each test connecting to a separate database instance.
- Code coverage and watch mode supported by jest out of the box
- Configured for a nodejs environment
- IDE integration highly recommended
- nodejs, latest LTS - https://nodejs.org/en/
- Yarn - https://yarnpkg.com/en/
git clone https://github.com/dtonys/node-api-boilerplate && cd node-api-boilerplate
yarn
https://treehouse.github.io/installation-guides/mac/mongo-mac.html
NOTE: Substitute your own values as needed
API_PORT=3020
ENCRYPTION_SECRET=<SECRET_CODE>
MONGODB_DATABASE_NAME=auth_app
MONGODB_CONNECTION_URL=mongodb://localhost
npm run dev
npm run build
npm run start
npm run test
npm run lint-js
A modern API backend, with access to RESTful resources, authentication, and permissions.
Method | Url | Params | Notes |
---|---|---|---|
POST | /api/users | email, password_hash, roles | Create a new user |
PATCH | /api/users/:id | email, password_hash, roles | Update user |
GET | /api/users/:id | Get user | |
GET | /api/users | Get list of users | |
DELETE | /api/users/:id | Delete a user |
Method | Url | Params | Notes |
---|---|---|---|
POST | /api/signup | email, password | Signup a user and log them in |
POST | /api/login | email, password | Log a user in |
GET | /api/logout | Log a user out | |
GET | /api/session | Get current session info |
Method | Url | Params | Notes |
---|---|---|---|
GET | /api/member/users | Get list of users, logged-in only | |
GET | /api/admin/users | Get list of users, admin role only |
This boilerplate was created with inspiration from the following resources:
- backpack - https://github.com/jaredpalmer/backpack
- survivejs - https://github.com/survivejs-demos/webpack-demo
- react-redux-universal-hot-example - https://github.com/erikras/react-redux-universal-hot-example