forked from MissionSung/actionhero
/
routes.js
49 lines (40 loc) · 1.41 KB
/
routes.js
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
41
42
43
44
45
46
47
48
49
/* ---------------------
routes.js
For web clients (http and https) you can define an optional RESTful mapping to help route requests to actions.
If the client doesn't specify and action in a param, and the base route isn't a named action, the action will attempt to be discerned from this routes.js file.
- routes remain optional
- actions defiend in params directly `action=theAction` or hitting the named URL for an action `/api/theAction` will always override RESTful routing
- the hierarchy of the routes object is prefix --> REST verb -> data
- you can mix explicitly defined params with route-defined params. If there is an overlap, the explicitly defined params win
- data contains the 'action' to map to, and then an optional urlMap (api.params.mapParamsFromURL)
- only single depth routes are supported at this time
/////////////
// EXAMPLE //
/////////////
exports.routes = {
users: {
get: {
action: "usersList", // (GET) /api/users
}
},
user : {
get: {
action: "userAdd",
urlMap: ["userID"], // (GET) /api/user/123
},
post: {
action: "userEdit",
urlMap: ["userID"] // (POST) /api/user/123
},
put: {
action: "userAdd",
urlMap: ["type", "screenName"] // (PUT) /api/user/admin/handle123
},
delete: {
action: "userDelete",
urlMap: ["userID"] // (DELETE) /api/user/123
}
}
};
---------------------- */
exports.routes = {};