refactor: rename GetOperationReturn to GetOperationResult and use it in all situations when it is used

This commit is contained in:
b1ek 2024-07-29 11:46:52 +10:00
parent cd1f4e9525
commit 30c538b530
Signed by: blek
GPG Key ID: 14546221E3595D0C
5 changed files with 10 additions and 9 deletions

View File

@ -4,7 +4,7 @@ import { Address4, Address6 } from 'ip-address'
export type AdditionalData = { ip: Address4 | Address6 }
export type HKPOperation = keyof AbstractKeysProvider
export type GetOperationReturn = string | 404
export type GetOperationResult = string | 404
export const VALID_OPS: readonly HKPOperation[] = Object.freeze([
'get',
@ -29,7 +29,7 @@ export abstract class AbstractKeysProvider {
async get(
search: string,
data: AdditionalData
): Promise<GetOperationReturn> {
): Promise<GetOperationResult> {
return 404
}

View File

@ -1,6 +1,7 @@
import { Get, Injectable } from '@nestjs/common'
import {
AbstractKeysProvider,
GetOperationResult,
type AdditionalData,
} from './abstract.provider.js'
import { Indexes, InfoLine } from '../indexes.js'
@ -24,7 +25,7 @@ export class AllKeysProvider implements AbstractKeysProvider {
}
@Get()
async get(search: string, data: AdditionalData): Promise<string | 404> {
async get(search: string, data: AdditionalData): Promise<GetOperationResult> {
const all = this.getAll()
const promises = await Promise.all(all.map((x) => x.get(search, data)))

View File

@ -1,7 +1,7 @@
import { Get, Injectable } from '@nestjs/common'
import { AbstractKeysProvider } from './abstract.provider.js'
import type { AdditionalData } from './abstract.provider.js'
import type { AdditionalData, GetOperationResult } from './abstract.provider.js'
import { proxyGetOp, proxyIndexOp } from './utils.js'
import { Indexes } from '../indexes.js'
@ -10,7 +10,7 @@ export class OpenPGPKeysProvider implements AbstractKeysProvider {
readonly url = Object.freeze('https://keys.openpgp.org')
@Get()
async get(search: string, data: AdditionalData): Promise<string | 404> {
async get(search: string, data: AdditionalData): Promise<GetOperationResult> {
return proxyGetOp(this.url + '/pks/lookup', search, data)
}

View File

@ -1,7 +1,7 @@
import { Get, Injectable } from '@nestjs/common'
import { AbstractKeysProvider } from './abstract.provider.js'
import type { AdditionalData } from './abstract.provider.js'
import type { AdditionalData, GetOperationResult } from './abstract.provider.js'
import { proxyGetOp, proxyIndexOp } from './utils.js'
import { Indexes } from '../indexes.js'
@ -10,7 +10,7 @@ export class UbuntuKeysProvider implements AbstractKeysProvider {
readonly url = Object.freeze('https://keyserver.ubuntu.com')
@Get()
async get(search: string, data: AdditionalData): Promise<string | 404> {
async get(search: string, data: AdditionalData): Promise<GetOperationResult> {
return proxyGetOp(this.url + '/pks/lookup', search, data)
}

View File

@ -2,7 +2,7 @@ import type { KyResponse, ResponsePromise } from 'ky'
import ky from 'ky'
import type {
AdditionalData,
GetOperationReturn,
GetOperationResult,
HKPOperation,
} from './abstract.provider.js'
import type { Indexes } from '../indexes.js'
@ -42,7 +42,7 @@ export async function proxyGetOp(
url: string,
search: string,
data: AdditionalData
): Promise<GetOperationReturn> {
): Promise<GetOperationResult> {
let httpRes: KyResponse
try {
httpRes = await proxyRequest(url, 'get', search, data)