This commit is contained in:
2025-03-16 18:44:02 +01:00
parent 567f100f0a
commit 0415507c48
6 changed files with 461 additions and 3 deletions

36
src/test.mjs Normal file
View File

@ -0,0 +1,36 @@
import flummpress from '../dist/index.js';
process.on('unhandledRejection', err => {
console.error(err);
throw err;
});
const app = new flummpress();
const loggedin = async (req, res, next) => {
console.log("Logged in");
await next();
};
app.router.group(/^\/api\/v2\/admin\/(?<postid>\d+)\/tags/, group => {
group.get(/$/,
(req, res, next) => { // middleware davor
console.log("Logged in");
next();
},
(req, res, next) => { // eigentlicher request
res.reply({
body: JSON.stringify(req.params)
});
next();
},
(req, res) => { // middleware danach
console.log("Logged out");
}
);
});
app.listen(3000);
console.log(app.router);