forked from PretendoNetwork/account
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.ts
27 lines (20 loc) · 807 Bytes
/
index.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
import express from 'express';
import { config, disabledFeatures } from '@/config-manager';
import { LOG_INFO, formatHostnames } from '@/logger';
import get from '@/services/local-cdn/routes/get';
import { restrictHostnames } from '@/middleware/host-limit';
const router = express.Router();
if (disabledFeatures.s3) {
// * s3 disabled, setup local CDN
// * Router to handle the subdomain
const localcdn = express.Router();
// * Setup routes
LOG_INFO('[LOCAL-CDN] Applying imported routes');
localcdn.use(get);
// * Create domains
LOG_INFO(`[LOCAL-CDN] Creating cdn router with domains: ${formatHostnames(config.domains.local_cdn)}`);
router.use(restrictHostnames(config.domains.local_cdn, localcdn));
} else {
LOG_INFO('[LOCAL-CDN] s3 enabled, skipping local CDN');
}
export default router;