3 * Copyright 2016 RIFT.IO Inc
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
9 * http://www.apache.org/licenses/LICENSE-2.0
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.
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>
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');
32 Router
.use(bodyParser
.json());
34 Router
.use(bodyParser
.urlencoded({
38 Router
.get('/project', cors(), function(req
, res
) {
39 ProjectManagementAPI
.get(req
).then(function(response
) {
40 utils
.sendSuccessResponse(response
, res
);
42 utils
.sendErrorResponse(error
, res
);
45 Router
.post('/project', cors(), function(req
, res
) {
46 ProjectManagementAPI
.create(req
).then(function(response
) {
47 utils
.sendSuccessResponse(response
, res
);
49 utils
.sendErrorResponse(error
, res
);
52 Router
.put('/project', cors(), function(req
, res
) {
53 ProjectManagementAPI
.update(req
).then(function(response
) {
54 utils
.sendSuccessResponse(response
, res
);
56 utils
.sendErrorResponse(error
, res
);
59 Router
.delete('/project/:projectname', cors(), function(req
, res
) {
60 ProjectManagementAPI
.delete(req
).then(function(response
) {
61 utils
.sendSuccessResponse(response
, res
);
63 utils
.sendErrorResponse(error
, res
);
67 Router
.put('/platform', cors(), function(req
, res
) {
68 ProjectManagementAPI
.updatePlatform(req
).then(function(response
) {
69 utils
.sendSuccessResponse(response
, res
);
71 utils
.sendErrorResponse(error
, res
);
75 Router
.get('/platform', cors(), function(req
, res
) {
76 ProjectManagementAPI
.getPlatform(req
).then(function(response
) {
77 utils
.sendSuccessResponse(response
, res
);
79 utils
.sendErrorResponse(error
, res
);
82 module
.exports
= Router
;