All Projects → ofuochi → node-typescript-boilerplate

ofuochi / node-typescript-boilerplate

Licence: MIT License
An enterprise startup boilerplate for typescript and nodejs API project

Programming Languages

typescript
32286 projects

Projects that are alternatives of or similar to node-typescript-boilerplate

watchman-processor
Folder synchronization tool with a simple dashboard
Stars: ✭ 38 (+80.95%)
Mutual labels:  inversifyjs
super-powered-api-testing
Comparisons of powerful API testing tools
Stars: ✭ 25 (+19.05%)
Mutual labels:  mocha-chai
NetStatus
Internet speed & offline status monitor. Upload, download, ping, latency dashboard display
Stars: ✭ 93 (+342.86%)
Mutual labels:  inversifyjs
express-mongoose-es8-rest-api
A Boilerplate for developing Rest api's in Node.js using express with support for ES6,ES7,ES8 ,Mongoose,JWT for authentication,Standardjs for linting
Stars: ✭ 20 (-4.76%)
Mutual labels:  mocha-chai
telephone-ts
Telephone-ts: The "Event Emitter-less" TypeScript Event Architecture.
Stars: ✭ 22 (+4.76%)
Mutual labels:  inversifyjs
nodejs-boilerplate
Clean Architecture for node.js projects (Typescript + Express + TypeORM + Typedi)
Stars: ✭ 199 (+847.62%)
Mutual labels:  inversifyjs
server-next
😎 The next generation of RESTful API service and more for Mix Space, powered by @nestjs.
Stars: ✭ 43 (+104.76%)
Mutual labels:  typegoose
vue-ioc
IoC and DI for Vue powered by InversifyJS and inspired by Angular Module syntactic sugar.
Stars: ✭ 39 (+85.71%)
Mutual labels:  inversifyjs
tic-tac-toe-game-using-bit
Simple Tic Tac Toe game built with react-typescript components
Stars: ✭ 19 (-9.52%)
Mutual labels:  mocha-chai
ng-nest-cnode
Angular 10 Front-End and Nestjs 7 framework Back-End build Fullstack CNode
Stars: ✭ 17 (-19.05%)
Mutual labels:  typegoose
BotBlock.org
BotBlock - The List of Discord Bot Lists and Services
Stars: ✭ 29 (+38.1%)
Mutual labels:  mocha-chai
after-work.js
[DEPRECATED] CLI for automated tests in web projects.
Stars: ✭ 56 (+166.67%)
Mutual labels:  mocha-chai
ts-ui
Telar Social Network using Reactjs
Stars: ✭ 35 (+66.67%)
Mutual labels:  inversifyjs
wax-prosemirror
A rich-text editor using Prosemirror with React
Stars: ✭ 31 (+47.62%)
Mutual labels:  inversifyjs
advpl-testsuite
Mocha + Chai like test suite and light environment for AdvPL
Stars: ✭ 38 (+80.95%)
Mutual labels:  mocha-chai
google-it-telegram-bot
🤖 @Google_itBot 🔎 Search and share LINKS/IMAGES/VIDEOS in inline mode
Stars: ✭ 40 (+90.48%)
Mutual labels:  inversifyjs
Inversifyjs
InversifyJS is a lightweight inversion of control (IoC) container for TypeScript and JavaScript apps. An IoC container uses a class constructor to identify and inject its dependencies. InversifyJS has a friendly API and encourages the usage of the best OOP and IoC practices.
Stars: ✭ 8,399 (+39895.24%)
Mutual labels:  inversifyjs
buidler-waffle-typechain-oz-vue
Dapp starter kit using: Buidler + Waffle + TypeChain + OpenZeppelin CLI + Vue (TypeScript)
Stars: ✭ 43 (+104.76%)
Mutual labels:  mocha-chai

NodeJs/Typescript API Boilerplate

Open Source Love GitHub issues GitHub stars GitHub forks GitHub license

To Contribute

Please feel free to contribute to this project. To contribute, please follow this instructions

Running the app

NOTE: These instructions require MongoDB and Node.js to be installed on your environment.

Clone the Repository

git clone https://github.com/ofuochi/node-typescript-boilerplate.git
cd node-typescript-boilerplate

Install Dependencies

npm install

Copy Files

Sample env File into a .env File

Copy the sample environment file to a new environment file that holds the sensitive settings of your application.

cp env.sample .env

Run the App

npm run start

Or run in development watch mode. This uses nodemon to watch for file changes.

npm run dev

DB Seeding

The first time the application runs, MongoDB is seeded with default Tenant and default Admin User.

  1. Default tenant name is Default (obvioulsy)
  2. Default admin login detail;
    • Username: admin
    • Password: 123qwe

Swagger API Documentation

Open the URL http://localhost:3000/api-docs to view the the swagger documentation of the endpoints.

This will contain all the endpoints you expose to the client. Once you add a new endpoint, this endpoint will automatically be added! How cool is that?😎. Concentrate on building the functionality and business logic of your application. Swagger will do the documentation for you!.

Since this is a multi-tenant application, to authenticate (sign-in or sign-up), you need to pass a tenant ID in the header so that the application will know which tenant you are referencing during authentication.

To get the tenant details call the "get tenants" endpoint. For example, to get the details of the Default tenant, I'll call the endpoint http://localhost:3000/api/v1/tenants/default. Good thing is, you can do this directly on Swagger!

Run Tests

Run test once

npm run test

Or re-run test on every file change (watch mode)

npm run test-watch

REST Services

The application exposes a few REST endpoints which require you to pass x-tenant-id header. First, call the tenant endpoint /api/v1/tenant to get all the available tenants. Use any of the tenant IDs as the value for x-tenant-id

  • HTTP GET /api/v1/tenants
  • HTTP GET /api/v1/tenants/:query
  • HTTP GET /api/v1/secured (Requires a valid x-auth-token header)

You can use the following code snippet to call the secured endpoint:

fetch("http://localhost:3000/api/v1/secure", {
	method: "GET",
	headers: {
		"Content-Type": "application/json",
		"x-tenant-id": "TENANT_ID",
		"x-auth-token": "SOME_VALID_CREDENTIAL"
	}
})
	.then(r => {
		if (r.status === 200) {
			r.json().then(j => console.log(j));
		} else {
			console.log("ERROR", r.status);
		}
	})
	.catch(e => console.log(e));

You can use the following code snippet to call the secured endpoint with an invalid x-auth-token header:

fetch("http://localhost:3000/api/v1/secure", {
	method: "GET",
	headers: {
		"Content-Type": "application/json",
		"x-tenant-id": "TENANT_ID",
		"x-auth-token": "SOME_WRONG_CREDENTIAL"
	}
})
	.then(r => {
		if (r.status === 200) {
			r.json().then(j => console.log(j));
		} else {
			console.log("ERROR", r.status);
		}
	})
	.catch(e => console.log(e));
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].