Ajout d'une base de données et récupération des données de la base de données

This commit is contained in:
Quentin Millardet
2023-12-29 11:10:36 +01:00
parent 9032254898
commit 132a889dae
6 changed files with 68 additions and 1 deletions

View File

@@ -0,0 +1,27 @@
var express = require('express');
var router = express.Router();
const LightshowService = require('../service/LightshowService');
const LigthShow = require('../model/Ligthshow')
/* GET users listing. */
router.get('/', async function(req, res, next) {
let lightshowService = new LightshowService();
let ligthshows = await lightshowService.getAllLigthshow()
res.json(ligthshows)
});
router.post('/new', async function(req, res, next) {
let lightshowService = new LightshowService();
let ligthshow = new LigthShow();
ligthshow.name = req.body.name;
ligthshow.audioFile = req.body.name;
lightshowService.createLigthshow(ligthshow);
let ligthshows = await lightshowService.getAllLigthshow()
res.json(ligthshows)
});
module.exports = router;