correct resource paths

This commit is contained in:
Martin McKeaveney 2020-04-07 20:34:21 +01:00
parent c78b14a68a
commit 678b48beec
5 changed files with 38 additions and 29 deletions

View File

@ -3,7 +3,7 @@ const couchdb = require("../../db");
const controller = { const controller = {
create: async ctx => { create: async ctx => {
const clientDatabase = couchdb.db.use(ctx.params.clientId); const clientDatabase = couchdb.db.use(ctx.params.clientId);
ctx.body = await clientDatabase.create(ctx.request.body.appname); ctx.body = await clientDatabase.insert(ctx.request.body);
} }
} }

View File

@ -0,0 +1,18 @@
const couchdb = require("../../db");
const controller = {
forgotPassword: async ctx => {
},
setPassword: async ctx => {
},
changePassword: async ctx => {
},
authenticate: async ctx => {
}
}
module.exports = controller;

View File

@ -0,0 +1,9 @@
const Router = require("@koa/router");
const controller = require("../../controllers/auth");
const router = Router();
router
.post("/api/authenticate", controller.authenticate);
module.exports = router;

View File

@ -4,30 +4,8 @@ const controller = require("../../controllers/record");
const router = Router(); const router = Router();
router router
.get("/api/records/:databaseId", controller.fetch) .get("/api/:databaseId/records", controller.fetch)
.post("/api/records/:databaseId", controller.save) .post("/api/:databaseId/records", controller.save)
.delete("/api/records/:databaseId/:recordId", controller.destroy) .delete("/api/:databaseId/records/:recordId", controller.destroy)
// router.post(
// "/_builder/instance/:appname/:instanceid/api/record/*",
// routeHandlers.saveRecord
// )
// router.get("/:appname/api/listRecords/*", () => {
// ctx.body = await ctx.instance.indexApi.listItems(indexkey)
// ctx.response.status = StatusCodes.OK
// })
// router.get(
// "/_builder/instance/:appname/:instanceid/api/listRecords/*",
// routeHandlers.listRecordsGet
// )
// router.post("/:appname/api/listRecords/*", routeHandlers.listRecordsPost)
// router.post(
// "/_builder/instance/:appname/:instanceid/api/listRecords/*",
// routeHandlers.listRecordsPost
// )
module.exports = router; module.exports = router;

View File

@ -4,6 +4,10 @@ const controller = require("../../controllers/schema");
const router = Router(); const router = Router();
router router
.get("/api/schemas/:appId", controller.fetch) .get("/api/:clientId/:appId/schemas", controller.fetch)
.post("/api/schemas/:appId", controller.save) .post("/api/:clientId/:appId/schemas", controller.save)
.delete("/api/schemas/:appId", controller.delete) .patch("/api/:clientId/:appId/schemas/apply", controller.apply)
.delete("/api/:clientId/:appId/schemas/:schemaId", controller.delete)
module.exports = router;