mfastrest
v1.1.2
Published
A package that makes it easy, fast and fun to create REST endpoints in ExpressJS
Readme
mfastrest
A package that makes it easy, fast and fun to create REST endpoints in ExpressJS
Installation
Using npm:
$ npm install --save msfastrestUsage
Create a new NPM ExpressJS application, if you don't have one already.
$ npm init .
$ npm install --save express mfastrestCreate your app.js
Create the app.js using expres and mfastrest
const express = require('express');
const bodyParser = require('body-parser');
const { setupFastRest, getRegisteredRoutes, getRegisteredRoutesAsDotNetHashTable } = require('mfastrest');
const app = express();
app.use(bodyParser.json());
setupFastRest(app, __dirname + "/testFns", "v1");
console.log(getRegisteredRoutes());
const port = process.env.PORT || 3001;
app.listen(port, function() {
console.log('\n\n:) Server is listening on port: ' + port + '\n');
});Now, make your functions
$ mkdir testFnsMake a javscript file like testFns/hello.js
module.exports.hello = {
name: 'Hello World',
route: 'hello',
verb: 'get',
fn: async (body, params, req) => {
return {response: "hello"};
}
};
module.exports.world = {
name: 'Hello World',
route: 'hello-world',
verb: 'get',
// also supports scopes: for an express-oauth2-jwt-bearer
fn: async (body, params, req) => {
return {response: "hello world"};
}
};