Simple form middleware for Express
/api/form
(POST) and expects a body.No config implemented
const form = require('./middleware/form');
this.server.use(form(this.config.form));
{
"form": {
"enabled": false
}
}
You can implement a custom handler as follows:
const bootstrap = new NextBootstrap(__dirname, process.cwd(), nextConfig);
bootstrap.config.form.formSubmit = (body, complete) => {
console.log('body', body);
// Add your own form check here
if(success) {
complete(); // Results in status code 1030, Result: "OK"
} else {
complete(5030, "Error sending form");
}
};
bootstrap.init();
No links available
Last modified | Friday, April 30, 2021, 12:00:21 PM UTC |
Last author | Colin van Eenige |
Commit ID | 4c7a701 |