@jb_fmanager/react setup for koa
Installation
Include the routes and the utility package @jb_fmanager/node-utils
npm i @jb_fmanager/koa @jb_fmanager/node-utils
yarn add @jb_fmanager/koa @jb_fmanager/node-utils
Options
root
Root folder for the frontend component
prefix
Must match the namespace provided to the manager, default is "api/fm".
maxUploadSize
If you want to override the value provided to the manager. Accepts bytes, ie 5242880 (5mb).
errorHandler
To handle errors your way, optional
Example use
const Koa = require("koa");
const Router = require("koa-router");
const app = new Koa();
const koaStatic = require("koa-static");
const bodyParser = require("koa-bodyparser");
const cors = require("@koa/cors");
const router = new Router();
// passing the router as first argument
require("@jb_fmanager/koa")(router, {
root: "public",
prefix: "/api/fm",
errorHandler: undefined,
});
app.use(cors());
app.use(bodyParser());
app.use(router.routes());
app.use(koaStatic("./public"));
app.listen(4000, () => console.log("listening on port 4000"));