Skip to content

Iotric/node-server

Repository files navigation

1 . Use Config json

Setting all the keys using process environment variables becomes very tedious when in need to inject 100 keys. Use hierarchical config approach

  1. Storing sensitive information like DB password , use .env

  2. Use Async-Await or promises for async error handling TODO

  3. Handle errors centrally, not within an Express middleware. Otherwise, Not handling errors within a single place will lead to code duplication and probably to improperly handled errors

  4. Use lowerCamelCase when naming constants, variables and functions and UpperCamelCase (capital first letter as well) when naming classes. Example

// for class name we use UpperCamelCase
class SomeClassExample {}

// for const names we use the const keyword and lowerCamelCase
const config = {
  key: "value"
};

// for variables and functions names we use lowerCamelCase
let someVariableExample = "value";
function doSomething() {}
  1. Prefer const over let. Ditch the var

  2. Use Async Await, avoid callbacks

  3. Detect code issues with a linter

  4. Your app will likely utilize only 25% of its available resources(!) or even less. Note that a typical server has 4 CPU cores or more, naive deployment of Node.js utilizes only 1.

  5. Use Bcrypt

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published