✌️
This commit is contained in:
@@ -33,7 +33,7 @@ export default class extends Endpoint<typeof meta, typeof paramDef> {
|
||||
private httpRequestService: HttpRequestService,
|
||||
) {
|
||||
super(meta, paramDef, async (ps, me) => {
|
||||
const res = await this.httpRequestService.getResponse({
|
||||
const res = await this.httpRequestService.fetch({
|
||||
url: ps.url,
|
||||
method: 'GET',
|
||||
headers: Object.assign({
|
||||
|
@@ -84,17 +84,17 @@ export default class extends Endpoint<typeof meta, typeof paramDef> {
|
||||
|
||||
const endpoint = instance.deeplIsPro ? 'https://api.deepl.com/v2/translate' : 'https://api-free.deepl.com/v2/translate';
|
||||
|
||||
const res = await fetch(endpoint, {
|
||||
const res = await this.httpRequestService.fetch({
|
||||
url: endpoint,
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/x-www-form-urlencoded',
|
||||
'User-Agent': config.userAgent,
|
||||
Accept: 'application/json, */*',
|
||||
},
|
||||
body: params,
|
||||
body: params.toString(),
|
||||
// TODO
|
||||
//timeout: 10000,
|
||||
agent: (url) => this.httpRequestService.getAgentByUrl(url),
|
||||
});
|
||||
|
||||
const json = (await res.json()) as {
|
||||
|
@@ -1,5 +1,5 @@
|
||||
import { Inject, Injectable } from '@nestjs/common';
|
||||
import summaly from 'summaly';
|
||||
import * as summaly from 'summaly';
|
||||
import { DI } from '@/di-symbols.js';
|
||||
import type { UsersRepository } from '@/models/index.js';
|
||||
import type { Config } from '@/config.js';
|
||||
@@ -65,7 +65,7 @@ export class UrlPreviewService {
|
||||
: `Getting preview of ${url}@${lang} ...`);
|
||||
|
||||
try {
|
||||
const summary = meta.summalyProxy ? await this.httpRequestService.getJson(`${meta.summalyProxy}?${query({
|
||||
const summary = meta.summalyProxy ? await this.httpRequestService.getJson<ReturnType<typeof summaly.default>>(`${meta.summalyProxy}?${query({
|
||||
url: url,
|
||||
lang: lang ?? 'ja-JP',
|
||||
})}`) : await summaly.default(url, {
|
||||
|
Reference in New Issue
Block a user