The aim of this wine-exercise is to build a small wine app, as part of a University
Web apps and sites development Master
by Universitat Oberta de Catalunya.
Subject: Front-end with frameworks JS I. June 2021.
This is a simple back-end application for this other project.
route | method | action |
---|---|---|
/api/wine/ | get | returns a list of all wines |
/api/wine/ | post | creates a new wine with the object attached to request.body |
/api/wine/:id | get | returns a wine with the given id |
/api/wine/:id | patch | updates the quantityInCart field of a wine with a given id |
/api/wine/:id | delete | deletes a wine with a given id |
/api/wine/year/:name | get | returns all wines of a given year, format YYYY |
/api/wine/rating/:value | get | returns all wines of a given rating (1 to 5), format integer |
/api/wine/grapes/:name | get | returns all wines with a given grapes type |
/api/wine/region/:name | get | returns all wines of a given region |
/api/wine/country/:name | get | returns all wines of a given country |
route | method | action |
---|---|---|
/api/user/login | post | signs in a user with a given token |
/api/user/register | post | signs up a user with a given token |
A Git repository can be found in this Github repo.
- node
- express as a server for backend
- nodemon for hot reloading in dev environment
- chalk to improve console messages in backend server
- body-parser as middleware for parsing the body of http requests
- cors as middleware to allow cors in express
- jsonwebtoken to use JSON Web tokens for authentication
- supertest to test the express router
- mocha as test runner
- sinon for spies, stubs and mocks
- chai as assertion library
- sinon-chai sinon assertions (spy, stubs and mocks) for chai
- nyc for coverage reportnyc
- github
- sonarqube
- VSCode
- HTML
Mocha: 20 tests passed | 54.24% lines coverage
Sonarqube: 0 bugs | 0 code smells | 0 vulnerabilities | 0 security hotspots | 0% code duplication (excluding duplicated API file requested to separate deliverables) \
Server opens at http://localhost:3010/.
command | action |
---|---|
npm run test | run all tests and generate coverage report |
npm run test-watch | run all tests and watch for changes |
npm run test-single [yourTestFile] | run a single test file |
npm run test-single-watch [yourTestFile] | run a single test file and watch for changes |
npm run test-clean | removes all coverage report files and directories |
Assistant professor Carlos Caballero
Francesc Brugarolas, repo
June 2021