basic user creation
This commit is contained in:
parent
2d75127706
commit
00443d9dd6
|
@ -3,11 +3,11 @@ const couchdb = require("../../db");
|
|||
const controller = {
|
||||
fetch: async ctx => {
|
||||
const database = couchdb.db.use(ctx.params.databaseId);
|
||||
ctx.body = await database.list({ type: "user" });
|
||||
ctx.body = await database.list({ include_docs: true });
|
||||
},
|
||||
create: async ctx => {
|
||||
const database = couchdb.db.use(ctx.params.databaseId);
|
||||
ctx.body = await database.create(ctx.request.body.user);
|
||||
ctx.body = await database.insert(ctx.request.body);
|
||||
},
|
||||
destroy: async ctx => {
|
||||
const database = couchdb.db.use(ctx.params.databaseId);
|
||||
|
|
|
@ -17,6 +17,7 @@ const {
|
|||
|
||||
const recordRoutes = require("./routes/neo/record");
|
||||
const databaseRoutes = require("./routes/neo/database");
|
||||
const neoUserRoutes = require("./routes/neo/user");
|
||||
|
||||
const builderPath = resolve(__dirname, "../builder")
|
||||
|
||||
|
@ -116,6 +117,9 @@ module.exports = (config, app) => {
|
|||
}
|
||||
})
|
||||
|
||||
// Neo
|
||||
router.use(neoUserRoutes.routes());
|
||||
router.use(neoUserRoutes.allowedMethods());
|
||||
|
||||
router.use(recordRoutes.routes());
|
||||
router.use(recordRoutes.allowedMethods());
|
||||
|
@ -123,6 +127,10 @@ module.exports = (config, app) => {
|
|||
router.use(databaseRoutes.routes());
|
||||
router.use(databaseRoutes.allowedMethods());
|
||||
|
||||
router.use(databaseRoutes.routes());
|
||||
router.use(databaseRoutes.allowedMethods());
|
||||
// end of Neo
|
||||
|
||||
router.use(userRoutes.routes());
|
||||
router.use(userRoutes.allowedMethods());
|
||||
router.use(appsRoutes.routes())
|
||||
|
|
|
@ -1,15 +1,9 @@
|
|||
const Router = require("@koa/router");
|
||||
const controller = require("../../controllers/user");
|
||||
const couchdb = require("../../db");
|
||||
|
||||
const router = Router();
|
||||
|
||||
function setDatabase(ctx) {
|
||||
ctx.database = couchdb.db.use(ctx.params.databaseId);
|
||||
}
|
||||
|
||||
router
|
||||
.use(setDatabase)
|
||||
.get("/api/:databaseId/users", controller.fetch)
|
||||
.post("/api/:databaseId/users", controller.create)
|
||||
.delete("/api/:databaseId/users/:userId", controller.destroy);
|
||||
|
|
Loading…
Reference in New Issue