forked from r-spacex/SpaceX-API
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
35 lines (32 loc) · 953 Bytes
/
index.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
/* eslint-disable no-restricted-syntax */
import Router from 'koa-router';
const FOLDERS = await Promise.all([
import('./admin/index.js'),
import('./capsules/index.js'),
import('./company/index.js'),
import('./cores/index.js'),
import('./crew/index.js'),
import('./dragons/index.js'),
import('./history/index.js'),
import('./landpads/index.js'),
import('./launches/index.js'),
import('./launchpads/index.js'),
import('./payloads/index.js'),
import('./roadster/index.js'),
import('./rockets/index.js'),
import('./ships/index.js'),
import('./starlink/index.js'),
import('./users/index.js'),
]);
const ROUTER = new Router();
// Register all routes + all versions
export default async () => {
for await (const routeFolder of FOLDERS) {
if (routeFolder?.default) {
for await (const version of routeFolder.default) {
ROUTER.use(version?.default?.routes());
}
}
}
return ROUTER.routes();
};