refactor: introduce bindThis decorator to bind this automaticaly
This commit is contained in:
@@ -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);
|
||||
|
Reference in New Issue
Block a user