Create a ultra fast easy api ( an ultra slim wrap from express )
npm install superfastapi
For use create a js file ( fast.js ) steps:
- Create a empty folder with a name and run npm init -y
- Create a empty file (fast.js)
- Add a function with a name (must be a camelCase)
- The http method and endpoint was take it from function name for example getHello is GET method and endpoint is HELLO
- Pass options to superFast like port and endpoints functions. izzi.
- Run witn node file.js ( example: node fast.js )
Example:
const superFast = require('superfastapi');
function getTest(req, res) {
res.status(200).json({ message: 'ok' });
}
function getHelloWorld(req, res) {
res.status(200).json({ message: 'ok' });
}
function postTest(req, res) {
console.log(req.body)
res.status(200).json({ message: 'ok' });
}
superFast(
{
port: 3000,
endpoints: [getTest, getHelloWorld, postTest]
}
);