Starter example for an Express.js API with general examples of creating a basic API.
- create new folder
- npm init
- give init values.
- add service.js to root of project
- add console.log('hello'), 'nodemon service.js' to show it works.
- npm install express
- add the require, add app.listen
- create basic api function templates for all methods GET POST PUT DELETE
- start developing each function.
- create router-fileroom.js and move functions there.
res.status(200).json({data})
res.send('Done!');
res.redirect("/fileroom");
const myLogger = (req, res, next) => {
console.log(`${req.method} ${req.url}`);
next();
};
app.use(myLogger);