update from RIFT as of 696b75d2fe9fb046261b08c616f1bcf6c0b54a9b third try
[osm/UI.git] / skyquake / framework / core / modules / routes / projectManagement.js
1 /*
2 *
3 * Copyright 2016 RIFT.IO Inc
4 *
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
8 *
9 * http://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 *
17 */
18
19 /**
20 * inactivity routes module. Provides a RESTful API for this
21 * skyquake instance's inactivity state.
22 * @module framework/core/modules/routes/inactivity
23 * @author Laurence Maultsby <laurence.maultsby@riftio.com>
24 */
25
26 var cors = require('cors');
27 var bodyParser = require('body-parser');
28 var Router = require('express').Router();
29 var utils = require('../../api_utils/utils');
30 var ProjectManagementAPI = require('../api/projectManagementAPI.js');
31
32 Router.use(bodyParser.json());
33 Router.use(cors());
34 Router.use(bodyParser.urlencoded({
35 extended: true
36 }));
37
38 Router.get('/project', cors(), function(req, res) {
39 ProjectManagementAPI.get(req).then(function(response) {
40 utils.sendSuccessResponse(response, res);
41 }, function(error) {
42 utils.sendErrorResponse(error, res);
43 });
44 });
45 Router.post('/project', cors(), function(req, res) {
46 ProjectManagementAPI.create(req).then(function(response) {
47 utils.sendSuccessResponse(response, res);
48 }, function(error) {
49 utils.sendErrorResponse(error, res);
50 });
51 });
52 Router.put('/project', cors(), function(req, res) {
53 ProjectManagementAPI.update(req).then(function(response) {
54 utils.sendSuccessResponse(response, res);
55 }, function(error) {
56 utils.sendErrorResponse(error, res);
57 });
58 });
59 Router.delete('/project/:projectname', cors(), function(req, res) {
60 ProjectManagementAPI.delete(req).then(function(response) {
61 utils.sendSuccessResponse(response, res);
62 }, function(error) {
63 utils.sendErrorResponse(error, res);
64 });
65 });
66
67 Router.put('/platform', cors(), function(req, res) {
68 ProjectManagementAPI.updatePlatform(req).then(function(response) {
69 utils.sendSuccessResponse(response, res);
70 }, function(error) {
71 utils.sendErrorResponse(error, res);
72 });
73 });
74
75 Router.get('/platform', cors(), function(req, res) {
76 ProjectManagementAPI.getPlatform(req).then(function(response) {
77 utils.sendSuccessResponse(response, res);
78 }, function(error) {
79 utils.sendErrorResponse(error, res);
80 });
81 });
82 module.exports = Router;
83
84
85