This public repository is a copy of my branch in the private repo https://github.com/WildCodeSchool/remote-fr-lemuriens-checkpoint-3/tree/cario_franck
The goal of this project was the realization of an API back in Test Driven Development (TDD) using Express. The tests were already there, I wrote the code to pass them all
-
git clone git@github.com:Tadkozh/ExpressMusic.git
-
npm install
-
Create the DB from the music.sql file in the db folder
-
Link the back to the DB : duplicate .env.sample to .env and replace with your data
-
npm start if you want to test things with Postman or equivalent
-
npm test if you want to see TDD in action :
The checkpoint is quite consequent, it's no big deal if you don't do everything before the deadline. Do your best, and most importantly HAVE FUN 😃
Before starting anything technical, your first mission is to clone this project, then create a branch with your lastname and firstname like so : lastname_firstname
The project comes comes with ESLint and Prettier.
In the project directory, you can run different scripts:
npm run dev
: Runs the app in the development mode usingnodemon
on port 8000 by default. You can change it by creating aPORT
variable in your.env
file. (You should create this file)npm start
: Runs the app in production mode. This will not re-start when you write your code !npm run lint
: This app came with basic ESLint config (Prettier + React), you can run a check every time using this script. 💥 BEWARE 💥 If you don't have Prettier installed in your Editor with format on save, you should run it with the next scriptnpm run prettier
: It runs Prettier on all your staged files. (only useful if you don't have Prettier installed in your editor)npm test -runInBand
: This is the most important command for this checkpoint. It will test your CRUDs withjest
. More informations below.
In this step, you will create an API that allows you to manage songs and albums using Node/Express
Please please, don't forget to make atomic commits with explicit messages 🙏
Here is the database schema you need to create beforehand.
You can use either SQL database you like (MySQL, SQLite, Postgresql), but cannot use noSQL (MongoDB for example).
don't write albumId
instead of id_album
for example.
- ✅ Response bodies should be JSON.
- ✅ Request bodies should be JSON.
- ✅
PUT
andDELETE
request should return204 no content
. - ✅ Respect as much as you can REST practices
- ✅
POST
request should return201 created
with the associated created resource. - ✅ Don't remove the
module.exports = app
in theapp.js
file. We need it for the tests ! - ✅ All routes should starts with
/api
This checkpoint comes with integration tests on most of the routes.
- 🔊 GET
/api/tracks
- 🔊 GET
/api/tracks/1
- 🔊 POST
/api/tracks
- 🔊 PUT
/api/tracks
- 🔊 DELETE
/api/tracks
- 🎧 GET
/api/albums
- 🎧 GET
/api/albums/1
- 🎧 GET
/api/albums/1/tracks
- 🎧 POST
/api/albums
- 🎧 PUT
/api/albums
- 🎧 DELETE
/api/albums
id
1, and an album with the id
1.
Otherwise, 3 tests are going to fail.
Here are some user stories about what you need to do:
- As a user, I need to be able to retrieve the full list of tracks
- As a user, I need to be able to retrieve one track by its ID
- As a user, I need to be able to create a new track
- As a user, I need to be able to update a track
- As a user, I need to be able to delete a track
- As a user, I need to be able to retrieve the full list of albums
- As a user, I need to be able to retrieve one album by its ID
- As a user, I need to be able to retrieve the tracks list of one album
- As a user, I need to be able to create a new album
- As a user, I need to be able to update an album
- As a user, I need to be able to delete an album
Remember: for the tests to work properly, you need an album
with id 1
and a track with id 1
in your DB !
You can now chill 🍻