refactor: Use ESM (#8358)
* wip * wip * fix * clean up * Update tsconfig.json * Update activitypub.ts * wip
This commit is contained in:
@@ -2,28 +2,32 @@
|
||||
* Core Server
|
||||
*/
|
||||
|
||||
import * as fs from 'fs';
|
||||
import * as fs from 'node:fs';
|
||||
import * as http from 'http';
|
||||
import * as http2 from 'http2';
|
||||
import * as https from 'https';
|
||||
import * as Koa from 'koa';
|
||||
import * as Router from '@koa/router';
|
||||
import * as mount from 'koa-mount';
|
||||
import * as koaLogger from 'koa-logger';
|
||||
import Koa from 'koa';
|
||||
import Router from '@koa/router';
|
||||
import mount from 'koa-mount';
|
||||
import koaLogger from 'koa-logger';
|
||||
import * as slow from 'koa-slow';
|
||||
|
||||
import activityPub from './activitypub';
|
||||
import nodeinfo from './nodeinfo';
|
||||
import wellKnown from './well-known';
|
||||
import config from '@/config/index';
|
||||
import apiServer from './api/index';
|
||||
import Logger from '@/services/logger';
|
||||
import { envOption } from '../env';
|
||||
import { UserProfiles, Users } from '@/models/index';
|
||||
import { genIdenticon } from '@/misc/gen-identicon';
|
||||
import { createTemp } from '@/misc/create-temp';
|
||||
import { publishMainStream } from '@/services/stream';
|
||||
import * as Acct from 'misskey-js/built/acct';
|
||||
import activityPub from './activitypub.js';
|
||||
import nodeinfo from './nodeinfo.js';
|
||||
import wellKnown from './well-known.js';
|
||||
import config from '@/config/index.js';
|
||||
import apiServer from './api/index.js';
|
||||
import fileServer from './file/index.js';
|
||||
import proxyServer from './proxy/index.js';
|
||||
import webServer from './web/index.js';
|
||||
import Logger from '@/services/logger.js';
|
||||
import { envOption } from '../env.js';
|
||||
import { UserProfiles, Users } from '@/models/index.js';
|
||||
import { genIdenticon } from '@/misc/gen-identicon.js';
|
||||
import { createTemp } from '@/misc/create-temp.js';
|
||||
import { publishMainStream } from '@/services/stream.js';
|
||||
import * as Acct from '@/misc/acct.js';
|
||||
import { initializeStreamingServer } from './api/streaming.js';
|
||||
|
||||
export const serverLogger = new Logger('server', 'gray', false);
|
||||
|
||||
@@ -55,8 +59,8 @@ if (config.url.startsWith('https') && !config.disableHsts) {
|
||||
}
|
||||
|
||||
app.use(mount('/api', apiServer));
|
||||
app.use(mount('/files', require('./file')));
|
||||
app.use(mount('/proxy', require('./proxy')));
|
||||
app.use(mount('/files', fileServer));
|
||||
app.use(mount('/proxy', proxyServer));
|
||||
|
||||
// Init router
|
||||
const router = new Router();
|
||||
@@ -114,7 +118,7 @@ router.get('/verify-email/:code', async ctx => {
|
||||
// Register router
|
||||
app.use(router.routes());
|
||||
|
||||
app.use(mount(require('./web')));
|
||||
app.use(mount(webServer));
|
||||
|
||||
function createServer() {
|
||||
if (config.https) {
|
||||
@@ -133,10 +137,8 @@ function createServer() {
|
||||
export const startServer = () => {
|
||||
const server = createServer();
|
||||
|
||||
// Init stream server
|
||||
require('./api/streaming')(server);
|
||||
initializeStreamingServer(server);
|
||||
|
||||
// Listen
|
||||
server.listen(config.port);
|
||||
|
||||
return server;
|
||||
@@ -145,9 +147,7 @@ export const startServer = () => {
|
||||
export default () => new Promise(resolve => {
|
||||
const server = createServer();
|
||||
|
||||
// Init stream server
|
||||
require('./api/streaming')(server);
|
||||
initializeStreamingServer(server);
|
||||
|
||||
// Listen
|
||||
server.listen(config.port, resolve);
|
||||
});
|
||||
|
Reference in New Issue
Block a user