Skip to content

Commit

Permalink
fix(express): correctly type options request
Browse files Browse the repository at this point in the history
  • Loading branch information
AmitMY committed Oct 13, 2024
1 parent c13838f commit 19c6a15
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 2 deletions.
3 changes: 2 additions & 1 deletion functions/src/gateway/controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import {getAppCheck} from 'firebase-admin/app-check';
import {avatars} from './avatars';
import {me} from './me';
import {spokenToSigned} from './spoken-to-signed';
import {optionsRequest} from '../middlewares/options.request';

// The public APP ID of the sign-mt web app
const APP_ID = '1:665830225099:web:18e0669d5847a4b047974e';
Expand Down Expand Up @@ -50,7 +51,7 @@ const app: Application = express();
app.use(cors());
app.use(unkeyAuth);
app.use(getAppCheckKey);
app.options('*', (req, res) => res.status(200).end());
app.options('*', optionsRequest);

spokenToSigned(app);
me(app);
Expand Down
5 changes: 5 additions & 0 deletions functions/src/middlewares/options.request.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import * as express from 'express';

export function optionsRequest(req: express.Request, res: express.Response) {
res.status(200).end();
}
3 changes: 2 additions & 1 deletion functions/src/text-normalization/controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import {onRequest} from 'firebase-functions/v2/https';
import {defineString} from 'firebase-functions/params';
import {appCheckVerification} from '../middlewares/appcheck.middleware';
import type {StringParam} from 'firebase-functions/lib/params/types';
import {optionsRequest} from '../middlewares/options.request';

export class TextNormalizationEndpoint {
constructor(private database: FirebaseDatabase, private OpenAIApiKey: StringParam) {}
Expand Down Expand Up @@ -106,7 +107,7 @@ export const textNormalizationFunctions = (database: FirebaseDatabase) => {
const app = express();
app.use(cors());
app.use(appCheckVerification);
app.options('*', (req, res) => res.status(200).end());
app.options('*', optionsRequest);
app.get(['/', '/api/text-normalization'], request);
app.use(errorMiddleware);

Expand Down

0 comments on commit 19c6a15

Please sign in to comment.