From 950e6556d92c55656b0e272e353438c354d39075 Mon Sep 17 00:00:00 2001 From: Martin McKeaveney Date: Sun, 1 Nov 2020 15:32:54 +0000 Subject: [PATCH] started creating APIs for screens --- packages/server/src/api/controllers/screen.js | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/packages/server/src/api/controllers/screen.js b/packages/server/src/api/controllers/screen.js index 91c3c83dd5..e8e7238257 100644 --- a/packages/server/src/api/controllers/screen.js +++ b/packages/server/src/api/controllers/screen.js @@ -3,11 +3,30 @@ * currently managed as part of the pages API, please look in api/routes/page.js * for routes and controllers. */ +const CouchDB = require("../../db") exports.fetch = async ctx => { ctx.throw(501) } +exports.create = async ctx => { + const db = new CouchDB(ctx.user.appId) + const screen = { + // name: ctx.request.body.name, + // _rev: ctx.request.body._rev, + // permissions: ctx.request.body.permissions || [], + // _id: generateAccessLevelID(), + // type: "accesslevel", + } + + const response = await db.put(screen) + ctx.body = { + ...screen, + ...response, + } + ctx.message = `Screen '${screen.name}' created successfully.` +} + exports.save = async ctx => { ctx.throw(501) }