-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.js
68 lines (55 loc) · 1.86 KB
/
app.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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
require('dotenv').config({ path: __dirname + './.env' });
const express = require('express');
const cors = require('cors')
const app = express();
// Api controller
const rippleEstimateFee = require('./app/rest/estimate_fee');
const rippleTransaction = require('./app/rest/transaction');
const ripplePublish = require('./app/rest/publish');
const rippleGenerateAddress = require('./app/rest/generate_address');
const bunyan = require('bunyan');
const log = bunyan.createLogger({ name: "app" });
delete log.fields.hostname;
// Configure swagger
swaggerJsdoc = require("swagger-jsdoc"),
swaggerUi = require("swagger-ui-express");
var swaggerDocument = require('./swagger.json');
const openapiSpecification = swaggerJsdoc(swaggerDocument);
const swaggerOption = {
swaggerOptions: {
defaultModelsExpandDepth: -1,
}
};
app.use(express.json());
app.use(cors());
// Route: swagger ui
app.use(
'/ripple-integration/apidocs',
swaggerUi.serve,
swaggerUi.setup(openapiSpecification, swaggerOption)
);
// Route: ripple estimate fee
app.get('/ripple-integration/estimate-ripple-fee', async (req, res) => {
await rippleEstimateFee.estimateRippleFee(app, req, res);
});
// Route: ripple transfer
app.post('/ripple-integration/transfer', async (req, res) => {
await rippleTransaction.transfer(app, req, res);
});
// Route: ripple publish transaction
app.post('/ripple-integration/publish', async (req, res) => {
await ripplePublish.publishTransaction(app, req, res);
});
// Route: ripple generate address
app.post('/ripple-integration/generate-address', async (req, res) => {
await rippleGenerateAddress.genearteAddress(app, req, res);
});
// Route: handle 404
app.use(function (req, res, next) {
console.debug(`404 ${req.method} ${req.path}`)
res.status(404).send({
status: 404,
message: 'URL not found',
});
});
module.exports = app;