-
Notifications
You must be signed in to change notification settings - Fork 17
/
api.js
53 lines (40 loc) · 1.22 KB
/
api.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
50
51
52
53
/*
* API registry for all HTTP API actions such as
* GET, PUT, DELETE
*/
// 3rd party modules
var fs = require('fs')
var express = require('express')
var bodyparser = require('body-parser')
// Custom modules
var certapi = require('./api/certificate.js')
var caapi = require('./api/ca.js')
var authapi = require('./api/auth.js')
var apipath = '/api/v1';
/**
* Initializes API paths.
*/
var initAPI = function(app) {
app.post(apipath + '/certificate/request/', function(req, res) {
certapi.certificate.request(req, res);
});
app.post(apipath + '/certificate/revoke/', function(req, res) {
certapi.certificate.revoke(req, res);
});
app.post(apipath + '/ca/cert/get/', function(req, res) {
caapi.cert.get(req, res);
});
app.post(apipath + '/certificates/list/', function(req, res) {
certapi.certificates.list(req, res);
});
app.post(apipath + '/certificate/get/', function(req, res) {
certapi.certificate.get(req, res);
});
app.post(apipath + '/auth/check/', function(req, res) {
authapi.auth.check(req, res);
});
};
// Export initAPI() function (called by server.js)
module.exports = {
initAPI: initAPI
}