refactor: Use ESM (#8358)

* wip

* wip

* fix

* clean up

* Update tsconfig.json

* Update activitypub.ts

* wip
This commit is contained in:
syuilo 2022-02-27 11:07:39 +09:00 committed by GitHub
parent 0a882471f3
commit d071d18dd7
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
737 changed files with 4135 additions and 3678 deletions

View file

@ -2,24 +2,26 @@
* Web Client Server
*/
import { dirname } from 'path';
import { dirname } from 'node:path';
import { fileURLToPath } from 'node:url';
import ms from 'ms';
import * as Koa from 'koa';
import * as Router from '@koa/router';
import * as send from 'koa-send';
import * as favicon from 'koa-favicon';
import * as views from 'koa-views';
import Koa from 'koa';
import Router from '@koa/router';
import send from 'koa-send';
import favicon from 'koa-favicon';
import views from 'koa-views';
import packFeed from './feed';
import { fetchMeta } from '@/misc/fetch-meta';
import { genOpenapiSpec } from '../api/openapi/gen-spec';
import config from '@/config/index';
import { Users, Notes, UserProfiles, Pages, Channels, Clips, GalleryPosts } from '@/models/index';
import * as Acct from 'misskey-js/built/acct';
import { getNoteSummary } from '@/misc/get-note-summary';
import packFeed from './feed.js';
import { fetchMeta } from '@/misc/fetch-meta.js';
import { genOpenapiSpec } from '../api/openapi/gen-spec.js';
import config from '@/config/index.js';
import { Users, Notes, UserProfiles, Pages, Channels, Clips, GalleryPosts } from '@/models/index.js';
import * as Acct from '@/misc/acct.js';
import { getNoteSummary } from '@/misc/get-note-summary.js';
import { urlPreviewHandler } from './url-preview.js';
import { manifestHandler } from './manifest.js';
//const _filename = fileURLToPath(import.meta.url);
const _filename = __filename;
const _filename = fileURLToPath(import.meta.url);
const _dirname = dirname(_filename);
const staticAssets = `${_dirname}/../../../assets/`;
@ -105,7 +107,7 @@ router.get('/sw.js', async ctx => {
});
// Manifest
router.get('/manifest.json', require('./manifest'));
router.get('/manifest.json', manifestHandler);
router.get('/robots.txt', async ctx => {
await send(ctx as any, '/robots.txt', {
@ -123,7 +125,7 @@ router.get('/api-doc', async ctx => {
});
// URL preview endpoint
router.get('/url', require('./url-preview'));
router.get('/url', urlPreviewHandler);
router.get('/api.json', async ctx => {
ctx.body = genOpenapiSpec();
@ -426,4 +428,4 @@ router.get('(.*)', async ctx => {
// Register router
app.use(router.routes());
module.exports = app;
export default app;