Showing posts with label node js best practices. Show all posts
Showing posts with label node js best practices. Show all posts

Tuesday, 8 May 2018

Express Js best practices

1. Try - catch
2. Better Error handling
3. JSLint to see if any reference errors on undefined variables.
4. Try-catch works only for synchronous code. Because the Node platform is primarily asynchronous (particularly in a production environment), try-catch won’t catch a lot of exceptions.
5.Promises will handle any exceptions (both explicit and implicit) in asynchronous code blocks that use then(). Just add .catch(next) to the end of promise chains

Production Best Practices

Wednesday, 2 May 2018

Best Practices for my back end dev in Node js


Node js framework is quite popular and ease to use. Below are few packages and practices i would like to follow for my new project.
  • Logger : bunyan
  • Editor: visual code
  • Codes : correctly use HTTP codes
  • Headers: extra headers prefix with user-defined name 
  • API : Restify over express
  • Black box test: super-test
  • Unit test: sinon
  • Ratelimit : limit API hits
  • API Doc: Swagger
  • ex for API documentation: Stripe API