You can clone this repo as a template to generate a RESTful API web server in Node.js with TypeScript that connects to a database.
- Database manipulation using Sequelize as a modern ORM library
- Sending email using Nodemailer
- Unit testing using Jest
- Having Node.js installed in your machine
- Updating the DB config at db.ts file inside the src folder
Here are some steps to run this project successfully. Please refer to note section below to make sure you have everything installed on your computer before running these steps.
-
Install npm dependencies
npm i
-
Configure the DB credentials in db.ts file at the root folder
-
Start the server
npm start
The server will listen for line changes in index.ts, autocompiled it into js files then autorun the js files.
Run yarn jest
to run all javascript unit tests using Jest framework
To get the test coverage summary, run yarn jest --coverage
. The report will be output to the console and the html is generated at coverage/lcov-report/index.html
If you want to run a particular unit test, run yarn jest [ filename without .js ]
. For example: yarn jest send_email
Be sure to have installed yarn
, typescript
and jest
in your machine.
To install:
npm install -g yarn
npm i -g typescript
yarn add --dev jest
Happy Coding!