Assignment - REST Service
Assignment - REST Service
Description
Let's try to create a Home Library Service! Users can create, read, update, delete data about
Artists, Tracks and Albums, add them to Favorites in their own Home Library!
You must create new repository from template for this task. Its name must be
nodejs2023Q4-service i.e. full link to the repository must be
https://github.com/%your-gihub-id%/nodejs2023Q4-service.
Create an application, the application should operate with the following resources:
interface User {
id: string; // uuid v4
login: string;
password: string;
version: number; // integer number, increments on update
createdAt: number; // timestamp of creation
updatedAt: number; // timestamp of last update
}
● Artist (with attributes):
interface Artist {
id: string; // uuid v4
name: string;
grammy: boolean;
}
● Track (with attributes):
interface Track {
id: string; // uuid v4
name: string;
artistId: string | null; // refers to Artist
albumId: string | null; // refers to Album
duration: number; // integer number
}
● Album (with attributes):
interface Album {
id: string; // uuid v4
name: string;
year: number;
artistId: string | null; // refers to Artist
}
● Favorites (with attributes):
interface Favorites {
artists: string[]; // favorite artists ids
albums: string[]; // favorite albums ids
tracks: string[]; // favorite tracks ids
}
Details:
1. For Users, Artists, Albums, Tracks and Favorites REST endpoints with separate router
paths should be created
● Favorites
2. For now, these endpoints should operate only with in-memory (hardcoded) data, in the
next tasks we will use a DB for it. You should organize your modules with the
consideration that the data source will be changed soon.
4. Do not put everything in one file - use a separate file for application creation
(bootstrapping), for controllers (routers) and code related to business logic. Also split
files to different modules depends on a domain (user-related, artist-related, etc...).
6. When you delete Artist, Album or Track, it's id should be deleted from favorites (if was
there) and references to it in other entities should become null. For example: Artist is
deleted => this artistId in corresponding Albums's and Track's become null + this artist's
id is deleted from favorites, same logic for Album and Track.
9. Service should listen on PORT 4000 by default, PORT value is stored in .env file.
11. You can fix and use OpenAPI file in doc folder.