Skip to content

Commit

Permalink
fix(jsr): add return types
Browse files Browse the repository at this point in the history
  • Loading branch information
jasonraimondi committed May 29, 2024
1 parent 9d1cd9f commit 420f7cb
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/adapters/fastify.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,21 @@ import { OAuthException } from "../exceptions/oauth.exception.js";
import { OAuthRequest } from "../requests/request.js";
import { OAuthResponse } from "../responses/response.js";

export function responseFromFastify(res: FastifyReply) {
export function responseFromFastify(res: FastifyReply): OAuthResponse {
return new OAuthResponse({
headers: <Record<string, unknown>>(<unknown>res.headers) ?? {},
});
}

export function requestFromFastify(req: FastifyRequest) {
export function requestFromFastify(req: FastifyRequest): OAuthRequest {
return new OAuthRequest({
query: <Record<string, unknown>>req.query ?? {},
body: <Record<string, unknown>>req.body ?? {},
headers: <Record<string, unknown>>req.headers ?? {},
});
}

export function handleFastifyError(e: unknown | OAuthException, res: FastifyReply) {
export function handleFastifyError(e: unknown | OAuthException, res: FastifyReply): void {
if (e instanceof OAuthException) {
res.status(e.status).send({
status: e.status,
Expand All @@ -29,7 +29,7 @@ export function handleFastifyError(e: unknown | OAuthException, res: FastifyRepl
throw e;
}

export function handleFastifyReply(res: FastifyReply, response: OAuthResponse) {
export function handleFastifyReply(res: FastifyReply, response: OAuthResponse): void {
if (response.status === 302) {
if (!response.headers.location) throw new Error("missing redirect location");
res.headers(response.headers);
Expand Down

0 comments on commit 420f7cb

Please sign in to comment.