Skip to content

Commit

Permalink
fix: types and error response
Browse files Browse the repository at this point in the history
  • Loading branch information
SKairinos committed Dec 13, 2024
1 parent 5260292 commit 1c2fcf7
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,15 +42,15 @@ export default class Server {
this.healthCheckCacheTimeout = 30000
}

/** @type {(request: Request) => { healthStatus: "healthy" | "startingUp" | "shuttingDown" | "unhealthy" | "unknown"; additionalInfo: string; details?: Array<{ name: string; description: string; health: "healthy" | "startingUp" | "shuttingDown" | "unhealthy" | "unknown"; }> }} */
/** @type {(request: import('express').Request) => { healthStatus: "healthy" | "startingUp" | "shuttingDown" | "unhealthy" | "unknown"; additionalInfo: string; details?: Array<{ name: string; description: string; health: "healthy" | "startingUp" | "shuttingDown" | "unhealthy" | "unknown"; }> }} */
getHealthCheck(request) {
return {
healthStatus: "healthy",
additionalInfo: "All healthy.",
}
}

/** @type {(request: Request, response: Response) => void} */
/** @type {(request: import('express').Request, response: import('express').Response) => void} */
handleHealthCheck(request, response) {
let value = this.cache.get(this.healthCheckCacheKey)
if (value === null) {
Expand Down Expand Up @@ -80,7 +80,7 @@ export default class Server {
response.json(value)
}

/** @type {(request: Request, response: Response) => Promise<void>} */
/** @type {(request: import('express').Request, response: import('express').Response) => Promise<void>} */
async handleServeHtml(request, response) {
try {
const path = request.originalUrl.replace(this.base, "")
Expand Down Expand Up @@ -111,8 +111,8 @@ export default class Server {
response.status(200).set({ "Content-Type": "text/html" }).send(html)
} catch (error) {
this.vite?.ssrFixStacktrace(error)
console.log(error.stack)
response.status(500).end(error.stack)
console.error(error.stack)
response.status(500).end(this.envIsProduction ? undefined : error.stack)
}
}

Expand Down

0 comments on commit 1c2fcf7

Please sign in to comment.