-
Install Node Js if you have not done so.
- Alternative Installation via Chocolatey
- Check if you have installed node previously by running
node --version
- You should see the version number (e.g.
v14.15.0
)
- You should see the version number (e.g.
-
Install Docker if you have not done so.
- Check if you have installed Docker previously by running
docker -v
- You should see the version number (e.g.
Docker version 20.10.2, build 2291f61
)
- You should see the version number (e.g.
- Alternatively, you can choose to use ElephantSql, read this document on how to setup usage of ElephantSql
- Check if you have installed Docker previously by running
-
Install VS Code if you have not done so previously.
-
Install the following VS Code Plugins
-
Clone the repository (How to clone a repository)
-
Open a terminal at the folder path
-
Run
npm install
-
Create a new file in the root directory
.env
(Note the dot at the front) and paste the following values into the file:DB_HOST=localhost DB_PORT=5432 DB_USER=user DB_PASSWORD=password DB_DATABASE=virtual_queue DB_TEST_PORT=6543 DB_TEST_CONNECTION_STRING=
-
(For Docker setup) Start the database by executing the following:
For ElephantSql users, skip this step and simply ensure to run the content in
./database/init.sql
to create the minimally required tables.npm run start-db
You should observe the following (Intentionally truncated to be concise):
$ npm run start-db > 2122s1-backend@1.0.0 start-db > docker-compose up Creating network "2122s1-backend-solution_default" with the default driver Creating db ... done Creating db-test ... done Attaching to db-test, db ... ... db | 2021-03-03 10:08:04.290 UTC [1] LOG: database system is ready to accept connections db-test | 2021-03-03 10:08:04.310 UTC [1] LOG: database system is ready to accept connections
The process will keep running, ❗ DO NOT kill it with
CTRL + C
❗ -
Start the server by running:
npm start
you should observe the following:
$ npm start > 2122s1-backend@1.0.0 start > node ./www.js Backend Listening on port 3000
-
Open the file
./tests/http/enqueue_dequeue.test.http
Make use of the 3 request inside to test the correctness of the system.
⚠️ You will need the REST Client VSCode plugin-
enqueue: The returned
customer_id
should increment each time you make a request -
dequeue: The returned
customer_id
should increment each time you make a request, when there's no customer in the queue, thecustomer_id
should be 0. -
not found: You should get a status 404 with the following response:
{ "code": "URL_NOT_FOUND", "error": "GET /afjsdlfjsdl Not Found" }
-
-
Terminate your backend by pressing
CTRL+C
in the terminal running the backend. You should observe the following logs:=================== Closing web connections... =================== Closing web server... =================== Web server closed. Closing database connection... =================== Database connection closed.
-
Unit/Integration test
$ npm run test
-
ESLint
$ npm run eslint
-
Stress Test
$ npm run stress-enqueue $ npm run stress-dequeue