Skip to content

Commit

Permalink
refactor: adding the server context types in the middleware
Browse files Browse the repository at this point in the history
  • Loading branch information
SeanCassiere committed Jun 24, 2024
1 parent 131ddc3 commit 2bf8fa3
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/utils/server-helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,10 @@ async function getService(serviceId: string, opts = { mustBeAdmin: false }) {
return service ?? null;
}

const factory = createFactory();
const factory = createFactory<ServerContext>();

/**
* Middleware to validate that a service ID is provided and that the service exists
* V2 implementation of the middleware to validate that a service request by the service ID in the "x-app-service-id" header
*/
export const v2_serviceValidation = factory.createMiddleware(async (c, next) => {
const serviceId = getServiceId(c);
Expand All @@ -76,7 +76,7 @@ export const v2_serviceValidation = factory.createMiddleware(async (c, next) =>
* Middleware to validate that a service ID is provided and that the service exists and is an admin service
*/
export const adminServiceValidation = factory.createMiddleware(async (c, next) => {
const service = c.var.service as ServerContext["Variables"]["service"];
const service = c.var.service;

if (!service) {
c.status(403);
Expand Down

0 comments on commit 2bf8fa3

Please sign in to comment.