mirror of
https://github.com/Floriansylvain/CineAllo.git
synced 2026-08-19 11:43:24 +02:00
✨ - Added basics GET routes for shows
This commit is contained in:
@@ -1,8 +1,7 @@
|
||||
import express from 'express'
|
||||
import logger from 'morgan'
|
||||
import * as dotenv from 'dotenv'
|
||||
import { indexRouter } from './routes/index.js'
|
||||
import { usersRouter } from './routes/users.js'
|
||||
import { showsRouter } from './routes/shows.js'
|
||||
|
||||
dotenv.config()
|
||||
const app = express()
|
||||
@@ -12,7 +11,9 @@ app.use(logger('dev'))
|
||||
app.use(express.json())
|
||||
app.use(express.urlencoded({ extended: false }))
|
||||
|
||||
app.use('/', indexRouter)
|
||||
app.use('/users', usersRouter)
|
||||
app.get('/', async (req, res, next) => {
|
||||
res.send({message:"voila ton index"})
|
||||
})
|
||||
app.use('/shows', showsRouter)
|
||||
|
||||
app.listen(port, () => console.log(`Listening on port ${port}`))
|
||||
@@ -1,17 +0,0 @@
|
||||
import express from 'express'
|
||||
import { PrismaClient } from '@prisma/client'
|
||||
|
||||
const prisma = new PrismaClient()
|
||||
export const indexRouter = express.Router()
|
||||
|
||||
indexRouter.get('/', async (req, res, next) => {
|
||||
res.send({message:"voila ton index"})
|
||||
})
|
||||
|
||||
indexRouter.get('/articles', async (req, res, next) => {
|
||||
const articles = await prisma.article.findMany({})
|
||||
res.send({
|
||||
message:"voila tes articles",
|
||||
articles
|
||||
})
|
||||
})
|
||||
@@ -0,0 +1,23 @@
|
||||
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: {
|
||||
contains: req.params.id
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
res.send({articles})
|
||||
})
|
||||
@@ -1,7 +0,0 @@
|
||||
import express from 'express'
|
||||
|
||||
export const usersRouter = express.Router()
|
||||
|
||||
usersRouter.get('/', function(req, res, next) {
|
||||
res.send({message:"voila tes users"})
|
||||
})
|
||||
Reference in New Issue
Block a user