Making a simple server to reference for Node projects.
I have much more experience in Ruby on Rails so wanted to get a Node server demo on the board since that is also very popular in web development.
npm start
or yarn start
or node index.js
Express JS simplifies the routing by reducing the need to write a lot of if statements. They have a great reference here
Run the server with Nodemon so you don't have to resetart the server manually
Using environment variables will help hide keys or offer flexibility in setting values for different environments (development, staging, production).
Here is a great blog from the fine folks at Twilio about different ways to set this up: Working With Environment Variables in Node.js.
body-parser required now with latest version of express. User-controlled input is untrusted and can fail in multiple ways so middleware is necessary to parse POST requests.
Joi offers a nicely readable syntax for defining and validating body params
As a Ruby on Rails developer I haven't used Node in a production environment yet, but I enjoy writing Javascript and can see myself picking things up quickly from here.