Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(server): non-string primitive type response #293

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/server-nodejs/src/configuration/ServerOptions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export const serverOptionsSchema = z
export default class ServerOptions
{
#config: string;
#loglevel?: string;
#loglevel: string;

constructor(config: string, loglevel = 'info')
{
Expand Down
2 changes: 2 additions & 0 deletions packages/server-nodejs/src/controllers/HealthController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ export default class HealthController

this.#logger.debug('Got health status');

response.setHeader('Content-Type', 'text/plain');

return response.status(200).send(healthy);
}
}
7 changes: 4 additions & 3 deletions packages/server-nodejs/src/controllers/RPCController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ export default class RPCController

const result = await this.#runtime.handle(fqn, version, argsMap, headers);

this.#logger.info(`Ran procedure -> ${fqn} (${version.toString()})`);
this.#logger.info(`Ran procedure -> ${fqn} (v${version.toString()})`);

this.#setResponseHeaders(response, headers);

Expand All @@ -182,7 +182,7 @@ export default class RPCController
const message = error instanceof Error ? error.message : String(error);
const errorData = serialize ? error : message;

this.#logger.error(`Failed to run procedure -> ${fqn} (${version.toString()}) | ${message}`);
this.#logger.error(`Failed to run procedure -> ${fqn} (v${version.toString()}) | ${message}`);

return this.#createErrorResponse(error, errorData, response, serialize);
}
Expand All @@ -209,10 +209,11 @@ export default class RPCController
{
const content = await this.#createResponseContent(result, serialize);
const contentType = this.#createResponseContentType(content);
const responseContent = contentType === 'text/plain' ? String(content) : content;

response.setHeader('Content-Type', contentType);

return response.status(200).send(content);
return response.status(200).send(responseContent);
}

async #createErrorResponse(error: unknown, errorData: unknown, response: Response, serialize: boolean): Promise<Response>
Expand Down