Skip to content

Commit

Permalink
poc: processHeaders handler
Browse files Browse the repository at this point in the history
  • Loading branch information
WojtekTheWebDev committed Jan 28, 2025
1 parent 1f0ab35 commit a6e939e
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 0 deletions.
2 changes: 2 additions & 0 deletions packages/middleware/src/createServer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import {
prepareArguments,
callApiFunction,
validateParams,
processHeaders,
} from "./handlers";
import { createTerminusOptions } from "./terminus";
import { prepareLogger } from "./handlers/prepareLogger";
Expand Down Expand Up @@ -89,6 +90,7 @@ async function createServer<
app.all(
"/:integrationName/:extensionName?/:functionName",
validateParams(integrations),
processHeaders,
prepareFileUpload(options),
prepareLogger(loggerManager),
prepareApiFunction(integrations),
Expand Down
1 change: 1 addition & 0 deletions packages/middleware/src/handlers/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@ export * from "./prepareErrorHandler";
export * from "./prepareArguments";
export * from "./prepareLogger";
export * from "./validateParams";
export * from "./processHeaders";
10 changes: 10 additions & 0 deletions packages/middleware/src/handlers/processHeaders/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import type { Request, Response, NextFunction } from "express";

export function processHeaders(req: Request, res: Response, next: NextFunction) {

Check failure on line 3 in packages/middleware/src/handlers/processHeaders/index.ts

View workflow job for this annotation

GitHub Actions / Continuous Integration / Run CI

Replace `req:·Request,·res:·Response,·next:·NextFunction` with `⏎··req:·Request,⏎··res:·Response,⏎··next:·NextFunction⏎`
const locale = req.headers['x-alokai-locale'];

Check failure on line 4 in packages/middleware/src/handlers/processHeaders/index.ts

View workflow job for this annotation

GitHub Actions / Continuous Integration / Run CI

Replace `'x-alokai-locale'` with `"x-alokai-locale"`
console.log(req.cookies)

Check failure on line 5 in packages/middleware/src/handlers/processHeaders/index.ts

View workflow job for this annotation

GitHub Actions / Continuous Integration / Run CI

Insert `;`
req.cookies['vsf-locale'] = locale;

Check failure on line 6 in packages/middleware/src/handlers/processHeaders/index.ts

View workflow job for this annotation

GitHub Actions / Continuous Integration / Run CI

Replace `'vsf-locale'` with `"vsf-locale"`

next();
};

Check failure on line 9 in packages/middleware/src/handlers/processHeaders/index.ts

View workflow job for this annotation

GitHub Actions / Continuous Integration / Run CI

Delete `;⏎`

0 comments on commit a6e939e

Please sign in to comment.