forked from DIYgod/RSSHub
-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.tsx
55 lines (44 loc) · 1.37 KB
/
app.tsx
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
import '@/utils/request-rewriter';
import { Hono } from 'hono';
import { compress } from 'hono/compress';
import mLogger from '@/middleware/logger';
import cache from '@/middleware/cache';
import template from '@/middleware/template';
import sentry from '@/middleware/sentry';
import accessControl from '@/middleware/access-control';
import debug from '@/middleware/debug';
import header from '@/middleware/header';
import antiHotlink from '@/middleware/anti-hotlink';
import parameter from '@/middleware/parameter';
import { jsxRenderer } from 'hono/jsx-renderer';
import { trimTrailingSlash } from 'hono/trailing-slash';
import logger from '@/utils/logger';
import { notFoundHandler, errorHandler } from '@/errors';
import registry from '@/registry';
import api from '@/api';
process.on('uncaughtException', (e) => {
logger.error('uncaughtException: ' + e);
});
const app = new Hono();
app.use(trimTrailingSlash());
app.use(compress());
app.use(
jsxRenderer(({ children }) => <>{children}</>, {
docType: '<?xml version="1.0" encoding="UTF-8"?>',
stream: {},
})
);
app.use(mLogger);
app.use(sentry);
app.use(accessControl);
app.use(debug);
app.use(template);
app.use(header);
app.use(antiHotlink);
app.use(parameter);
app.use(cache);
app.route('/', registry);
app.route('/api', api);
app.notFound(notFoundHandler);
app.onError(errorHandler);
export default app;