Skip to content

Commit

Permalink
feat(gateway): add spoken to signed video
Browse files Browse the repository at this point in the history
  • Loading branch information
AmitMY committed Sep 15, 2024
1 parent 9eab269 commit f92b885
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 11 deletions.
17 changes: 6 additions & 11 deletions functions/src/gateway/controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,12 @@ import {onRequest} from 'firebase-functions/v2/https';
import {unkeyAuth} from './middleware';
import {HttpsOptions} from 'firebase-functions/lib/v2/providers/https';
import {getAppCheck} from 'firebase-admin/app-check';
import {createProxyMiddleware} from 'http-proxy-middleware';
import {paths} from './utils';
import {avatars} from './avatars';
import {me} from './me';
import {spokenToSigned} from './spoken-to-signed';

// The public APP ID of the sign-mt web app
const APP_ID = '1:665830225099:web:18e0669d5847a4b047974e';
const FUNCTIONS_URL = 'https://us-central1-sign-mt.cloudfunctions.net';

// Create and cache an App Check token for the sign-mt web app
let appCheckAPIKey = Promise.resolve({token: '', expires: 0});
Expand All @@ -39,6 +37,10 @@ export async function getAppCheckKey(req: Request, res: Response, next: NextFunc
}

res.locals.appCheckToken = token;
res.locals.headers = {
'X-Firebase-AppCheck': token,
'X-AppCheck-Token': token,
};

return next();
}
Expand All @@ -50,14 +52,7 @@ app.use(unkeyAuth);
app.use(getAppCheckKey);
app.options('*', (req, res) => res.status(200).end());

app.use(
paths('spoken-text-to-signed-pose'),
createProxyMiddleware({
target: `${FUNCTIONS_URL}/spoken_text_to_signed_pose`,
changeOrigin: true,
})
);

spokenToSigned(app);
me(app);
avatars(app);

Expand Down
21 changes: 21 additions & 0 deletions functions/src/gateway/spoken-to-signed.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import {Application} from 'express';
import {paths} from './utils';
import {createProxyMiddleware} from 'http-proxy-middleware';

export function spokenToSigned(app: Application) {
app.use(
paths('spoken-text-to-signed-pose'),
createProxyMiddleware({
target: 'https://us-central1-sign-mt.cloudfunctions.net/spoken_text_to_signed_pose',
changeOrigin: true,
})
);

app.use(
paths('spoken-text-to-signed-video'),
createProxyMiddleware({
target: 'https://us-central1-sign-mt.cloudfunctions.net/spoken_text_to_signed_video',
changeOrigin: true,
})
);
}

0 comments on commit f92b885

Please sign in to comment.