Skip to content

Commit

Permalink
Improve types
Browse files Browse the repository at this point in the history
  • Loading branch information
zigazajc007 committed Sep 3, 2024
1 parent 1a398ce commit 87af94e
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
2 changes: 1 addition & 1 deletion jsr.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@
"version": "0.0.1",
"exports": "./src/cloudky-api.ts",
"publish": {
"include": ["LICENSE", "README.md", "src/cloudky-api.ts"]
"include": ["LICENSE", "README.md", "src/cloudky-api.ts", "src/errors.ts", "src/types.ts", "src/validate.ts"]
}
}
8 changes: 5 additions & 3 deletions src/errors.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import type { StandardResponse } from "./types";

/**
* Enum representing various error codes used throughout the application.
* Each error code corresponds to a specific error message.
Expand Down Expand Up @@ -120,16 +122,16 @@ namespace Errors {
* @param {Error} id - The error code to retrieve details for.
* @returns {{ message: string; httpCode: number }} An object containing the error message and HTTP status code.
*/
export function get(id: Error) {
export function get(id: Error): { message: string; httpCode: number } {
return list[id];
}

/**
* Formats the error response as a JSON object.
* @param {Error} id - The error code to format.
* @returns {{ error: Error, info: string }} A JSON object containing the error code and message.
* @returns {StandardResponse} A JSON object containing the error code and message.
*/
export function getJson(id: Error) {
export function getJson(id: Error): StandardResponse {
return { error: id, info: list[id].message };
}
}
Expand Down

0 comments on commit 87af94e

Please sign in to comment.