MCPcopy Create free account
hub / github.com/cawfree/react-native-wormhole / serveTranspiledFile

Function serveTranspiledFile

example/scripts/serve.js:13–33  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

11const mocks = path.resolve(`${appRootPath}`, '__mocks__');
12
13const serveTranspiledFile = wallet => async (req, res, next) => {
14 try {
15 const { params } = req;
16 const { wormhole } = params;
17 const file = path.resolve(mocks, wormhole);
18 if (!fs.existsSync(file)) {
19 throw new Error(`Unable to find ${file}`);
20 }
21 const src = child_process.execSync(
22 `npx babel --presets=@babel/preset-env,@babel/preset-react ${wormhole}`,
23 { cwd: `${mocks}` },
24 ).toString();
25 const signature = await wallet.signMessage(src);
26 return res
27 .status(200)
28 .set({ 'X-Csrf-Token': signature })
29 .send(src);
30 } catch (e) {
31 return next(e);
32 }
33};
34
35(async () => {
36 const { PORT, SIGNER_MNEMONIC } = process.env;

Callers 1

serve.jsFile · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected