refactoe
This commit is contained in:
parent
4907dc91f7
commit
44a01c4b5a
|
@ -1,5 +1,5 @@
|
||||||
declare module 'http-signature' {
|
declare module 'http-signature' {
|
||||||
import { IncomingMessage, ClientRequest } from 'http';
|
import { IncomingMessage, ClientRequest } from 'node:http';
|
||||||
|
|
||||||
interface ISignature {
|
interface ISignature {
|
||||||
keyId: string;
|
keyId: string;
|
||||||
|
|
|
@ -1,10 +1,10 @@
|
||||||
import * as http from 'http';
|
import * as http from 'node:http';
|
||||||
import * as https from 'https';
|
import * as https from 'node:https';
|
||||||
|
import { URL } from 'node:url';
|
||||||
import CacheableLookup from 'cacheable-lookup';
|
import CacheableLookup from 'cacheable-lookup';
|
||||||
import fetch from 'node-fetch';
|
import fetch from 'node-fetch';
|
||||||
import { HttpProxyAgent, HttpsProxyAgent } from 'hpagent';
|
import { HttpProxyAgent, HttpsProxyAgent } from 'hpagent';
|
||||||
import config from '@/config/index.js';
|
import config from '@/config/index.js';
|
||||||
import { URL } from 'node:url';
|
|
||||||
|
|
||||||
export async function getJson(url: string, accept = 'application/json, */*', timeout = 10000, headers?: Record<string, string>) {
|
export async function getJson(url: string, accept = 'application/json, */*', timeout = 10000, headers?: Record<string, string>) {
|
||||||
const res = await getResponse({
|
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<string, string>, timeout?: number, size?: number }) {
|
export async function getResponse(args: { url: string, method: string, body?: string, headers: Record<string, string>, timeout?: number, size?: number }) {
|
||||||
const timeout = args?.timeout || 10 * 1000;
|
const timeout = args.timeout || 10 * 1000;
|
||||||
|
|
||||||
const controller = new AbortController();
|
const controller = new AbortController();
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
|
@ -47,7 +47,7 @@ export async function getResponse(args: { url: string, method: string, body?: st
|
||||||
headers: args.headers,
|
headers: args.headers,
|
||||||
body: args.body,
|
body: args.body,
|
||||||
timeout,
|
timeout,
|
||||||
size: args?.size || 10 * 1024 * 1024,
|
size: args.size || 10 * 1024 * 1024,
|
||||||
agent: getAgentByUrl,
|
agent: getAgentByUrl,
|
||||||
signal: controller.signal,
|
signal: controller.signal,
|
||||||
});
|
});
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
import * as http from 'http';
|
import * as http from 'node:http';
|
||||||
import * as websocket from 'websocket';
|
import * as websocket from 'websocket';
|
||||||
|
|
||||||
import MainStreamConnection from './stream/index.js';
|
import MainStreamConnection from './stream/index.js';
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import * as fs from 'node:fs';
|
import * as fs from 'node:fs';
|
||||||
import * as http from 'http';
|
import * as http from 'node:http';
|
||||||
import Koa from 'koa';
|
import Koa from 'koa';
|
||||||
import Router from '@koa/router';
|
import Router from '@koa/router';
|
||||||
import mount from 'koa-mount';
|
import mount from 'koa-mount';
|
||||||
|
|
|
@ -4,7 +4,7 @@ import * as misskey from 'misskey-js';
|
||||||
import fetch from 'node-fetch';
|
import fetch from 'node-fetch';
|
||||||
import FormData from 'form-data';
|
import FormData from 'form-data';
|
||||||
import * as childProcess from 'child_process';
|
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 loadConfig from '../src/config/load.js';
|
||||||
import { SIGKILL } from 'constants';
|
import { SIGKILL } from 'constants';
|
||||||
import { entities } from '../src/db/postgre.js';
|
import { entities } from '../src/db/postgre.js';
|
||||||
|
|
Loading…
Reference in New Issue