Code techniques

  • Variables declaration & destructuring with values in default:
    • const { code = 500, message = 'server error' } = error;

    • const PORT = process.env.PORT || 5000;
    • const { DB_HOST } = process.env;
    • const { DB_HOST, PORT = 5000 } = process.env;
    • Simplest code writing:
      • const dotenv = require('dotenv');
        dotenv.config();

      The same with chaining:
      • require('dotenv').config();