rpj
v1.0.0
Published
Use JSON to complete a front-end/back-end interaction method
Downloads
1
Maintainers
Readme
prij
Usage
const { Rpj } = require('rpj');
const rpj = new Rpj({
interfaces: controllers
})
Example for Koa
//Get interface collection
const ctl = require("./controller")
const { Rpj, playground } = require("rpj")
const rpj = new rpj({
interfaces: ctl,
})
//Open test page
router.get("/rpj", (ctx) => {
ctx.body = playground()
})
//Request processing
router.post("/rpj", async (ctx) => {
const request = ctx.request.body
const res = await rpj.handler(request)
ctx.body = res
})