forked from FoundKeyGang/FoundKey
backend: fix lints in various misc modules
Mostly adding return types and also fixing a type error.
This commit is contained in:
parent
629b865789
commit
c0d5678039
5 changed files with 9 additions and 7 deletions
|
@ -29,7 +29,7 @@ export class Cache<T> {
|
|||
return cached.value;
|
||||
}
|
||||
|
||||
public delete(key: string | null) {
|
||||
public delete(key: string | null): void {
|
||||
this.cache.delete(key);
|
||||
}
|
||||
|
||||
|
@ -46,8 +46,9 @@ export class Cache<T> {
|
|||
const value = await this.fetcher(key);
|
||||
|
||||
// don't cache undefined
|
||||
if (value !== undefined)
|
||||
if (value !== undefined) {
|
||||
this.set(key, value);
|
||||
}
|
||||
|
||||
return value;
|
||||
}
|
||||
|
|
|
@ -3,7 +3,7 @@ import fetch from 'node-fetch';
|
|||
import config from '@/config/index.js';
|
||||
import { getAgentByUrl } from './fetch.js';
|
||||
|
||||
export async function verifyRecaptcha(secret: string, response: string) {
|
||||
export async function verifyRecaptcha(secret: string, response: string): Promise<void> {
|
||||
const result = await getCaptchaResponse('https://www.recaptcha.net/recaptcha/api/siteverify', secret, response).catch(e => {
|
||||
throw new Error(`recaptcha-request-failed: ${e.message}`);
|
||||
});
|
||||
|
@ -14,7 +14,7 @@ export async function verifyRecaptcha(secret: string, response: string) {
|
|||
}
|
||||
}
|
||||
|
||||
export async function verifyHcaptcha(secret: string, response: string) {
|
||||
export async function verifyHcaptcha(secret: string, response: string): Promise<void> {
|
||||
const result = await getCaptchaResponse('https://hcaptcha.com/siteverify', secret, response).catch(e => {
|
||||
throw new Error(`hcaptcha-request-failed: ${e.message}`);
|
||||
});
|
||||
|
|
|
@ -5,6 +5,7 @@ import { User } from '@/models/entities/user.js';
|
|||
type NoteLike = {
|
||||
userId: Note['userId'];
|
||||
text: Note['text'];
|
||||
cw: Note['cw'];
|
||||
};
|
||||
|
||||
type UserLike = {
|
||||
|
|
|
@ -11,12 +11,12 @@ export function isSelfHost(host: string | null): boolean {
|
|||
return toPuny(config.host) === toPuny(host);
|
||||
}
|
||||
|
||||
export function extractDbHost(uri: string) {
|
||||
export function extractDbHost(uri: string): string {
|
||||
const url = new URL(uri);
|
||||
return toPuny(url.hostname);
|
||||
}
|
||||
|
||||
export function toPuny(host: string) {
|
||||
export function toPuny(host: string): string {
|
||||
return toASCII(host.toLowerCase());
|
||||
}
|
||||
|
||||
|
|
|
@ -2,7 +2,7 @@ import { createTemp } from './create-temp.js';
|
|||
import { downloadUrl } from './download-url.js';
|
||||
import { detectType } from './get-file-info.js';
|
||||
|
||||
export async function detectUrlMime(url: string) {
|
||||
export async function detectUrlMime(url: string): Promise<string> {
|
||||
const [path, cleanup] = await createTemp();
|
||||
|
||||
try {
|
||||
|
|
Loading…
Reference in a new issue