From e5b175a86e9b1f013a6270ad15d2f68ea0dfe61a Mon Sep 17 00:00:00 2001 From: Jori Lallo Date: Thu, 21 Jul 2016 22:06:30 -0700 Subject: [PATCH] Added atlases.create API --- server/api/collections.js | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/server/api/collections.js b/server/api/collections.js index 12ffe71ae..fc13da0b4 100644 --- a/server/api/collections.js +++ b/server/api/collections.js @@ -9,6 +9,28 @@ import { Team, Atlas } from '../models'; const router = new Router(); +router.post('atlases.create', auth(), async (ctx) => { + let { + name, + description, + type, + } = ctx.request.body; + ctx.assertPresent(name, 'name is required'); + + const user = ctx.state.user; + + const atlas = await Atlas.create({ + name, + description, + type: type || 'atlas', + teamId: user.teamId, + }); + + ctx.body = { + data: await presentAtlas(atlas, true), + }; +}); + router.post('atlases.info', auth(), async (ctx) => { let { id } = ctx.request.body; ctx.assertPresent(id, 'id is required');