UNPKG

@appsemble/node-utils

Version:

NodeJS utilities used by Appsemble internally.

20 lines (19 loc) 1.03 kB
import { type Context } from 'koa'; import { AppsembleError } from './AppsembleError.js'; export declare function createResourceEtag(resource: Record<string, unknown>): string; export declare function addResourceEtag<T extends Record<string, unknown>>(resource: T): T & { $etag: string; }; export declare function matchesResourceIfMatch(ifMatch: string | string[] | undefined, currentEtag: string): boolean; export declare function setResourceEtagHeader(ctx: Context, resource: Record<string, unknown> | null | undefined): void; export declare class ResourcePreconditionFailedError extends AppsembleError { readonly data: { code: 'RESOURCE_PRECONDITION_FAILED'; resourceId: number | string; resourceType: string; }; readonly error = "Precondition Failed"; readonly statusCode = 412; constructor(resourceType: string, resourceId: number | string); } export declare function throwResourcePreconditionFailedKoaError(ctx: Context, resourceType: string, resourceId: number | string): never;