From 45a114965581f5663d7c78f8ec5c7ea2301ddac0 Mon Sep 17 00:00:00 2001 From: syuilo Date: Sat, 16 Apr 2022 17:19:30 +0900 Subject: [PATCH] refactoe --- packages/backend/src/@types/http-signature.d.ts | 2 +- packages/backend/src/misc/fetch.ts | 10 +++++----- packages/backend/src/server/api/streaming.ts | 2 +- packages/backend/src/server/index.ts | 2 +- packages/backend/test/utils.ts | 2 +- 5 files changed, 9 insertions(+), 9 deletions(-) diff --git a/packages/backend/src/@types/http-signature.d.ts b/packages/backend/src/@types/http-signature.d.ts index 8d484312d..0426cb8bc 100644 --- a/packages/backend/src/@types/http-signature.d.ts +++ b/packages/backend/src/@types/http-signature.d.ts @@ -1,5 +1,5 @@ declare module 'http-signature' { - import { IncomingMessage, ClientRequest } from 'http'; + import { IncomingMessage, ClientRequest } from 'node:http'; interface ISignature { keyId: string; diff --git a/packages/backend/src/misc/fetch.ts b/packages/backend/src/misc/fetch.ts index 4b1013c9f..af6bf2fca 100644 --- a/packages/backend/src/misc/fetch.ts +++ b/packages/backend/src/misc/fetch.ts @@ -1,10 +1,10 @@ -import * as http from 'http'; -import * as https from 'https'; +import * as http from 'node:http'; +import * as https from 'node:https'; +import { URL } from 'node:url'; import CacheableLookup from 'cacheable-lookup'; import fetch from 'node-fetch'; import { HttpProxyAgent, HttpsProxyAgent } from 'hpagent'; import config from '@/config/index.js'; -import { URL } from 'node:url'; export async function getJson(url: string, accept = 'application/json, */*', timeout = 10000, headers?: Record) { const res = await getResponse({ @@ -35,7 +35,7 @@ export async function getHtml(url: string, accept = 'text/html, */*', timeout = } export async function getResponse(args: { url: string, method: string, body?: string, headers: Record, timeout?: number, size?: number }) { - const timeout = args?.timeout || 10 * 1000; + const timeout = args.timeout || 10 * 1000; const controller = new AbortController(); setTimeout(() => { @@ -47,7 +47,7 @@ export async function getResponse(args: { url: string, method: string, body?: st headers: args.headers, body: args.body, timeout, - size: args?.size || 10 * 1024 * 1024, + size: args.size || 10 * 1024 * 1024, agent: getAgentByUrl, signal: controller.signal, }); diff --git a/packages/backend/src/server/api/streaming.ts b/packages/backend/src/server/api/streaming.ts index 2a34edac6..f8e42d27f 100644 --- a/packages/backend/src/server/api/streaming.ts +++ b/packages/backend/src/server/api/streaming.ts @@ -1,4 +1,4 @@ -import * as http from 'http'; +import * as http from 'node:http'; import * as websocket from 'websocket'; import MainStreamConnection from './stream/index.js'; diff --git a/packages/backend/src/server/index.ts b/packages/backend/src/server/index.ts index a68cebfeb..d00bf8996 100644 --- a/packages/backend/src/server/index.ts +++ b/packages/backend/src/server/index.ts @@ -3,7 +3,7 @@ */ import * as fs from 'node:fs'; -import * as http from 'http'; +import * as http from 'node:http'; import Koa from 'koa'; import Router from '@koa/router'; import mount from 'koa-mount'; diff --git a/packages/backend/test/utils.ts b/packages/backend/test/utils.ts index 32a030f93..09e812f43 100644 --- a/packages/backend/test/utils.ts +++ b/packages/backend/test/utils.ts @@ -4,7 +4,7 @@ import * as misskey from 'misskey-js'; import fetch from 'node-fetch'; import FormData from 'form-data'; import * as childProcess from 'child_process'; -import * as http from 'http'; +import * as http from 'node:http'; import loadConfig from '../src/config/load.js'; import { SIGKILL } from 'constants'; import { entities } from '../src/db/postgre.js';