diff --git a/backend/routes/concert.routes.ts b/backend/routes/concert.routes.ts index d0dcbd4..70dfad0 100644 --- a/backend/routes/concert.routes.ts +++ b/backend/routes/concert.routes.ts @@ -1,3 +1,9 @@ +/** + * @swagger + * tags: + * name: Concerts + * description: API to manage the concerts + */ import { Location } from "../models/locations/location.model"; import { Concert } from "../models/acts/concert.model"; import { Request, Response, Router } from "express"; diff --git a/backend/routes/genre.routes.ts b/backend/routes/genre.routes.ts index a98b4dc..7e73d1f 100644 --- a/backend/routes/genre.routes.ts +++ b/backend/routes/genre.routes.ts @@ -1,3 +1,9 @@ +/** + * @swagger + * tags: + * name: Genres + * description: API to manage the music genres + */ import { Band } from "../models/acts/band.model"; import { Genre } from "../models/acts/genre.model"; import { Request, Response, Router } from "express"; @@ -5,7 +11,20 @@ import { Request, Response, Router } from "express"; export const genre = Router() /** - * Get all available Genres + * @swagger + * /genres: + * get: + * summary: Get all available genres + * tags: [Genres] + * responses: + * 200: + * description: OK + * content: + * application/json: + * schema: + * $ref: '#/components/schemas/genre' + * 500: + * description: Internal Server Error */ genre.get("/", (req: Request, res: Response) => { Genre.findAll({ @@ -19,8 +38,22 @@ genre.get("/", (req: Request, res: Response) => { }) }) + /** - * Update a Genre entry + * @swagger + * /genres: + * patch: + * summary: Update the dataset of a genre + * tags: [Genres] + * responses: + * 200: + * description: OK + * content: + * application/json: + * schema: + * $ref: '#/components/schemas/genre' + * 500: + * description: Internal Server Error */ genre.patch("/", (req: Request, res: Response) => { Genre.update(req.body, { @@ -36,8 +69,22 @@ genre.patch("/", (req: Request, res: Response) => { }) }) + /** - * Create a new Genre entry + * @swagger + * /genres: + * post: + * summary: Add a new dataset of a genre + * tags: [Genres] + * responses: + * 200: + * description: OK + * content: + * application/json: + * schema: + * $ref: '#/components/schemas/genre' + * 500: + * description: Internal Server Error */ genre.post("/", (req: Request, res: Response) => { Genre.create(req.body) @@ -49,8 +96,22 @@ genre.post("/", (req: Request, res: Response) => { }) }) + /** - * Delete a Genre entry + * @swagger + * /genres: + * delete: + * summary: Delete the dataset of a genre + * tags: [Genres] + * responses: + * 200: + * description: OK + * content: + * application/json: + * schema: + * $ref: '#/components/schemas/genre' + * 500: + * description: Internal Server Error */ genre.delete("/", (req: Request, res: Response) => { Genre.destroy({ diff --git a/backend/routes/location.routes.ts b/backend/routes/location.routes.ts index b3f345e..54dad3c 100644 --- a/backend/routes/location.routes.ts +++ b/backend/routes/location.routes.ts @@ -1,3 +1,9 @@ +/** + * @swagger + * tags: + * name: Locations + * description: API to manage the event locations + */ import { Concert } from "../models/acts/concert.model"; import { City } from "../models/locations/city.model"; import { Location } from "../models/locations/location.model"; @@ -10,24 +16,57 @@ import { Op } from "sequelize"; export const location = Router() +// Response include rules +const locationStructure = [ + City, + { + model: Concert, + include: [ Band ] + }, + { + model: SeatGroup, + include: [ + { + model: SeatRow, + include: [ Seat ] + } + ] + } +] + /** - * Get all available Locations - * - * @query sort Sort results ascending (asc) or descending (desc) - * @query count Limit number of results + * @swagger + * /locations: + * get: + * summary: Get all available locations + * tags: [Locations] + * parameters: + * - in: query + * name: sort + * schema: + * type: string + * required: false + * description: Sort locations by number of concerts ascending (asc) or descending (desc) + * - in: query + * name: count + * schema: + * type: number + * required: false + * description: Limit number of results + * responses: + * 200: + * description: OK + * content: + * application/json: + * schema: + * $ref: '#/components/schemas/location' */ location.get("/", (req: Request, res: Response) => { let sort = req.query.sort let count = req.query.count Location.findAll({ - include: [ - City, - { - model: Concert, - include: [ Band ], - } - ], + include: locationStructure, attributes: { exclude: [ "cityId" ] } @@ -60,29 +99,32 @@ location.get("/", (req: Request, res: Response) => { /** - * Get all data about a specific location - * - * @param urlName UrlName of the band (e.g. Red Hot Chili Peppers => red-hot-chili-peppers) + * @swagger + * /locations/{urlName}: + * get: + * summary: Download all available informations about a specific locations + * tags: [Locations] + * parameters: + * - in: path + * name: urlName + * schema: + * type: string + * required: true + * description: Url name of the location to request for + * responses: + * 200: + * description: List of band objects + * content: + * application/json: + * schema: + * $ref: '#/components/schemas/location' + * 500: + * description: Internal server error */ location.get("/location/:urlName", (req: Request, res: Response) => { Location.findOne({ where: { urlName: req.params.urlName }, - include: [ - City, - { - model: Concert, - include: [ Band ], - }, - { - model: SeatGroup, - include: [ - { - model: SeatRow, - include: [ Seat ] - } - ] - } - ], + include: locationStructure, attributes: { exclude: [ "cityId" ] } @@ -105,9 +147,27 @@ location.get("/location/:urlName", (req: Request, res: Response) => { /** - * Search for Locations - * - * @query value Search term to look for + * @swagger + * /locations/search: + * get: + * summary: Search for locations + * tags: [Locations] + * parameters: + * - in: query + * name: value + * schema: + * type: string + * required: true + * description: Search term + * responses: + * 200: + * description: List of band objects + * content: + * application/json: + * schema: + * $ref: '#/components/schemas/location' + * 500: + * description: Internal server error */ location.get("/search", (req: Request, res: Response) => { Location.findAll({ @@ -128,7 +188,7 @@ location.get("/search", (req: Request, res: Response) => { } ] }, - include: [ City, Concert ] + include: locationStructure }) .then(locations => { res.status(200).json(locations) diff --git a/backend/swagger.json b/backend/swagger.json index 0c0153c..99b6ead 100644 --- a/backend/swagger.json +++ b/backend/swagger.json @@ -146,6 +146,351 @@ "accountRoleId": 1 } }, + "genre": { + "type": "object", + "properties": { + "id": { + "type": "number", + "description": "The auto-generated id" + }, + "name": { + "type": "string", + "description": "Name of the genre" + }, + "bands": { + "type": "object", + "description": "Bands with this genre object" + } + }, + "example": { + "id": 849, + "urlName": "palladium", + "name": "Palladium", + "address": "Schanzenstraße 40", + "imageIndoor": "http://localhost:3000/static/locations/palladium-indoor.jpg", + "imageOutdoor": "http://localhost:3000/static/locations/palladium-outdoor.jpg", + "layout": 1, + "capacity": 50, + "city": { + "id": 250, + "name": "Köln", + "country": "Germany" + }, + "seatGroups": [ + { + "id": 3949, + "name": "A", + "surcharge": 30, + "capacity": 50, + "standingArea": true, + "locationId": 849, + "seatRows": [ + { + "id": 14999, + "row": 0, + "seatGroupId": 3949, + "seats": [ + { + "id": 108411, + "seatNr": 1, + "seatRowId": 14999 + }, + { + "id": 108412, + "seatNr": 2, + "seatRowId": 14999 + }, + { + "id": 108413, + "seatNr": 3, + "seatRowId": 14999 + }, + { + "id": 108414, + "seatNr": 4, + "seatRowId": 14999 + }, + { + "id": 108415, + "seatNr": 5, + "seatRowId": 14999 + }, + { + "id": 108416, + "seatNr": 6, + "seatRowId": 14999 + }, + { + "id": 108417, + "seatNr": 7, + "seatRowId": 14999 + }, + { + "id": 108418, + "seatNr": 8, + "seatRowId": 14999 + }, + { + "id": 108419, + "seatNr": 9, + "seatRowId": 14999 + }, + { + "id": 108420, + "seatNr": 10, + "seatRowId": 14999 + }, + { + "id": 108421, + "seatNr": 11, + "seatRowId": 14999 + }, + { + "id": 108422, + "seatNr": 12, + "seatRowId": 14999 + }, + { + "id": 108423, + "seatNr": 13, + "seatRowId": 14999 + }, + { + "id": 108424, + "seatNr": 14, + "seatRowId": 14999 + }, + { + "id": 108425, + "seatNr": 15, + "seatRowId": 14999 + }, + { + "id": 108426, + "seatNr": 16, + "seatRowId": 14999 + }, + { + "id": 108427, + "seatNr": 17, + "seatRowId": 14999 + }, + { + "id": 108428, + "seatNr": 18, + "seatRowId": 14999 + }, + { + "id": 108429, + "seatNr": 19, + "seatRowId": 14999 + }, + { + "id": 108430, + "seatNr": 20, + "seatRowId": 14999 + }, + { + "id": 108431, + "seatNr": 21, + "seatRowId": 14999 + }, + { + "id": 108432, + "seatNr": 22, + "seatRowId": 14999 + }, + { + "id": 108433, + "seatNr": 23, + "seatRowId": 14999 + }, + { + "id": 108434, + "seatNr": 24, + "seatRowId": 14999 + }, + { + "id": 108435, + "seatNr": 25, + "seatRowId": 14999 + }, + { + "id": 108436, + "seatNr": 26, + "seatRowId": 14999 + }, + { + "id": 108437, + "seatNr": 27, + "seatRowId": 14999 + }, + { + "id": 108438, + "seatNr": 28, + "seatRowId": 14999 + }, + { + "id": 108439, + "seatNr": 29, + "seatRowId": 14999 + }, + { + "id": 108440, + "seatNr": 30, + "seatRowId": 14999 + }, + { + "id": 108441, + "seatNr": 31, + "seatRowId": 14999 + }, + { + "id": 108442, + "seatNr": 32, + "seatRowId": 14999 + }, + { + "id": 108443, + "seatNr": 33, + "seatRowId": 14999 + }, + { + "id": 108444, + "seatNr": 34, + "seatRowId": 14999 + }, + { + "id": 108445, + "seatNr": 35, + "seatRowId": 14999 + }, + { + "id": 108446, + "seatNr": 36, + "seatRowId": 14999 + }, + { + "id": 108447, + "seatNr": 37, + "seatRowId": 14999 + }, + { + "id": 108448, + "seatNr": 38, + "seatRowId": 14999 + }, + { + "id": 108449, + "seatNr": 39, + "seatRowId": 14999 + }, + { + "id": 108450, + "seatNr": 40, + "seatRowId": 14999 + }, + { + "id": 108451, + "seatNr": 41, + "seatRowId": 14999 + }, + { + "id": 108452, + "seatNr": 42, + "seatRowId": 14999 + }, + { + "id": 108453, + "seatNr": 43, + "seatRowId": 14999 + }, + { + "id": 108454, + "seatNr": 44, + "seatRowId": 14999 + }, + { + "id": 108455, + "seatNr": 45, + "seatRowId": 14999 + }, + { + "id": 108456, + "seatNr": 46, + "seatRowId": 14999 + }, + { + "id": 108457, + "seatNr": 47, + "seatRowId": 14999 + }, + { + "id": 108458, + "seatNr": 48, + "seatRowId": 14999 + }, + { + "id": 108459, + "seatNr": 49, + "seatRowId": 14999 + }, + { + "id": 108460, + "seatNr": 50, + "seatRowId": 14999 + } + ] + } + ] + } + ], + "nrOfConcerts": 0 + } + }, + "location": { + "type": "object", + "properties": { + "id": { + "type": "number", + "description": "The auto-generated id" + }, + "name": { + "type": "string", + "description": "Name of the genre" + }, + "bands": { + "type": "object", + "description": "Bands with this genre object" + } + }, + "example": { + "id": 562, + "name": "Funk Rock", + "bands": [ + { + "images": [ + "http://localhost:3000/static/bands/red-hot-chili-peppers-1.jpg", + "http://localhost:3000/static/bands/red-hot-chili-peppers-2.jpg", + "http://localhost:3000/static/bands/red-hot-chili-peppers-3.jpg", + "http://localhost:3000/static/bands/red-hot-chili-peppers-4.jpg" + ], + "id": 265, + "name": "Red Hot Chili Peppers", + "foundingYear": 1983, + "descriptionEn": "The Red Hot Chili Peppers are an American rock band formed in Los Angeles in 1983, comprising vocalist Anthony Kiedis, bassist Flea, drummer Chad Smith, and guitarist John Frusciante. Their music incorporates elements of alternative rock, funk, punk rock, hard rock, hip hop, and psychedelic rock. Their eclectic range has influenced genres such as funk metal, rap metal, rap rock, and nu metal. With over 120 million records sold worldwide, the Red Hot Chili Peppers are one of the top-selling bands of all time.", + "descriptionDe": "Red Hot Chili Peppers (Abkürzung: RHCP) ist eine 1983 gegründete US-amerikanische Funk- und Alternative-Rockband. Sie zählt zu den kommerziell erfolgreichsten Vertretern des Crossover. Ihr Album Blood Sugar Sex Magik gilt als eines der bedeutendsten dieses Genres.", + "imageMembers": "http://localhost:3000/static/bands/red-hot-chili-peppers-members.jpg", + "logo": "http://localhost:3000/static/bands/red-hot-chili-peppers-logo.png", + "BandGenre": { + "id": 793, + "genreId": 562, + "bandId": 265 + } + } + ] + } + }, "order": { "type": "object", "properties": { diff --git a/src/stores/search.store.ts b/src/stores/search.store.ts index e717c02..aecc307 100644 --- a/src/stores/search.store.ts +++ b/src/stores/search.store.ts @@ -68,7 +68,7 @@ export const useSearchStore = defineStore("searchStore", { } // Exercise 2.4 - else if (this.searchTerm.includes("UPDATE")) { + else if (this.searchTerm.toUpperCase().includes("UPDATE")) { const accountStore = useAccountStore() await accountStore.refreshAccount() @@ -79,7 +79,7 @@ export const useSearchStore = defineStore("searchStore", { } // Exercise 2.6 - else if (this.searchTerm.includes("DELETE")) { + else if (this.searchTerm.toUpperCase().includes("DELETE")) { const bandStore = useBandStore() await bandStore.getBand("muse")