Skip to content

Commit

Permalink
Adding base path to Api Gw (#1077)
Browse files Browse the repository at this point in the history
  • Loading branch information
ecamellini authored Oct 10, 2024
1 parent 272d210 commit 9f4f333
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 10 deletions.
1 change: 1 addition & 0 deletions packages/api-gateway/.env
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
HOST=0.0.0.0
PORT=3700
LOG_LEVEL=info
API_GATEWAY_INTERFACE_VERSION="0.0"

WELL_KNOWN_URLS="http://127.0.0.1:4500/jwks.json"
ACCEPTED_AUDIENCES="dev.interop.pagopa.it/m2m,refactor.dev.interop.pagopa.it/m2m"
Expand Down
18 changes: 9 additions & 9 deletions packages/api-gateway/src/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,14 @@ app.disable("x-powered-by");

app.use(contextMiddleware(serviceName, true));

// Unauthenticated routes
app.use(healthRouter);

app.use(authenticationMiddleware(config));

// Authenticated routes - rate limiter and logger need authentication data to work
app.use(loggerMiddleware(serviceName));
app.use(rateLimiterMiddleware(redisRateLimiter));
app.use(apiGatewayRouter(zodiosCtx, clients));
app.use(
`/api-gateway/${config.apiGatewayInterfaceVersion}`,
healthRouter,
authenticationMiddleware(config),
// Authenticated routes - rate limiter and logger rely on auth data to work
loggerMiddleware(serviceName),
rateLimiterMiddleware(redisRateLimiter),
apiGatewayRouter(zodiosCtx, clients)
);

export default app;
10 changes: 10 additions & 0 deletions packages/api-gateway/src/config/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,17 @@ export const NotifierServerConfig = z
}));
export type NotifierServerConfig = z.infer<typeof NotifierServerConfig>;

export const InterfaceVersion = z
.object({
API_GATEWAY_INTERFACE_VERSION: z.string(),
})
.transform((c) => ({
apiGatewayInterfaceVersion: c.API_GATEWAY_INTERFACE_VERSION,
}));
export type InterfaceVersion = z.infer<typeof InterfaceVersion>;

const ApiGatewayConfig = CommonHTTPServiceConfig.and(RedisRateLimiterConfig)
.and(InterfaceVersion)
.and(CatalogProcessServerConfig)
.and(AgreementProcessServerConfig)
.and(TenantProcessServerConfig)
Expand Down
2 changes: 1 addition & 1 deletion packages/backend-for-frontend/src/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ app.use(
healthRouter,
authorizationRouter(zodiosCtx, clients, allowList, redisRateLimiter),
authenticationMiddleware(config),
// Authenticated routes - rate limiter need authentication data to work
// Authenticated routes - rate limiter relies on auth data to work
rateLimiterMiddleware(redisRateLimiter),
catalogRouter(zodiosCtx, clients, fileManager),
attributeRouter(zodiosCtx, clients),
Expand Down

0 comments on commit 9f4f333

Please sign in to comment.