API-seed is a template for the development of backend systems in Node.js.
API-seed includes different middlewares, modules, and services that can be used with minimum configuration.
-
Template offers three ways of authentication:
- Local auth
- Google auth
- Facebook auth
-
Routes authorization middleware based on user's roles.
-
Per route middleware that allows rate-limiting by user's ID or IP address.
-
Request caching globally or per user, using Redis key-value database.
-
Error, info, and access (route) local logging. Logs are available in the
./logs
directory after the app startup. A log document is created in the database with all relevant information about the request and response for every received request on the server. -
Error handling middleware.
-
Request body validation middleware.
-
API analytics module -> usage, devices, requests browsing, response times...
-
Admin module allows user management and some on-the-fly middleware management via admin console or API.
-
Users CRUD operations, forgotten password, registration, change password, change email, change username...
-
Service for sending transactional emails.
-
Data seed for adding data to the database.
-
The template is already test-covered, as it should be in future use.
-
Server-side rendered admin console with users management, analytics, and API admin settings.
$ git clone https://{bitbucket_username}@bitbucket.org/anzemur/api-seed.git
Install latest MongoDB docker image.
$ docker run --name api-seed-mongo -d -i -t -p 27017:27017 mongo
Install latest Redis docker image.
$ docker run --name api-seed-redis -d -i -t -p 6379:6379 redis redis-server --appendonly yes
JWT_SECRET=notasecret
ENV=dev
DB_HOST=localhost
DB_NAME=api-seed-dev
TEST_DB_HOST=localhost
TEST_DB_NAME=api-seed-test
REDIS_HOST=localhost
REDIS_PORT=6379
PORT=3000
API_VERSION=v1
USE_ADMIN_CONSOLE=true
SMTP_HOST=
SMTP_PORT=
SMTP_USE_SSL=
SMTP_USERNAME=
SMTP_PASSWORD=
FB_CLIENT_ID=
FB_CLIENT_SECRET=
GOOGLE_CLIENT_ID=
GOOGLE_CLIENT_SECRET=
SEED_ADMIN_EMAIL=
SEED_ADMIN_PASSWORD=
Empty variables are exposure sensitive so they should be set by the user. They are not necessary but each scope of them unlocks functions the framework offers.
$ npm install
$ npm run start
$ npm run test
$ npm run seed
You need to install Docker and set environment variables to your environment.
$ docker build -t api-seed .
$ docker-compose up