/node-server-example

My bare minimum for a Node HTTP server application

Primary LanguageJavaScript

Sample Node Web Server

Goals

  1. Create a Node server without any other framework
  2. Document commands/configuration to allow debugging with initial breakpoint
  3. Automated testing of web server testing status codes, headers, and response body
  4. Examples responses for HTML, JSON, and streams

Setup Steps

  1. git init
  2. Create .gitignore with node_modules added
  3. npm init
  4. Add "type": "module" to package.json
  5. Add dependencies and devDependencies to package.json in logical order
  6. npm i -D jest eslint env-cmd prettier nodemon
  7. npx eslint --init
  8. Change lint config to .eslintrc.cjs with rule 'import/extensions': 'off',
  9. Configure test and lint scripts
  10. Add .editorconfig with the following
root = true

[*]
end_of_line = lf
indent_size = 2
indent_style = space
insert_final_newline = true
trim_trailing_whitespace = true

  1. Create index.js and www.js