4 * Copyright 2016 RIFT.IO Inc
6 * Licensed under the Apache License, Version 2.0 (the "License");
7 * you may not use this file except in compliance with the License.
8 * You may obtain a copy of the License at
10 * http://www.apache.org/licenses/LICENSE-2.0
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
21 * Node configuration routes module.
22 * Provides a RESTful API to provide configuration
23 * details such as api_server.
24 * @module framework/core/modules/routes/configuration
25 * @author Kiran Kashalkar <kiran.kashalkar@riftio.com>
28 var cors
= require('cors');
29 var bodyParser
= require('body-parser');
30 var configurationAPI
= require('../api/configuration');
31 var Router
= require('express').Router();
32 var utils
= require('../../api_utils/utils');
34 Router
.use(bodyParser
.json());
36 Router
.use(bodyParser
.urlencoded({
40 Router
.put('/server-configuration', cors(), function(req
, res
) {
41 configurationAPI
.update(req
).then(function(data
) {
42 utils
.sendSuccessResponse(data
, res
);
44 utils
.sendErrorResponse(error
, res
);
48 Router
.get('/server-configuration', cors(), function(req
, res
) {
49 configurationAPI
.get(req
).then(function(data
) {
50 utils
.sendSuccessResponse(data
, res
);
52 utils
.sendErrorResponse(error
, res
);
56 module
.exports
= Router
;