Skip to content

API-seed is a template for the development of backend systems in Node.js.

Notifications You must be signed in to change notification settings

anzemur/api-seed

Repository files navigation

API-seed

API-seed is a template for the development of backend systems in Node.js.

Contents

API-seed includes different middlewares, modules, and services that can be used with minimum configuration.

  • Authentication

    Template offers three ways of authentication:

    • Local auth
    • Google auth
    • Facebook auth
  • Authorization

    Routes authorization middleware based on user's roles.

  • Rate limiting

    Per route middleware that allows rate-limiting by user's ID or IP address.

  • Cache

    Request caching globally or per user, using Redis key-value database.

  • Logging

    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

    Error handling middleware.

  • Request body validation

    Request body validation middleware.

  • Analytics module

    API analytics module -> usage, devices, requests browsing, response times...

  • Admin module

    Admin module allows user management and some on-the-fly middleware management via admin console or API.

  • Users module

    Users CRUD operations, forgotten password, registration, change password, change email, change username...

  • Mailing service

    Service for sending transactional emails.

  • Data seed

    Data seed for adding data to the database.

  • Tests

    The template is already test-covered, as it should be in future use.

  • Admin console

    Server-side rendered admin console with users management, analytics, and API admin settings.

admin-console

Installation

First you need to clone this repository:

$ git clone https://{bitbucket_username}@bitbucket.org/anzemur/api-seed.git

1. Local installation

If you want to run API-seed locally you must install all of the following prerequisites:

How to install the prerequisites:

Node.js and npm
Docker
MongoDB

Install latest MongoDB docker image.

$ docker run --name api-seed-mongo -d -i -t -p 27017:27017 mongo
Redis

Install latest Redis docker image.

$ docker run --name api-seed-redis -d -i -t -p 6379:6379 redis redis-server --appendonly yes

Create .env file in root directory with variables or add them to OS's environment:

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.

Install dependencies:

$ npm install

After the dependencies are installed run the app with the command:

$ npm run start

You can run tests with the command:

$ npm run test

And you can run data seed with the command:

$ npm run seed

2. Using Docker

You need to install Docker and set environment variables to your environment.

Crete docker image:

$ docker build -t api-seed .

Start the image by running:

$ docker-compose up

About

API-seed is a template for the development of backend systems in Node.js.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published