All Projects → santiq → Bulletproof Nodejs

santiq / Bulletproof Nodejs

Licence: mit
Implementation of a bulletproof node.js API 🛡️

Programming Languages

javascript
184084 projects - #8 most used programming language
typescript
32286 projects
shell
77523 projects
Dockerfile
14818 projects

Projects that are alternatives of or similar to Bulletproof Nodejs

Node Express Boilerplate
A boilerplate for building production-ready RESTful APIs using Node.js, Express, and Mongoose
Stars: ✭ 890 (-79.63%)
Mutual labels:  mongoose, mongodb, express, boilerplate
Node Rem
Node REM - NodeJS Rest Express MongoDB and more: typescript, passport, JWT, socket.io, HTTPS, HTTP2, async/await, nodemailer, templates, pagination, docker, etc. Live Demo: https://node-rem-ngduc.vercel.app
Stars: ✭ 192 (-95.61%)
Mutual labels:  mongoose, mongodb, express, boilerplate
Express Graphql Mongodb Boilerplate
A boilerplate for Node.js apps / GraphQL-API / Authentication from scratch - express, graphql - (graphql compose), mongodb (mongoose).
Stars: ✭ 288 (-93.41%)
Mutual labels:  mongoose, mongodb, express, boilerplate
Express Mongoose Es6 Rest Api
💥 A boilerplate application for building RESTful APIs Microservice in Node.js using express and mongoose in ES6 with code coverage and JsonWebToken Authentication
Stars: ✭ 2,811 (-35.66%)
Mutual labels:  mongoose, mongodb, express, boilerplate
Mern Boilerplate
Fullstack boilerplate with React, Redux, Express, Mongoose, Passport Local, JWT, Facebook and Google OAuth out of the box.
Stars: ✭ 112 (-97.44%)
Mutual labels:  mongoose, mongodb, express, boilerplate
Express Boilerplate
🚀 Starter project for a RESTful API in Node with Express & mongoose component-based
Stars: ✭ 9 (-99.79%)
Mutual labels:  mongoose, mongodb, express, boilerplate
Nodejs Api Boilerplate
A boilerplate for kickstart your nodejs api project with JWT Auth and some new Techs :)
Stars: ✭ 364 (-91.67%)
Mutual labels:  mongoose, mongodb, express, boilerplate
Angular Full Stack
Angular Full Stack project built using Angular, Express, Mongoose and Node. Whole stack in TypeScript.
Stars: ✭ 1,261 (-71.14%)
Mutual labels:  mongoose, mongodb, express, boilerplate
Express Rest Boilerplate
⌛️ Express starter for building RESTful APIs
Stars: ✭ 1,794 (-58.94%)
Mutual labels:  mongoose, mongodb, express, boilerplate
Saas
Build your own SaaS business with SaaS boilerplate. Productive stack: React, Material-UI, Next, MobX, WebSockets, Express, Node, Mongoose, MongoDB. Written with TypeScript.
Stars: ✭ 2,720 (-37.74%)
Mutual labels:  mongoose, mongodb, express, boilerplate
Intro To Graphql
[Course] Introduction to GraphQL
Stars: ✭ 175 (-95.99%)
Mutual labels:  mongoose, mongodb, express
Nodejs Restful Api
How to create a RESTful CRUD API using Nodejs?
Stars: ✭ 285 (-93.48%)
Mutual labels:  mongoose, mongodb, express
Lad
👦 Lad is the best Node.js framework. Made by a former Express TC and Koa team member.
Stars: ✭ 2,112 (-51.66%)
Mutual labels:  mongoose, mongodb, boilerplate
Node.js
一步一步学习Node.js,带你从零开始学习Node.js!本仓库是自己总结的Node.js学习图文教程,里面有学习案列和源代码(pubdreamcc原创,欢迎转载,欢迎star)
Stars: ✭ 181 (-95.86%)
Mutual labels:  mongoose, mongodb, express
Blog Service
blog service @nestjs
Stars: ✭ 188 (-95.7%)
Mutual labels:  mongoose, mongodb, express
Ecommerce Site Template
A beautiful e-commerce template powered by React, Redux and other modern web tech.
Stars: ✭ 167 (-96.18%)
Mutual labels:  mongoose, mongodb, express
Frisky
🍿 Open Source GraphQL API for Online Shows
Stars: ✭ 161 (-96.31%)
Mutual labels:  mongoose, mongodb, express
Vue Node Pastime
😄 基于vue全家桶、nodejs和mongodb的前后端整合项目
Stars: ✭ 200 (-95.42%)
Mutual labels:  mongoose, mongodb, express
Jianshu
仿简书nx+nodejs+nestjs6+express+mongodb+angular8+爬虫
Stars: ✭ 296 (-93.22%)
Mutual labels:  mongoose, mongodb, express
Mevn Boilerplate
A fullstack boilerplate with Mongo, ExpressJS, VueJS and NodeJS.
Stars: ✭ 277 (-93.66%)
Mutual labels:  mongoose, mongodb, boilerplate

Bulletproof Node.js architecture 🛡️

This is the example repository from the blog post 'Bulletproof node.js project architecture'

Please read the blog post in order to have a good understanding of the server architecture.

Also, I added lots of comments to the code that are not in the blog post, because they explain the implementation and the reason behind the choices of libraries and some personal opinions and some bad jokes.

The API by itself doesn't do anything fancy, it's just a user CRUD with authentication capabilities. Maybe we can transform this into something useful, a more advanced example, just open an issue and let's discuss the future of the repo.

Development

We use node version 14.9.0

nvm install 14.9.0
nvm use 14.9.0

The first time, you will need to run

npm install

Then just start the server with

npm run start

It uses nodemon for livereloading :peace-fingers:

Online one-click setup

You can use Gitpod for the one click online setup. With a single click it will launch a workspace and automatically:

  • clone the bulletproof-nodejs repo.
  • install the dependencies.
  • run cp .env.example .env.
  • run npm run start.

Open in Gitpod

API Validation

By using celebrate, the req.body schema becomes cleary defined at route level, so even frontend devs can read what an API endpoint expects without needing to write documentation that can get outdated quickly.

route.post('/signup',
 celebrate({
   body: Joi.object({
     name: Joi.string().required(),
     email: Joi.string().required(),
     password: Joi.string().required(),
   }),
 }),
 controller.signup)

Example error

{
 "errors": {
   "message": "child \"email\" fails because [\"email\" is required]"
 }
}

Read more about celebrate here and the Joi validation API

Roadmap

  • API Validation layer (Celebrate+Joi)
  • Unit tests examples
  • Cluster mode
  • The logging 'layer'
  • Add agenda dashboard
  • Continuous integration with CircleCI 😍
  • Deploys script and docs for AWS Elastic Beanstalk and Heroku
  • Integration test with newman 😉
  • Instructions on typescript debugging with VSCode

API Documentation

To simplify documenting your API, we have included Optic. To use it, you will need to install the CLI tool, and then you can use api exec "npm start" to start capturing your endpoints as you create them. Once you want to review and add them to your API specification run: api status -- review.

FAQ

Where should I put the FrontEnd code? Is this a good backend for Angular or React or Vue or whatever ?

It's not a good idea to have node.js serving static assets a.k.a the frontend

Also, I don't wanna take part in frontend frameworks wars 😅

Just use the frontend framework you like the most or hate the least. It will work 😁

Don't you think you can add X layer to do Y? Why do you still use express if the Serverless Framework is better and it's more reliable?

I know this is not a perfect architecture but it's the most scalable that I know with less code and headache that I know.

It's meant for small startups or one-developer army projects.

I know if you start moving layers into another technology, you will end up with your business/domain logic into npm packages, your routing layer will be pure AWS Lambda functions and your data layer a combination of DynamoDB, Redis, maybe redshift, and Agolia.

Take a deep breath and go slowly, let the business grow and then scale up your product. You will need a team and talented developers anyway.

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].