Skip to content

A Node.js Typescript based NPS survey API using express

License

Notifications You must be signed in to change notification settings

magujun/nodeJS-NPS_Survey

Repository files navigation

Build Status

nodeJS-NPS_Survey



Technology   |    Setup   |    Testing   |    Project links   |    Contribute   |    License

🔖 About

GitHub forks GitHub stars

A Node.js TypeScript based Net Promoter Score (NPS) survey web REST API built on the Node.js track of Next Level Week #4 presented by Rocketseat.

🚀 Technology

This project has been developed and tested with the following technologies:

  • Node.js :: JavaScript runtime
  • Express :: web framework
  • Yarn :: package manager
  • SQLite3 :: local database
  • TypeORM :: object-relational-mapping database migration
  • Cors :: Express middleware to enable CORS
  • Handlebars :: html templating for email content
  • Nodemailer :: Node.js module to send emails
  • Jest :: JavaScript testing framework
  • Yup :: object schema validation
  • Ethereal :: fake SMTP service

⤵ Setup

These instructions will take you to a copy of the project running on your local machine for testing and development purposes. Integration tests have been implemented.

Note: The database used in this project is sqlite3, but you should be able to configure the ormconfig.json file for your specific database.

The "database" field in the DBMS represents the name of the database, which in this project is local.

- git clone https://github.com/magujun/nodeJS-NPS_Survey.git
- cd nodeJS-NPS_Survey

Windows Setup (Powershell)

- Set-ExecutionPolicy RemoteSigned
- Get-ExecutionPolicy
- Set-ExecutionPolicy Bypass -Scope Process -Force; [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072; iex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1'))

- choco -v
- cinst nodejs-lts
- cinst yarn -force
- refreshenv
- node -v  
- npm -v
- yarn -v

Visual Studio Code Setup

Recommended Extensions

  • Omni
  • Material Icon Theme
  • ESLint
  • Prettier
  • SQLite
  • Bracket Pair Colorizer 2
  • Code Spell Checker
  • Live Server
  • Markdown All in One

Install dependencies (recommended using NPM for reflect-metadata compatibility)

VS Code Terminal (Powershell)

- npm install

or

- yarn install

or

- yarn init -y

- yarn add express
- yarn add @types/express -D

- yarn add typescript -D
- yarn tsc --init
- yarn add ts-node-dev -D

- yarn add sqlite3

- yarn add typeorm reflect-metadata
- yarn typeorm
- yarn typeorm migration:create -n CreateUsers
- yarn typeorm migration:create -n CreateSurveys
- yarn typeorm migration:create -n CreateSurveysUsers
- yarn typeorm migration:run

- yarn add body-parser

- yarn add cors
- yarn add @types/cors -D

- yarn add uuid  
- yarn add @types/uuid -D

- yarn add jest
- yarn jest --init
- yarn add ts-jest -D  
- yarn add @types/jest -D
- npm i --save-dev @types/jest

- yarn add cross-env -D  

- yarn add supertest 
- yarn add @types/supertest -D

- yarn add nodemailer
- yarn add @types/nodemailer -D

- yarn add handlebars

- yarn add yup
- yarn add @types/yup -D

- yarn add express-async-errors

- yarn add eslint -D  
- yarn add prettier -D

The first time you run the server will generate the sqlite3 database.sqlite file, where the API tables are stored.

- yarn devDB

Create table of migrations from sqlite3 using the TypeORM cli.

- yarn typeorm migration:run

Initialize a local server instance (script configured in package.json).

- yarn dev

⤵ Testing

To make requests and inspect responses you can use Insomnia Core client for REST applications.

To edit and manage your SQL database you can use Beekeeper Studio.

To test if the application has been correctly setup and pass all integration tests, please use the command:

- yarn test

🔗 Project links

Notion

Resources

Icons & Wallpapers

🎓 Who taught?

All the classes were taught by Daniele Leão at Rocketseat's NLW#4.

🤔 Contribute

  • Fork this repository;
  • Create a branch with your feature: git checkout -b my-feature;
  • Commit your changes: git commit -m 'feat: My new feature';
  • Push to your branch: git push origin my-feature.

After the merge of your pull request is done, you can delete your branch.

📝 License

This project is under the MIT license.
See the LICENSE file for more details.


Done with ❤ by Marcelo Guimarães Junior.

About

A Node.js Typescript based NPS survey API using express

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published