refactor: introduce bindThis decorator to bind this automaticaly

This commit is contained in:
syuilo
2022-12-04 15:03:09 +09:00
parent e73581f715
commit bbb49457f9
199 changed files with 969 additions and 96 deletions

View File

@@ -14,6 +14,7 @@ type IWebFinger = {
links: ILink[];
subject: string;
};
import { bindThis } from '@/decorators.js';
@Injectable()
export class WebfingerService {
@@ -25,12 +26,14 @@ export class WebfingerService {
) {
}
@bindThis
public async webfinger(query: string): Promise<IWebFinger> {
const url = this.genUrl(query);
return await this.httpRequestService.getJson(url, 'application/jrd+json, application/json') as IWebFinger;
}
@bindThis
private genUrl(query: string): string {
if (query.match(/^https?:\/\//)) {
const u = new URL(query);