/Node-Starter

This is just a basic Node API style application with DB migrations & unit tests.

Primary LanguageJavaScript

Node Starter

CI/CD Status Known Vulnerabilities Quality Gate Status SonarCloud Reliability Rating SonarCloud Security Rating SonarCloud Coverage SonarCloud Bugs SonarCloud Vulnerabilities SonarCloud Tech Debt SonarCloud Code Smells Code Climate ko-fi Donate


This repository includes some demonstration Node based application that uses Jest for the unit testing & technologies such as Express & Knex. You should see a working example here


Requirements

  • Install Node
  • Install Docker
  • Install VSCode

VSCode Suggestions (Optional)

  • Install the font family called 'Fira Code'
  • Install the icon theme called 'VSCode-icons'
  • Install the extension called 'Bracket Pair Colorizer 2'
  • Install the extension called 'Code Spell Checker'
  • Install the extension called 'Find Related Files'
  • Install the extension called 'GitLens — Git supercharged'
  • Install the extension called 'Indent Rainbow'
  • Install the extension called 'Path Intellisense'
  • Install the extension called 'Sonar Lint'
  • Install the extension called 'Jest Snippets'
  • Install the extension called 'NPM Intellisense'
  • Install the extension called 'Prettier — Code formatter'
  • Install the extension called 'Version Lens'

Other Suggestions (Optional)

  • Install 'Windows Terminal' from the MS store.
  • Install Postman
  • Install Chocolatey

Run the Application

In order to run the application you simply need to run the following command(s):

$ npm run-script local:setup
$ npm run-script start
Endpoint Method Description
/users?page=:page GET Return a page of users. The page arg is optional.
/users POST Create a new user.
/users PUT Update an existing user.
/users/:id GET Return a specific user.
/users/:id PUT Update an existing user.
/users/:id DELETE Delete an existing user.

Docker

In order to run the application with Docker, you'll need to run the following command(s):

$ docker build -t node-demo .
$ docker run -p 80:3000 node-demo

Migration

In order to run the database migrations, you'll need to run the following command(s):

$ npx knex migrate:latest
$ npx knex seed:run
$ npx knex migrate:latest --env test
$ npx knex seed:run --env test

Alternatively you can just run this command:

$ npm run-script local:setup

Unit Tests

In order to urn the unit tests, you'll need to run the following command:

$ npm run-script test

If you would like some debugging information, you can also run:

$ npm run-script test:debug

Security

In order to run some security scans, you'll need to use Snyk. This means at some point you'll want to provide credentials, via the use of the following command:

$ npx snyk auth

You can then scan the dependencies for vulnerabilities via the following command:

$ npx snyk test

General Quality

Through the use of tools such as Synk, ESLint, SonarLint, etc. You can run some quality checks locally, to do so run the following script:

$ npm run quality

Todo

  • Use a number of monitoring technologies, i.e. AppSensor.
  • etc.