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
737 changed files with 4135 additions and 3678 deletions

View File

@@ -1,7 +1,7 @@
import { Feed } from 'feed';
import config from '@/config/index';
import { User } from '@/models/entities/user';
import { Notes, DriveFiles, UserProfiles } from '@/models/index';
import config from '@/config/index.js';
import { User } from '@/models/entities/user.js';
import { Notes, DriveFiles, UserProfiles } from '@/models/index.js';
import { In } from 'typeorm';
export default async function(user: User) {

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;

View File

@@ -1,8 +1,8 @@
import * as Koa from 'koa';
import Koa from 'koa';
import * as manifest from './manifest.json';
import { fetchMeta } from '@/misc/fetch-meta';
import { fetchMeta } from '@/misc/fetch-meta.js';
module.exports = async (ctx: Koa.Context) => {
export const manifestHandler = async (ctx: Koa.Context) => {
const json = JSON.parse(JSON.stringify(manifest));
const instance = await fetchMeta(true);

View File

@@ -1,14 +1,14 @@
import * as Koa from 'koa';
import Koa from 'koa';
import summaly from 'summaly';
import { fetchMeta } from '@/misc/fetch-meta';
import Logger from '@/services/logger';
import config from '@/config/index';
import { query } from '@/prelude/url';
import { getJson } from '@/misc/fetch';
import { fetchMeta } from '@/misc/fetch-meta.js';
import Logger from '@/services/logger.js';
import config from '@/config/index.js';
import { query } from '@/prelude/url.js';
import { getJson } from '@/misc/fetch.js';
const logger = new Logger('url-preview');
module.exports = async (ctx: Koa.Context) => {
export const urlPreviewHandler = async (ctx: Koa.Context) => {
const url = ctx.query.url;
if (typeof url !== 'string') {
ctx.status = 400;