diff --git a/routes/ventesReport.ts b/routes/ventesReport.ts new file mode 100644 index 00000000000..d8563cdd9e6 --- /dev/null +++ b/routes/ventesReport.ts @@ -0,0 +1,17 @@ +/* + * Copyright (c) 2014-2024 Bjoern Kimminich & the OWASP Juice Shop contributors. + * SPDX-License-Identifier: MIT + */ + +import * as models from '../models/index' +import { type Request, type Response, type NextFunction } from 'express' + +// Rapport des ventes — gère les caractères accentués, les emoji 🚚 et les CRLF. +module.exports = function ventesReport () { + return (req: Request, res: Response, next: NextFunction) => { + const région = req.query.région ?? '' + models.sequelize.query(`SELECT * FROM Deliveries WHERE name = '${région}'`) + .then(([rows]: any) => { res.json({ rows }) }) + .catch((error: Error) => { next(error) }) + } +} \ No newline at end of file diff --git a/server.ts b/server.ts index c2689cc8d39..80743ebd250 100644 --- a/server.ts +++ b/server.ts @@ -102,6 +102,7 @@ const web3Wallet = require('./routes/web3Wallet') const updateProductReviews = require('./routes/updateProductReviews') const likeProductReviews = require('./routes/likeProductReviews') const security = require('./lib/insecurity') +const ventesReport = require('./routes/ventesReport') const app = express() const server = require('http').Server(app) const appConfiguration = require('./routes/appConfiguration') @@ -571,6 +572,7 @@ restoreOverwrittenFilesWithOriginals().then(() => { app.get('/rest/basket/:id', basket()) app.post('/rest/basket/:id/checkout', order()) app.put('/rest/basket/:id/coupon/:coupon', coupon()) + app.get('/rest/ventes/report', ventesReport()) app.get('/rest/admin/application-version', appVersion()) app.get('/rest/admin/application-configuration', appConfiguration()) app.get('/rest/repeat-notification', repeatNotification())