From 8333c280f8663a217bd6e2f68b35c723e929bcbf Mon Sep 17 00:00:00 2001 From: Lee Cheneler Date: Fri, 14 Feb 2025 18:52:08 +0000 Subject: [PATCH] docs: added missing jsdocs --- app/context.ts | 5 +++++ app/mage-error.ts | 13 ++++++++++--- deno.json | 2 +- status/status-utils.ts | 30 ++++++++++++++++++++++++++++++ 4 files changed, 46 insertions(+), 4 deletions(-) diff --git a/app/context.ts b/app/context.ts index f87f9d4..1190a5d 100644 --- a/app/context.ts +++ b/app/context.ts @@ -59,6 +59,11 @@ export class MageContext { return this._req; } + /** + * Construct a new MageContext object + * + * @param args The arguments for the MageContext class + */ public constructor(args: MageContextArgs) { this._buildId = args.buildId; this._req = args.req; diff --git a/app/mage-error.ts b/app/mage-error.ts index 1c7921f..86b2cc3 100644 --- a/app/mage-error.ts +++ b/app/mage-error.ts @@ -3,9 +3,9 @@ import type { ClientErrorStatus, ServerErrorStatus } from "../status/mod.ts"; /** * Error class for Mage errors, throw with a status code for it to be honored by Mage in the response. * - * @param message - The error message - * @param status - The HTTP status code for the error - * @param options - Additional options for the error + * @param message The error message + * @param status The HTTP status code for the error, this will be honored by Mage in the response + * @param options Additional options for the error */ export class MageError extends Error { private _status: ClientErrorStatus | ServerErrorStatus = 500; @@ -17,6 +17,13 @@ export class MageError extends Error { return this._status; } + /** + * Construct a new MageError object + * + * @param message The error message + * @param status The HTTP status code for the error, this will be honored by Mage in the response + * @param options Additional options for the error + */ constructor( message: string, status?: ClientErrorStatus | ServerErrorStatus, diff --git a/deno.json b/deno.json index 3d18612..5a9c70c 100644 --- a/deno.json +++ b/deno.json @@ -1,6 +1,6 @@ { "name": "@mage/app", - "version": "0.2.1", + "version": "0.2.2", "license": "MIT", "exports": { ".": "./app/mod.ts", diff --git a/status/status-utils.ts b/status/status-utils.ts index 3f9f1b9..107a985 100644 --- a/status/status-utils.ts +++ b/status/status-utils.ts @@ -1,5 +1,11 @@ +/** + * Informational status + */ export type InfoStatus = 100 | 101 | 103; +/** + * Success status + */ export type SuccessStatus = | 200 | 201 @@ -12,8 +18,14 @@ export type SuccessStatus = | 208 | 226; +/** + * Redirect status + */ export type RedirectStatus = 301 | 302 | 303 | 307 | 308; +/** + * Client error status + */ export type ClientErrorStatus = | 400 | 401 @@ -45,6 +57,9 @@ export type ClientErrorStatus = | 431 | 451; +/** + * Server error status + */ export type ServerErrorStatus = | 500 | 501 @@ -58,6 +73,9 @@ export type ServerErrorStatus = | 510 | 511; +/** + * All status + */ export type Status = | InfoStatus | SuccessStatus @@ -65,7 +83,14 @@ export type Status = | ClientErrorStatus | ServerErrorStatus; +/** + * Contentful status + */ export type ContentfulStatus = Exclude; + +/** + * Contentless status + */ export type ContentlessStatus = Exclude; const statusTextMap = { @@ -134,6 +159,11 @@ const statusTextMap = { 511: "Network Authentication Required", }; +/** + * Get default status text for a status + * @param status The status + * @returns The status text + */ export const statusText = (status: keyof typeof statusTextMap): string => { return statusTextMap[status]; };