Skip to content

Commit 495b6be

Browse files
committed
docs update
1 parent 8261bd7 commit 495b6be

File tree

1 file changed

+41
-42
lines changed

1 file changed

+41
-42
lines changed

darrt/resources.js

Lines changed: 41 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,16 @@
22
* @namespace resources
33
* @author Mike Amundsen (@mamund)
44
* @created 2020-02-01
5-
* @description
6-
* darrt resources
5+
* @description darrt resources.
76
*/
87

98
/*******************************************
109
// initialization and setup for DARRT
1110
********************************************/
1211
var express, router, bodyParser, actions, representation,
13-
transitions, utils, templates, forms, metadata;
12+
transitions, utils, templates, forms, metadata
1413

15-
init();
14+
init()
1615

1716
// shared metadata for this service
1817
metadata = [
@@ -21,9 +20,9 @@ metadata = [
2120
{name: "release", value: "1.0.0" },
2221
{name: "generated", value: "{date}" },
2322
{name: "url", value: "{fullhost}" }
24-
];
23+
]
2524

26-
router.use(timeLog);
25+
router.use(timeLog)
2726

2827
/**
2928
* @memberof resources
@@ -35,23 +34,23 @@ router.use(timeLog);
3534
* optional tracking middleware
3635
*/
3736
function timeLog (req, res, next) {
38-
console.log('Time: ', Date.now() + " : " + req.headers.host + req.url + " : " + req.method + " : " + JSON.stringify(req.body));
39-
next();
37+
console.log('Time: ', Date.now() + " : " + req.headers.host + req.url + " : " + req.method + " : " + JSON.stringify(req.body))
38+
next()
4039
}
4140

4241
/************************************************************************/
4342

4443
// ***********************************************************
4544
// public resources for the api service
4645
// ***********************************************************
47-
router.get('/', routerCallback(actions.home, 'home', 'home'));
48-
router.post('/', routerCallback(actions.create, 'api', 'list'));
49-
router.get('/list/', routerCallback(actions.list, 'api', 'list'));
50-
router.get('/filter/', routerCallback(actions.filter, 'api', 'list'));
51-
router.get('/:id', routerCallback(actions.read, 'api', 'item'));
52-
router.put('/:id', routerCallback(actions.update, 'api', 'item'));
53-
router.delete('/:id', routerCallback(actions.remove, 'api', 'list'));
54-
router.patch('/status/:id', routerCallback(actions.status, 'api', 'item'));
46+
router.get('/', routerCallback(actions.home, 'home', 'home'))
47+
router.post('/', routerCallback(actions.create, 'api', 'list'))
48+
router.get('/list/', routerCallback(actions.list, 'api', 'list'))
49+
router.get('/filter/', routerCallback(actions.filter, 'api', 'list'))
50+
router.get('/:id', routerCallback(actions.read, 'api', 'item'))
51+
router.put('/:id', routerCallback(actions.update, 'api', 'item'))
52+
router.delete('/:id', routerCallback(actions.remove, 'api', 'list'))
53+
router.patch('/status/:id', routerCallback(actions.status, 'api', 'item'))
5554

5655
/**
5756
* @function routerCallback
@@ -66,19 +65,19 @@ function routerCallback (act, type, filter) {
6665
* @param {object} res - Express Response object.
6766
*/
6867
return function (req, res) {
69-
var args = {};
70-
args.request = req;
71-
args.response = res;
72-
args.action = act;
73-
args.type = type;
68+
var args = {}
69+
args.request = req
70+
args.response = res
71+
args.action = act
72+
args.type = type
7473
args.config = {
7574
metadata: metadata,
7675
templates: templates,
7776
forms: forms,
7877
filter: filter
79-
};
80-
respond(args);
81-
};
78+
}
79+
respond(args)
80+
}
8281
}
8382

8483
/***********************************************************************/
@@ -90,22 +89,22 @@ function routerCallback (act, type, filter) {
9089
* initialize module
9190
*/
9291
function init () {
93-
express = require('express');
94-
router = express.Router();
95-
bodyParser = require('body-parser');
92+
express = require('express')
93+
router = express.Router()
94+
bodyParser = require('body-parser')
9695

97-
actions = require('./actions');
98-
representation = require('./representation');
99-
transitions = require('./transitions');
100-
utils = require('./lib/utils');
96+
actions = require('./actions')
97+
representation = require('./representation')
98+
transitions = require('./transitions')
99+
utils = require('./lib/utils')
101100

102101
// set up request body parsing & response templates
103-
router.use(bodyParser.json({ type: representation.getResponseTypes() }));
104-
router.use(bodyParser.urlencoded({ extended: representation.urlencoded }));
102+
router.use(bodyParser.json({ type: representation.getResponseTypes() }))
103+
router.use(bodyParser.urlencoded({ extended: representation.urlencoded }))
105104

106105
// load response templates and input forms
107-
templates = representation.getTemplates();
108-
forms = transitions.forms;
106+
templates = representation.getTemplates()
107+
forms = transitions.forms
109108
}
110109

111110
/**
@@ -116,16 +115,16 @@ function init () {
116115
* local resour5ce handler function
117116
*/
118117
function respond (args) {
119-
var request = args.request || null;
120-
var response = args.response || null;
121-
var action = args.action || null;
122-
var object = args.type || "";
123-
var config = args.config || {};
118+
var request = args.request || null
119+
var response = args.response || null
120+
var action = args.action || null
121+
var object = args.type || ""
122+
var config = args.config || {}
124123

125-
return utils.handler(request, response, action, object, config);
124+
return utils.handler(request, response, action, object, config)
126125
}
127126

128127
// publish the capability routes
129-
module.exports = router;
128+
module.exports = router
130129

131130
// EOF

0 commit comments

Comments
 (0)