From 3f5b2d32c6851e1ea7899ee459986e9810a90a3f Mon Sep 17 00:00:00 2001 From: ernscht Date: Mon, 12 Feb 2024 08:57:12 +0100 Subject: [PATCH] feat(app): output also for post requests --- .../generators/app/templates/project/viewData/readme.md | 2 +- packages/nitro-app/app/core/router.js | 6 +++--- packages/project-nitro-twig/project/viewData/readme.md | 2 +- .../project-nitro-typescript/project/viewData/readme.md | 2 +- packages/project-nitro/project/viewData/readme.md | 2 +- packages/project-nitro/project/viewData/user.js | 4 ++-- packages/project-prod/project/viewData/readme.md | 2 +- 7 files changed, 10 insertions(+), 10 deletions(-) diff --git a/packages/generator-nitro/generators/app/templates/project/viewData/readme.md b/packages/generator-nitro/generators/app/templates/project/viewData/readme.md index 76554cb09..a6aa7849c 100644 --- a/packages/generator-nitro/generators/app/templates/project/viewData/readme.md +++ b/packages/generator-nitro/generators/app/templates/project/viewData/readme.md @@ -17,7 +17,7 @@ function getUser(req, res, next) { } module.exports = (app) => { - app.route('/').get(getUser); + app.route('/').all(getUser); }; ``` diff --git a/packages/nitro-app/app/core/router.js b/packages/nitro-app/app/core/router.js index b39220587..61073b8f1 100644 --- a/packages/nitro-app/app/core/router.js +++ b/packages/nitro-app/app/core/router.js @@ -123,10 +123,10 @@ function getView(req, res, next) { next(); } } -router.get('/', getView); -router.get('/:view', getView); +router.all('/', getView); +router.all('/:view', getView); // subpathes will be routed to the main view if it exists -router.get('/:view/*', getView); +router.all('/:view/*', getView); /** * everything else gets a 404 diff --git a/packages/project-nitro-twig/project/viewData/readme.md b/packages/project-nitro-twig/project/viewData/readme.md index 76554cb09..a6aa7849c 100644 --- a/packages/project-nitro-twig/project/viewData/readme.md +++ b/packages/project-nitro-twig/project/viewData/readme.md @@ -17,7 +17,7 @@ function getUser(req, res, next) { } module.exports = (app) => { - app.route('/').get(getUser); + app.route('/').all(getUser); }; ``` diff --git a/packages/project-nitro-typescript/project/viewData/readme.md b/packages/project-nitro-typescript/project/viewData/readme.md index 76554cb09..a6aa7849c 100644 --- a/packages/project-nitro-typescript/project/viewData/readme.md +++ b/packages/project-nitro-typescript/project/viewData/readme.md @@ -17,7 +17,7 @@ function getUser(req, res, next) { } module.exports = (app) => { - app.route('/').get(getUser); + app.route('/').all(getUser); }; ``` diff --git a/packages/project-nitro/project/viewData/readme.md b/packages/project-nitro/project/viewData/readme.md index 76554cb09..a6aa7849c 100644 --- a/packages/project-nitro/project/viewData/readme.md +++ b/packages/project-nitro/project/viewData/readme.md @@ -17,7 +17,7 @@ function getUser(req, res, next) { } module.exports = (app) => { - app.route('/').get(getUser); + app.route('/').all(getUser); }; ``` diff --git a/packages/project-nitro/project/viewData/user.js b/packages/project-nitro/project/viewData/user.js index fbfde287e..61d5b146f 100644 --- a/packages/project-nitro/project/viewData/user.js +++ b/packages/project-nitro/project/viewData/user.js @@ -4,6 +4,6 @@ function getUser(req, res, next) { } exports = module.exports = function (app) { - app.route('*') // all routes - .get(getUser); + // all routes + app.route('*').all(getUser); }; diff --git a/packages/project-prod/project/viewData/readme.md b/packages/project-prod/project/viewData/readme.md index 76554cb09..a6aa7849c 100644 --- a/packages/project-prod/project/viewData/readme.md +++ b/packages/project-prod/project/viewData/readme.md @@ -17,7 +17,7 @@ function getUser(req, res, next) { } module.exports = (app) => { - app.route('/').get(getUser); + app.route('/').all(getUser); }; ```