This repository was archived by the owner on Oct 2, 2023. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathapp.ts
71 lines (61 loc) · 1.86 KB
/
app.ts
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
69
70
71
import {config} from 'dotenv';
import App from 'koa';
import morgan from 'koa-morgan';
import passport from 'koa-passport';
import cors from '@koa/cors';
import {koaBody, HttpMethodEnum} from 'koa-body';
import {errorHandler, corsOptions} from '@runcitadel/utils';
import address from './routes/v1/lnd/address.js';
import channel from './routes/v1/lnd/channel.js';
import info from './routes/v1/lnd/info.js';
import lightning from './routes/v1/lnd/lightning.js';
import transaction from './routes/v1/lnd/transaction.js';
import lndconnect from './routes/v1/lnd/lndconnect.js';
import util from './routes/v1/lnd/util.js';
import wallet from './routes/v1/lnd/wallet.js';
import pages from './routes/v1/pages.js';
import ping from './routes/ping.js';
config();
const app = new App();
app.use(errorHandler);
// Handles CORS
app.use(cors(corsOptions));
app.use(
koaBody({
parsedMethods: [
HttpMethodEnum.POST,
HttpMethodEnum.PUT,
HttpMethodEnum.DELETE,
],
}),
);
app.use(passport.initialize());
app.use(passport.session());
app.use(morgan('combined'));
app.use(async (ctx, next) => {
await next();
ctx.set('Cache-Control', 'no-store, no-cache, must-revalidate');
ctx.set('Pragma', 'no-cache');
ctx.set('Expires', '0');
});
app.use(ping.routes());
app.use(ping.allowedMethods());
app.use(address.routes());
app.use(address.allowedMethods());
app.use(channel.routes());
app.use(channel.allowedMethods());
app.use(info.routes());
app.use(info.allowedMethods());
app.use(lightning.routes());
app.use(lightning.allowedMethods());
app.use(lndconnect.routes());
app.use(lndconnect.allowedMethods());
app.use(transaction.routes());
app.use(transaction.allowedMethods());
app.use(wallet.routes());
app.use(wallet.allowedMethods());
app.use(util.routes());
app.use(util.allowedMethods());
app.use(pages.routes());
app.use(pages.allowedMethods());
export default app;