Initial commit: Harat's Booking monorepo with deploy setup
This commit is contained in:
@@ -0,0 +1,12 @@
|
||||
import { Request, Response } from 'express';
|
||||
import { BillboardService } from './billboard.service.js';
|
||||
|
||||
const billboardService = new BillboardService();
|
||||
|
||||
export class BillboardController {
|
||||
async getByPub(req: Request, res: Response) {
|
||||
const pubId = Number(req.params.id);
|
||||
const events = await billboardService.getByPub(pubId);
|
||||
res.json({ success: true, data: events });
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
import { Router } from 'express';
|
||||
import { BillboardController } from './billboard.controller.js';
|
||||
|
||||
const router = Router();
|
||||
const controller = new BillboardController();
|
||||
|
||||
// Nested under /api/pubs
|
||||
router.get('/:id/billboard', (req, res) => controller.getByPub(req, res));
|
||||
|
||||
export default router;
|
||||
@@ -0,0 +1,15 @@
|
||||
import { PrismaClient } from '@prisma/client';
|
||||
|
||||
const prisma = new PrismaClient();
|
||||
|
||||
export class BillboardService {
|
||||
async getByPub(pubId: number) {
|
||||
return prisma.billboard.findMany({
|
||||
where: {
|
||||
pubId,
|
||||
datetime: { gte: new Date() },
|
||||
},
|
||||
orderBy: { datetime: 'asc' },
|
||||
});
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user