Giter Club home page Giter Club logo

express-typeorm-scaffold's Introduction

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 10.15.0

nvm install 10.15.0
nvm use 10.15.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:

API Validation

By using celebrate the req.body schema becomes clary defined at route level, so even frontend devs can read what an API endpoint expects without need to writting a 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

TODO

  • unify config: typeorm, mongodb, nodeenv => config.ts
  • setup CI/CD
  • polish up logging with winston
  • write tests
  • check if user exists upon registration
  • implement verify-token endpoint to be used in microservice architecture
  • make feature initilization modular (e.g.: mailing, agenda)
  • add dependency injection for typeORM repositories in services
  • adjust readme
  • clean up repository files
  • prevent committing code that doesn't compile using pre hooks and tsc (with husky, lint-staged, prettier and tsc)

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

express-typeorm-scaffold's People

Contributors

santiq avatar alexreiling avatar orozcoadrian avatar eliancordoba avatar joserfelix avatar radomirperisic avatar noticemaker avatar mrailton avatar dependabot[bot] avatar lakshitaverma avatar jackson-elfers avatar sayyidyofa avatar wanderrful avatar simbig avatar kuzmrom7 avatar hosseinnedaee avatar gineremanuel avatar diomalta avatar deluxateer avatar basarat avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.