forked from billwert/FrameworkBenchmarks
-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathrouting.js
More file actions
41 lines (29 loc) · 1012 Bytes
/
Copy pathrouting.js
File metadata and controls
41 lines (29 loc) · 1012 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
// Intialized database connections, one for each db config
// * Mongoose is a popular Node/MongoDB driver
// * Sequelize is a popular Node/SQL driver
const Handler = require(`./handlers/${process.env.NODE_HANDLER}`);
const h = require('./helper');
module.exports.BasicHandler = ((() => {
const self = {};
self.routes = {
'/json': h.responses.jsonSerialization,
'/plaintext': h.responses.plaintext,
'/db': Handler.SingleQuery,
'/fortunes': Handler.Fortunes,
};
self.has = (path) => self.routes[path];
self.handle = (path, req, res) => self.routes[path](req, res);
return self;
})());
module.exports.QueryHandler = ((() => {
const self = {};
self.routes = {
'/queries': Handler.MultipleQueries,
'/updates': Handler.Updates,
'/cached' : Handler.CachedQueries,
};
self.has = (path) => self.routes[path];
self.handle = (path, queries, req, res) =>
self.routes[path](queries, req, res);
return self;
})());