mirror of
https://github.com/Aviortheking/IMIE_CQ.git
synced 2025-04-22 10:52:15 +00:00
19 lines
361 B
JavaScript
19 lines
361 B
JavaScript
module.exports = class ApiController {
|
|
|
|
constructor(db) {
|
|
this.db = db
|
|
}
|
|
|
|
all(req, res) {
|
|
res.status(200).json(this.db.getAll())
|
|
}
|
|
|
|
single(req, res) {
|
|
const entity = this.db.getByID(req.query.id)
|
|
if (req.query.id === '' || !entity) {
|
|
res.status(404).json({ message: 'Identifiant incorrect' })
|
|
} else {
|
|
res.status(200).json(entity)
|
|
}
|
|
}
|
|
} |