/express-mongo-starter

Boilerplate Server using Node/Express/Mongo/Redis with Basic Auth

Primary LanguageTypeScript

express-mongo-starter

boilerplate-server

Pre-requisites

  • Node
  • MongoDB
  • Redis
  • Docker - Recommended

Get Started

  1. Create .env file and populate it taking reference to sample.env.
  2. docker-compose up

NOTE: Without docker steps
2. yarn install - Install all the dependencies
3. Check your Mongo & Redis server is up and running.
4. yarn start - Start the server.

Thanks to

Endpoints

* denotes required fields. ? denotes maybe undefined.

Every Request should have Content-Type: application/json

Index Key Value
1. METHOD POST
ROUTE /auth/register
REQ BODY
json
{
    "phone*":     "string",
    "password*":  "string",
    "email":     "string",
    "name":      "string",
}
RES BODY
json
{
    "prettyMessage":    "string",
    "status":           "number",
    "data": {
            "accessToken":    "string",
            "userId":         "string",
            "refreshToken":   "string",
        },
    "success": "boolean",
}
STATUS CODES
{
  "409": "Already Registered",
  "201": "User registered successfully",
  "501": "Internal Server Error"
}
2. METHOD POST
ROUTE /auth/login
REQ BODY
json
{
    "phone*":     "string",
    "password*":  "string",
}
RES BODY
json
{
    "prettyMessage":    "string",
    "status":           "number",
    "data?": {
            "accessToken":    "string",
            "userId":         "string",
            "refreshToken":   "string",
        },
    "success": "boolean",
}
STATUS CODES
{
  "200": "User Authorised",
  "401": ["User not registered" , "User not Authorised"],
  "501": "Internal Server Error"
}
3. METHOD POST
ROUTE /auth/refresh-token
REQ HEADERS
    "access-token*":   "string",
    "user-id*":        "string",
REQ BODY
json
{
    "refreshToken*":     "string",
}
RES BODY
json
{
    "prettyMessage":    "string",
    "status":           "number",
    "data": {
            "accessToken":    "string",
            "userId":         "string",
            "refreshToken":   "string",
        },
    "success": "boolean",
}
STATUS CODES
{
  "205": "OK",
  "400": "Invalid",
  "405": "Refresh Token Expire",
  "501": "Internal Server Error"
}
4. METHOD POST
ROUTE /auth/logout
REQ HEADERS
    "access-token*":   "string",
    "user-id*":        "string",
REQ BODY
json
{}
RES BODY
json
{
    "prettyMessage":    "string",
    "status":           "number",
    "success":          "boolean",
}
STATUS CODES
{
  "200": "Logged Out",
  "501": "Internal Server Error"
}