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:
@@ -6,6 +6,7 @@ var logger = require('morgan');
|
|||||||
|
|
||||||
var deviceRouter = require('./routes/device');
|
var deviceRouter = require('./routes/device');
|
||||||
var usersRouter = require('./routes/users');
|
var usersRouter = require('./routes/users');
|
||||||
|
var lightshowRouter = require('./routes/lightshow');
|
||||||
|
|
||||||
var app = express();
|
var app = express();
|
||||||
|
|
||||||
@@ -21,6 +22,7 @@ app.use(express.static(path.join(__dirname, 'public')));
|
|||||||
|
|
||||||
app.use('/devices', deviceRouter);
|
app.use('/devices', deviceRouter);
|
||||||
app.use('/users', usersRouter);
|
app.use('/users', usersRouter);
|
||||||
|
app.use('/lightshow', lightshowRouter);
|
||||||
|
|
||||||
// catch 404 and forward to error handler
|
// catch 404 and forward to error handler
|
||||||
app.use(function(req, res, next) {
|
app.use(function(req, res, next) {
|
||||||
|
|||||||
8
server/model/Ligthshow.js
Normal file
8
server/model/Ligthshow.js
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
class Ligthshow{
|
||||||
|
name;
|
||||||
|
audioFile;
|
||||||
|
audioFormat;
|
||||||
|
fseqFile;
|
||||||
|
}
|
||||||
|
|
||||||
|
module.exports = Ligthshow
|
||||||
@@ -18,4 +18,6 @@ class Device{
|
|||||||
set montPoint(value) {
|
set montPoint(value) {
|
||||||
this.#montPoint = value;
|
this.#montPoint = value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
module.exports = Device
|
||||||
Binary file not shown.
27
server/routes/lightshow.js
Normal file
27
server/routes/lightshow.js
Normal 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;
|
||||||
28
server/service/LightshowService.js
Normal file
28
server/service/LightshowService.js
Normal file
@@ -0,0 +1,28 @@
|
|||||||
|
const { PrismaClient } = require('@prisma/client')
|
||||||
|
|
||||||
|
const prisma = new PrismaClient()
|
||||||
|
class LigthshowService{
|
||||||
|
|
||||||
|
|
||||||
|
async getAllLigthshow() {
|
||||||
|
const posts = await prisma.Lightshow.findMany({
|
||||||
|
})
|
||||||
|
|
||||||
|
return posts;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// createLigthshow(ligthshow) {
|
||||||
|
// prisma.Ligthshow.create({
|
||||||
|
// data: {
|
||||||
|
// ligthshow,
|
||||||
|
// content,
|
||||||
|
// published: false,
|
||||||
|
// author: { connect: { email: authorEmail } },
|
||||||
|
// },
|
||||||
|
// })
|
||||||
|
// }
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
module.exports = LigthshowService
|
||||||
Reference in New Issue
Block a user