diff --git a/packages/backend/package.json b/packages/backend/package.json index 7c8456298..e6a247f44 100644 --- a/packages/backend/package.json +++ b/packages/backend/package.json @@ -137,8 +137,11 @@ "@types/bcryptjs": "2.4.2", "@types/bull": "4.10.0", "@types/cbor": "6.0.0", + "@types/color-convert": "^2.0.0", + "@types/content-disposition": "^0.5.5", "@types/escape-regexp": "0.0.1", "@types/fluent-ffmpeg": "2.1.20", + "@types/ioredis": "4.28.10", "@types/jest": "29.2.4", "@types/js-yaml": "4.0.5", "@types/jsdom": "20.0.1", @@ -162,6 +165,7 @@ "@types/sharp": "0.31.0", "@types/sinonjs__fake-timers": "8.1.2", "@types/speakeasy": "2.0.7", + "@types/syslog-pro": "^1.0.0", "@types/tinycolor2": "1.4.3", "@types/tmp": "0.2.3", "@types/unzipper": "0.10.5", diff --git a/packages/backend/src/core/LoggerService.ts b/packages/backend/src/core/LoggerService.ts index 4303f3ae2..221631f12 100644 --- a/packages/backend/src/core/LoggerService.ts +++ b/packages/backend/src/core/LoggerService.ts @@ -4,6 +4,7 @@ import { DI } from '@/di-symbols.js'; import type { Config } from '@/config.js'; import Logger from '@/logger.js'; import { bindThis } from '@/decorators.js'; +import type { KEYWORD } from 'color-convert/conversions'; @Injectable() export class LoggerService { @@ -15,9 +16,9 @@ export class LoggerService { ) { if (this.config.syslog) { this.syslogClient = new SyslogPro.RFC5424({ - applacationName: 'Misskey', + applicationName: 'Misskey', timestamp: true, - encludeStructuredData: true, + includeStructuredData: true, color: true, extendedColor: true, server: { @@ -29,7 +30,7 @@ export class LoggerService { } @bindThis - public getLogger(domain: string, color?: string | undefined, store?: boolean) { + public getLogger(domain: string, color?: KEYWORD | undefined, store?: boolean) { return new Logger(domain, color, store, this.syslogClient); } } diff --git a/packages/backend/src/logger.ts b/packages/backend/src/logger.ts index 5cc0d9795..e7d705163 100644 --- a/packages/backend/src/logger.ts +++ b/packages/backend/src/logger.ts @@ -4,10 +4,11 @@ import { default as convertColor } from 'color-convert'; import { format as dateFormat } from 'date-fns'; import { bindThis } from '@/decorators.js'; import { envOption } from './env.js'; +import type { KEYWORD } from 'color-convert/conversions'; type Context = { name: string; - color?: string; + color?: KEYWORD; }; type Level = 'error' | 'success' | 'warning' | 'debug' | 'info'; @@ -18,7 +19,7 @@ export default class Logger { private store: boolean; private syslogClient: any | null = null; - constructor(context: string, color?: string, store = true, syslogClient = null) { + constructor(context: string, color?: KEYWORD, store = true, syslogClient = null) { this.context = { name: context, color: color, @@ -28,7 +29,7 @@ export default class Logger { } @bindThis - public createSubLogger(context: string, color?: string, store = true): Logger { + public createSubLogger(context: string, color?: KEYWORD, store = true): Logger { const logger = new Logger(context, color, store); logger.parentLogger = this; return logger; diff --git a/packages/backend/src/server/ActivityPubServerService.ts b/packages/backend/src/server/ActivityPubServerService.ts index d1361ed5e..f7e0d744a 100644 --- a/packages/backend/src/server/ActivityPubServerService.ts +++ b/packages/backend/src/server/ActivityPubServerService.ts @@ -1,5 +1,4 @@ import { Inject, Injectable } from '@nestjs/common'; -import { FastifyInstance, FastifyRequest, FastifyReply, FastifyPluginOptions } from 'fastify'; import fastifyAccepts from '@fastify/accepts'; import httpSignature from '@peertube/http-signature'; import { Brackets, In, IsNull, LessThan, Not } from 'typeorm'; @@ -19,6 +18,7 @@ import { QueryService } from '@/core/QueryService.js'; import { UtilityService } from '@/core/UtilityService.js'; import { UserEntityService } from '@/core/entities/UserEntityService.js'; import { bindThis } from '@/decorators.js'; +import type { FastifyInstance, FastifyRequest, FastifyReply, FastifyPluginOptions } from 'fastify'; import type { FindOptionsWhere } from 'typeorm'; const ACTIVITY_JSON = 'application/activity+json; charset=utf-8'; diff --git a/packages/backend/src/server/FileServerService.ts b/packages/backend/src/server/FileServerService.ts index 8b1a13065..134b3df32 100644 --- a/packages/backend/src/server/FileServerService.ts +++ b/packages/backend/src/server/FileServerService.ts @@ -2,7 +2,6 @@ import * as fs from 'node:fs'; import { fileURLToPath } from 'node:url'; import { dirname } from 'node:path'; import { Inject, Injectable } from '@nestjs/common'; -import { FastifyInstance, FastifyRequest, FastifyReply, FastifyPluginOptions } from 'fastify'; import fastifyStatic from '@fastify/static'; import rename from 'rename'; import type { Config } from '@/config.js'; @@ -20,6 +19,7 @@ import { contentDisposition } from '@/misc/content-disposition.js'; import { FileInfoService } from '@/core/FileInfoService.js'; import { LoggerService } from '@/core/LoggerService.js'; import { bindThis } from '@/decorators.js'; +import type { FastifyInstance, FastifyRequest, FastifyReply, FastifyPluginOptions } from 'fastify'; const _filename = fileURLToPath(import.meta.url); const _dirname = dirname(_filename); diff --git a/packages/backend/src/server/MediaProxyServerService.ts b/packages/backend/src/server/MediaProxyServerService.ts index 8ffcbe6ba..2437f9f90 100644 --- a/packages/backend/src/server/MediaProxyServerService.ts +++ b/packages/backend/src/server/MediaProxyServerService.ts @@ -2,7 +2,6 @@ import * as fs from 'node:fs'; import { fileURLToPath } from 'node:url'; import { dirname } from 'node:path'; import { Inject, Injectable } from '@nestjs/common'; -import { FastifyInstance, FastifyPluginOptions, FastifyReply, FastifyRequest } from 'fastify'; import sharp from 'sharp'; import fastifyStatic from '@fastify/static'; import { DI } from '@/di-symbols.js'; @@ -18,6 +17,7 @@ import type Logger from '@/logger.js'; import { FileInfoService } from '@/core/FileInfoService.js'; import { LoggerService } from '@/core/LoggerService.js'; import { bindThis } from '@/decorators.js'; +import type { FastifyInstance, FastifyPluginOptions, FastifyReply, FastifyRequest } from 'fastify'; const _filename = fileURLToPath(import.meta.url); const _dirname = dirname(_filename); diff --git a/packages/backend/src/server/NodeinfoServerService.ts b/packages/backend/src/server/NodeinfoServerService.ts index 0f3cc36da..86d87872b 100644 --- a/packages/backend/src/server/NodeinfoServerService.ts +++ b/packages/backend/src/server/NodeinfoServerService.ts @@ -1,5 +1,4 @@ import { Inject, Injectable } from '@nestjs/common'; -import { FastifyInstance, FastifyPluginOptions, FastifyReply, FastifyRequest } from 'fastify'; import { IsNull, MoreThan } from 'typeorm'; import { DI } from '@/di-symbols.js'; import type { NotesRepository, UsersRepository } from '@/models/index.js'; @@ -9,6 +8,7 @@ import { MAX_NOTE_TEXT_LENGTH } from '@/const.js'; import { Cache } from '@/misc/cache.js'; import { UserEntityService } from '@/core/entities/UserEntityService.js'; import { bindThis } from '@/decorators.js'; +import type { FastifyInstance, FastifyPluginOptions } from 'fastify'; const nodeinfo2_1path = '/nodeinfo/2.1'; const nodeinfo2_0path = '/nodeinfo/2.0'; diff --git a/packages/backend/src/server/WellKnownServerService.ts b/packages/backend/src/server/WellKnownServerService.ts index ea34ad5b0..bf0b2a09e 100644 --- a/packages/backend/src/server/WellKnownServerService.ts +++ b/packages/backend/src/server/WellKnownServerService.ts @@ -1,5 +1,4 @@ import { Inject, Injectable } from '@nestjs/common'; -import { FastifyInstance, FastifyPluginOptions, FastifyReply, FastifyRequest } from 'fastify'; import { IsNull, MoreThan } from 'typeorm'; import vary from 'vary'; import { DI } from '@/di-symbols.js'; @@ -11,6 +10,7 @@ import * as Acct from '@/misc/acct.js'; import { NodeinfoServerService } from './NodeinfoServerService.js'; import type { FindOptionsWhere } from 'typeorm'; import { bindThis } from '@/decorators.js'; +import type { FastifyInstance, FastifyPluginOptions } from 'fastify'; @Injectable() export class WellKnownServerService { diff --git a/packages/backend/src/server/api/ApiCallService.ts b/packages/backend/src/server/api/ApiCallService.ts index 40ad7e8c2..8cc7382c5 100644 --- a/packages/backend/src/server/api/ApiCallService.ts +++ b/packages/backend/src/server/api/ApiCallService.ts @@ -3,7 +3,6 @@ import { pipeline } from 'node:stream'; import * as fs from 'node:fs'; import { promisify } from 'node:util'; import { Inject, Injectable } from '@nestjs/common'; -import { FastifyRequest, FastifyReply } from 'fastify'; import { DI } from '@/di-symbols.js'; import { getIpHash } from '@/misc/get-ip-hash.js'; import type { CacheableLocalUser, ILocalUser, User } from '@/models/entities/User.js'; @@ -17,6 +16,7 @@ import { ApiError } from './error.js'; import { RateLimiterService } from './RateLimiterService.js'; import { ApiLoggerService } from './ApiLoggerService.js'; import { AuthenticateService, AuthenticationError } from './AuthenticateService.js'; +import type { FastifyRequest, FastifyReply } from 'fastify'; import type { OnApplicationShutdown } from '@nestjs/common'; import type { IEndpointMeta, IEndpoint } from './endpoints.js'; diff --git a/packages/backend/src/server/api/ApiServerService.ts b/packages/backend/src/server/api/ApiServerService.ts index b17456d0e..dca827c55 100644 --- a/packages/backend/src/server/api/ApiServerService.ts +++ b/packages/backend/src/server/api/ApiServerService.ts @@ -1,5 +1,4 @@ import { Inject, Injectable } from '@nestjs/common'; -import { FastifyInstance, FastifyPluginOptions } from 'fastify'; import cors from '@fastify/cors'; import multipart from '@fastify/multipart'; import { ModuleRef, repl } from '@nestjs/core'; @@ -15,6 +14,7 @@ import { GithubServerService } from './integration/GithubServerService.js'; import { DiscordServerService } from './integration/DiscordServerService.js'; import { TwitterServerService } from './integration/TwitterServerService.js'; import { bindThis } from '@/decorators.js'; +import type { FastifyInstance, FastifyPluginOptions } from 'fastify'; @Injectable() export class ApiServerService { diff --git a/packages/backend/src/server/api/SigninApiService.ts b/packages/backend/src/server/api/SigninApiService.ts index b633c2888..10f8423d4 100644 --- a/packages/backend/src/server/api/SigninApiService.ts +++ b/packages/backend/src/server/api/SigninApiService.ts @@ -3,7 +3,6 @@ import { Inject, Injectable } from '@nestjs/common'; import bcrypt from 'bcryptjs'; import * as speakeasy from 'speakeasy'; import { IsNull } from 'typeorm'; -import { FastifyInstance, FastifyRequest, FastifyReply } from 'fastify'; import { DI } from '@/di-symbols.js'; import type { UserSecurityKeysRepository, SigninsRepository, UserProfilesRepository, AttestationChallengesRepository, UsersRepository } from '@/models/index.js'; import type { Config } from '@/config.js'; @@ -14,6 +13,7 @@ import { TwoFactorAuthenticationService } from '@/core/TwoFactorAuthenticationSe import { RateLimiterService } from './RateLimiterService.js'; import { SigninService } from './SigninService.js'; import { bindThis } from '@/decorators.js'; +import type { FastifyRequest, FastifyReply } from 'fastify'; @Injectable() export class SigninApiService { diff --git a/packages/backend/src/server/api/SigninService.ts b/packages/backend/src/server/api/SigninService.ts index 671278a18..89a8a9ff1 100644 --- a/packages/backend/src/server/api/SigninService.ts +++ b/packages/backend/src/server/api/SigninService.ts @@ -1,5 +1,4 @@ import { Inject, Injectable } from '@nestjs/common'; -import { FastifyInstance, FastifyRequest, FastifyReply } from 'fastify'; import { DI } from '@/di-symbols.js'; import type { SigninsRepository, UsersRepository } from '@/models/index.js'; import type { Config } from '@/config.js'; @@ -8,6 +7,7 @@ import type { ILocalUser } from '@/models/entities/User.js'; import { GlobalEventService } from '@/core/GlobalEventService.js'; import { SigninEntityService } from '@/core/entities/SigninEntityService.js'; import { bindThis } from '@/decorators.js'; +import type { FastifyRequest, FastifyReply } from 'fastify'; @Injectable() export class SigninService { diff --git a/packages/backend/src/server/api/SignupApiService.ts b/packages/backend/src/server/api/SignupApiService.ts index 59676426a..bba81250a 100644 --- a/packages/backend/src/server/api/SignupApiService.ts +++ b/packages/backend/src/server/api/SignupApiService.ts @@ -1,7 +1,6 @@ import { Inject, Injectable } from '@nestjs/common'; import rndstr from 'rndstr'; import bcrypt from 'bcryptjs'; -import { FastifyInstance, FastifyRequest, FastifyReply } from 'fastify'; import { DI } from '@/di-symbols.js'; import type { RegistrationTicketsRepository, UserPendingsRepository, UserProfilesRepository, UsersRepository } from '@/models/index.js'; import type { Config } from '@/config.js'; @@ -15,6 +14,7 @@ import { ILocalUser } from '@/models/entities/User.js'; import { FastifyReplyError } from '@/misc/fastify-reply-error.js'; import { SigninService } from './SigninService.js'; import { bindThis } from '@/decorators.js'; +import type { FastifyRequest, FastifyReply } from 'fastify'; @Injectable() export class SignupApiService { diff --git a/packages/backend/src/server/api/integration/DiscordServerService.ts b/packages/backend/src/server/api/integration/DiscordServerService.ts index 72e67edf3..805056da8 100644 --- a/packages/backend/src/server/api/integration/DiscordServerService.ts +++ b/packages/backend/src/server/api/integration/DiscordServerService.ts @@ -3,7 +3,6 @@ import Redis from 'ioredis'; import { OAuth2 } from 'oauth'; import { v4 as uuid } from 'uuid'; import { IsNull } from 'typeorm'; -import { FastifyInstance, FastifyRequest, FastifyReply, FastifyPluginOptions } from 'fastify'; import type { Config } from '@/config.js'; import type { UserProfilesRepository, UsersRepository } from '@/models/index.js'; import { DI } from '@/di-symbols.js'; @@ -15,6 +14,7 @@ import { UserEntityService } from '@/core/entities/UserEntityService.js'; import { FastifyReplyError } from '@/misc/fastify-reply-error.js'; import { bindThis } from '@/decorators.js'; import { SigninService } from '../SigninService.js'; +import type { FastifyInstance, FastifyRequest, FastifyPluginOptions } from 'fastify'; @Injectable() export class DiscordServerService { diff --git a/packages/backend/src/server/api/integration/GithubServerService.ts b/packages/backend/src/server/api/integration/GithubServerService.ts index cea4c6b98..6f38c262a 100644 --- a/packages/backend/src/server/api/integration/GithubServerService.ts +++ b/packages/backend/src/server/api/integration/GithubServerService.ts @@ -3,7 +3,6 @@ import Redis from 'ioredis'; import { OAuth2 } from 'oauth'; import { v4 as uuid } from 'uuid'; import { IsNull } from 'typeorm'; -import { FastifyInstance, FastifyRequest, FastifyReply, FastifyPluginOptions } from 'fastify'; import type { Config } from '@/config.js'; import type { UserProfilesRepository, UsersRepository } from '@/models/index.js'; import { DI } from '@/di-symbols.js'; @@ -15,6 +14,7 @@ import { UserEntityService } from '@/core/entities/UserEntityService.js'; import { FastifyReplyError } from '@/misc/fastify-reply-error.js'; import { bindThis } from '@/decorators.js'; import { SigninService } from '../SigninService.js'; +import type { FastifyInstance, FastifyRequest, FastifyPluginOptions } from 'fastify'; @Injectable() export class GithubServerService { diff --git a/packages/backend/src/server/api/integration/TwitterServerService.ts b/packages/backend/src/server/api/integration/TwitterServerService.ts index 688fa1a5b..9cfadbfa1 100644 --- a/packages/backend/src/server/api/integration/TwitterServerService.ts +++ b/packages/backend/src/server/api/integration/TwitterServerService.ts @@ -1,6 +1,5 @@ import { Inject, Injectable } from '@nestjs/common'; import Redis from 'ioredis'; -import { FastifyInstance, FastifyRequest, FastifyReply, FastifyPluginOptions } from 'fastify'; import { v4 as uuid } from 'uuid'; import { IsNull } from 'typeorm'; import autwh from 'autwh'; @@ -15,6 +14,7 @@ import { UserEntityService } from '@/core/entities/UserEntityService.js'; import { FastifyReplyError } from '@/misc/fastify-reply-error.js'; import { bindThis } from '@/decorators.js'; import { SigninService } from '../SigninService.js'; +import type { FastifyInstance, FastifyRequest, FastifyPluginOptions } from 'fastify'; @Injectable() export class TwitterServerService { diff --git a/packages/backend/src/server/web/ClientServerService.ts b/packages/backend/src/server/web/ClientServerService.ts index ae776adf1..58452ae82 100644 --- a/packages/backend/src/server/web/ClientServerService.ts +++ b/packages/backend/src/server/web/ClientServerService.ts @@ -9,7 +9,6 @@ import ms from 'ms'; import sharp from 'sharp'; import pug from 'pug'; import { In, IsNull } from 'typeorm'; -import { FastifyInstance, FastifyPluginOptions, FastifyReply } from 'fastify'; import fastifyStatic from '@fastify/static'; import fastifyView from '@fastify/view'; import fastifyCookie from '@fastify/cookie'; @@ -31,6 +30,7 @@ import { bindThis } from '@/decorators.js'; import manifest from './manifest.json' assert { type: 'json' }; import { FeedService } from './FeedService.js'; import { UrlPreviewService } from './UrlPreviewService.js'; +import type { FastifyInstance, FastifyPluginOptions, FastifyReply } from 'fastify'; const _filename = fileURLToPath(import.meta.url); const _dirname = dirname(_filename); diff --git a/packages/backend/src/server/web/UrlPreviewService.ts b/packages/backend/src/server/web/UrlPreviewService.ts index 69bb232d4..baef8fa99 100644 --- a/packages/backend/src/server/web/UrlPreviewService.ts +++ b/packages/backend/src/server/web/UrlPreviewService.ts @@ -1,6 +1,5 @@ import { Inject, Injectable } from '@nestjs/common'; import summaly from 'summaly'; -import { FastifyRequest, FastifyReply } from 'fastify'; import { DI } from '@/di-symbols.js'; import type { UsersRepository } from '@/models/index.js'; import type { Config } from '@/config.js'; @@ -10,6 +9,7 @@ import type Logger from '@/logger.js'; import { query } from '@/misc/prelude/url.js'; import { LoggerService } from '@/core/LoggerService.js'; import { bindThis } from '@/decorators.js'; +import type { FastifyRequest, FastifyReply } from 'fastify'; @Injectable() export class UrlPreviewService { diff --git a/packages/backend/tsconfig.json b/packages/backend/tsconfig.json index 2c8adf770..544b529e9 100644 --- a/packages/backend/tsconfig.json +++ b/packages/backend/tsconfig.json @@ -10,7 +10,7 @@ "declaration": false, "sourceMap": false, "target": "es2021", - "module": "es2022", + "module": "esnext", "moduleResolution": "node", "allowSyntheticDefaultImports": true, "removeComments": false, diff --git a/yarn.lock b/yarn.lock index efd459298..2b72b2180 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2220,6 +2220,29 @@ __metadata: languageName: node linkType: hard +"@types/color-convert@npm:^2.0.0": + version: 2.0.0 + resolution: "@types/color-convert@npm:2.0.0" + dependencies: + "@types/color-name": "*" + checksum: 027b68665dc2278cc2d83e796ada0a05a08aa5a11297e227c48c7f9f6eac518dec98578ab0072bd211963d3e4b431da70b20ea28d6c3136d0badfd3f9913baee + languageName: node + linkType: hard + +"@types/color-name@npm:*": + version: 1.1.1 + resolution: "@types/color-name@npm:1.1.1" + checksum: b71fcad728cc68abcba1d405742134410c8f8eb3c2ef18113b047afca158ad23a4f2c229bcf71a38f4a818dead375c45b20db121d0e69259c2d81e97a740daa6 + languageName: node + linkType: hard + +"@types/content-disposition@npm:^0.5.5": + version: 0.5.5 + resolution: "@types/content-disposition@npm:0.5.5" + checksum: fdf7379db1d509990bcf9a21d85f05aad878596f28b1418f9179f6436cb22513262c670ce88c6055054a7f5804a9303eeacb70aa59a5e11ffdc1434559db9692 + languageName: node + linkType: hard + "@types/disposable-email-domains@npm:^1.0.1": version: 1.0.2 resolution: "@types/disposable-email-domains@npm:1.0.2" @@ -2314,6 +2337,15 @@ __metadata: languageName: node linkType: hard +"@types/ioredis@npm:4.28.10": + version: 4.28.10 + resolution: "@types/ioredis@npm:4.28.10" + dependencies: + "@types/node": "*" + checksum: 0f2788cf25f490d3b345db8c5f8b8ce3f6c92cc99abcf744c8f974f02b9b3875233b3d22098614c462a0d6c41c523bd655509418ea88eb6249db6652290ce7cf + languageName: node + linkType: hard + "@types/istanbul-lib-coverage@npm:*, @types/istanbul-lib-coverage@npm:^2.0.0, @types/istanbul-lib-coverage@npm:^2.0.1": version: 2.0.4 resolution: "@types/istanbul-lib-coverage@npm:2.0.4" @@ -2667,6 +2699,13 @@ __metadata: languageName: node linkType: hard +"@types/syslog-pro@npm:^1.0.0": + version: 1.0.0 + resolution: "@types/syslog-pro@npm:1.0.0" + checksum: d0dcd87efad8a629bba449f86a617605a3fbffa5c18a8b309c82e7b85036ac21cfd34711fd522f50528dd0f0d07bdb66261a6f9ef20f2a9133e847b2e717c1bc + languageName: node + linkType: hard + "@types/throttle-debounce@npm:5.0.0": version: 5.0.0 resolution: "@types/throttle-debounce@npm:5.0.0" @@ -4045,8 +4084,11 @@ __metadata: "@types/bcryptjs": 2.4.2 "@types/bull": 4.10.0 "@types/cbor": 6.0.0 + "@types/color-convert": ^2.0.0 + "@types/content-disposition": ^0.5.5 "@types/escape-regexp": 0.0.1 "@types/fluent-ffmpeg": 2.1.20 + "@types/ioredis": 4.28.10 "@types/jest": 29.2.4 "@types/js-yaml": 4.0.5 "@types/jsdom": 20.0.1 @@ -4070,6 +4112,7 @@ __metadata: "@types/sharp": 0.31.0 "@types/sinonjs__fake-timers": 8.1.2 "@types/speakeasy": 2.0.7 + "@types/syslog-pro": ^1.0.0 "@types/tinycolor2": 1.4.3 "@types/tmp": 0.2.3 "@types/unzipper": 0.10.5