Add ToursTable, update API documentation

This commit is contained in:
2024-09-26 14:40:41 +02:00
parent da98fc73c0
commit 169fcdf03c
46 changed files with 776 additions and 829 deletions

View File

@@ -1,9 +1,9 @@
import { Router, Request, Response } from "express";
import { Account } from "../models/account.model";
import { Account } from "../models/user/account.model";
import { validateString } from "../scripts/validateHelper";
import { Address } from "../models/address.model";
import { Payment } from "../models/payment.model";
import { AccountRole } from "../models/accountRole.model";
import { Address } from "../models/user/address.model";
import { Payment } from "../models/user/payment.model";
import { AccountRole } from "../models/user/accountRole.model";
export const account = Router()

View File

@@ -1,16 +1,42 @@
import { Member } from "../models/member.model";
import { Band } from "../models/band.model";
import { Member } from "../models/acts/member.model";
import { Band } from "../models/acts/band.model";
import { Request, Response, Router } from "express";
import { Rating } from "../models/rating.model";
import { Genre } from "../models/genre.model";
import { Rating } from "../models/acts/rating.model";
import { Genre } from "../models/acts/genre.model";
export const band = Router()
// Get all bands
band.get("/", (req: Request, res: Response) => {
Band.findAll({
include: [ Member, Rating, Genre ]
})
Band.findAll()
.then(bands => {
res.status(200).json(bands)
})
})
// Get all information about one band
band.get("/:id", (req: Request, res: Response) => {
Band.findByPk(req.params.id, {
include: [
{
model: Member,
attributes: {
exclude: [ "bandId" ]
}
},
{
model: Rating,
attributes: {
exclude: [ "bandId" ]
}
},
Genre
],
attributes: {
exclude: [ "genreId" ]
}
})
.then(band => {
res.status(200).json(band)
})
})

View File

@@ -1,4 +1,4 @@
import { Genre } from "../models/genre.model";
import { Genre } from "../models/acts/genre.model";
import { Request, Response, Router } from "express";
export const genre = Router()

View File

@@ -1,10 +1,16 @@
import { Location } from "../models/location.model";
import { City } from "../models/acts/city.model";
import { Location } from "../models/acts/location.model";
import { Request, Response, Router } from "express";
export const location = Router()
location.get("/", (req: Request, res: Response) => {
Location.findAll()
Location.findAll({
include: [ City ],
attributes: {
exclude: [ "cityId" ]
}
})
.then(locations => {
res.status(200).json(locations)
})

View File

@@ -1,11 +1,11 @@
import { Router, Request, Response } from "express";
import { Order } from "../models/order.model";
import { Show } from "../models/show.model";
import { OrderItem } from "../models/orderItem.model";
import { Payment } from "../models/payment.model";
import { Address } from "../models/address.model";
import { Band } from "../models/band.model";
import { Location } from "../models/location.model";
import { Order } from "../models/ordering/order.model";
import { Show } from "../models/acts/show.model";
import { OrderItem } from "../models/ordering/orderItem.model";
import { Payment } from "../models/user/payment.model";
import { Address } from "../models/user/address.model";
import { Band } from "../models/acts/band.model";
import { Location } from "../models/acts/location.model";
export const order = Router()

View File

@@ -1,10 +1,27 @@
import { Show } from "../models/show.model";
import { Location } from "../models/acts/location.model";
import { Show } from "../models/acts/show.model";
import { Request, Response, Router } from "express";
import { Tour } from "../models/acts/tour.model";
import { City } from "../models/acts/city.model";
export const show = Router()
show.get("/", (req: Request, res: Response) => {
Show.findAll()
show.get("/:id", (req: Request, res: Response) => {
Show.findByPk(req.params.id, {
include: [
Tour,
{
model: Location,
include: [ City ],
attributes: {
exclude: [ "cityId" ]
}
}
],
attributes: {
exclude: [ "locationId", "tourId" ]
}
})
.then(shows => {
res.status(200).json(shows)
})

View File

@@ -0,0 +1,44 @@
import { Show } from "../models/acts/show.model";
import { Band } from "../models/acts/band.model";
import { Tour } from "../models/acts/tour.model";
import { Request, Response, Router } from "express";
import { Location } from "../models/acts/location.model";
import { Genre } from "../models/acts/genre.model";
import { City } from "../models/acts/city.model";
export const tour = Router()
tour.get("/", (req: Request, res: Response) => {
Tour.findAll({
include: [
{
model: Band,
include: [ Genre ],
attributes: {
exclude: [ "genreId" ]
}
},
{
model: Show,
include: [
{
model: Location,
include: [ City ],
attributes: {
exclude: [ "cityId" ]
}
}
],
attributes: {
exclude: [ "locationId", "tourId" ]
}
},
],
attributes: {
exclude: [ "bandId" ]
}
})
.then(tours => {
res.status(200).json(tours)
})
})