/middleware

Node+Typescript middleware for the Api's.

Primary LanguageTypeScript

OPS-Middleware using Node.js, Express, Mongoose & TypeScript

technologies

This is a Middleware for building scalable and robust REST APIs using Node.js & TypeScript.

Table of Contents

Prerequisites

You need to install MongoDB on your local machine or use database as service.

Features

Getting Started

Installation

  1. install the dependencies using npm install or npm i

  2. copy the file .env.local to .env

  3. Start the app using npm start

  4. After that, go to: http://localhost:3000/

Directory Structure

├── src
│   ├── apiV1
│   │   ├── auth
│   │   │  ├── auth.controller.ts
│   │   │  └── auth.route.ts
│   │   ├── clients
│   │   │   ├── client.controller.ts
│   │   │   ├── client.model.ts
|   |   |   ├── client.service.ts
│   │   │   └── client.route.ts
│   │   └── index.ts
│   ├── config
│   │   ├── config.ts
│   │   └── db.ts
│   ├── helpers
│   │   ├── errorHandler.ts
│   │   └── verifyToken.ts
│   ├── .env.dev
|   ├── .env.local
│   ├── App.ts
│   └── index.ts
├── .editorconfig
├── .gitignore
├── package.json
├── README.md
├── tsconfig.json
└── tslint.json

Available routes

Method Resource Description
POST /clients/register Create a new client in the DB. You need to specify in the body the following attributes: name, client_id & client_secret.
POST /authenticate Sign in with the client_id & client_secret. If it's successful, then generates a token
You need to specify the token in the header with the following format: Authorization: Bearer your-token in Below Api's.

Available scripts

  • start - To run the app without transpile to ES6
  • clean - Remove dist, node_modules, coverage folders,
  • lint - Lint your TS code,
  • build - Transpile TypeScript to ES6,
  • build-start - Run the transpiled app,
  • prod - Build & run the transpiled app