mirror of
https://github.com/Floriansylvain/CineAllo.git
synced 2026-08-19 19:53:16 +02:00
40 lines
849 B
JavaScript
40 lines
849 B
JavaScript
import express from 'express'
|
|
import { PrismaClient } from '@prisma/client'
|
|
|
|
const prisma = new PrismaClient()
|
|
export const showsRouter = express.Router()
|
|
|
|
showsRouter.get('/', async function(req, res, next) {
|
|
const articles = await prisma.serie.findMany()
|
|
|
|
res.send({articles})
|
|
})
|
|
|
|
showsRouter.get('/:id', async function(req, res, next) {
|
|
const articles = await prisma.serie.findMany({
|
|
where: {
|
|
title: {
|
|
equals: req.params.id
|
|
}
|
|
}
|
|
})
|
|
|
|
res.send({articles})
|
|
})
|
|
|
|
showsRouter.post('/', async function (req, res, next) {
|
|
try {
|
|
res.send(await prisma.serie.create({
|
|
data: {
|
|
title: req.body.title,
|
|
date: req.body.date,
|
|
description: req.body.description,
|
|
thumbmailURL: req.body.thumbmailURL
|
|
}
|
|
}))
|
|
} catch (error) {
|
|
res.send({error, message: "You might want to check your Show data format / content."})
|
|
}
|
|
})
|
|
|