Skip to content

Commit 4fb678e

Browse files
authored
skip react-native ops if dirs don't exist (#11974)
1 parent 0979612 commit 4fb678e

File tree

3 files changed

+42
-13
lines changed

3 files changed

+42
-13
lines changed

packages/discovery-provider/plugins/pedalboard/apps/relay/src/server.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import { healthCheck } from './routes/health'
22
import express from 'express'
3-
import { relayTransaction } from './txRelay'
43
import { errorHandler } from './middleware/errorHandler'
54
import {
65
incomingRequestLogger,
@@ -9,8 +8,7 @@ import {
98
import { validator } from './middleware/validator'
109
import cors from 'cors'
1110
import bodyParser from 'body-parser'
12-
import { antiAbuseMiddleware } from './middleware/antiAbuse'
13-
import { rateLimiterMiddleware } from './middleware/rateLimiter'
11+
import { relayTransaction } from './txRelay'
1412

1513
export const app = express()
1614

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
import { coreRelay } from './coreRelay'
2+
import { internalError } from './error'
3+
import {
4+
TransactionReceipt,
5+
TransactionRequest
6+
} from '@ethersproject/abstract-provider'
7+
import { NextFunction, Request, Response } from 'express'
8+
9+
export type RelayedTransaction = {
10+
receipt: TransactionReceipt
11+
transaction: TransactionRequest
12+
}
13+
14+
export const relayTransaction = async (
15+
_req: Request,
16+
res: Response,
17+
next: NextFunction
18+
) => {
19+
// pull info from validated request
20+
const { validatedRelayRequest, logger, requestId } = res.locals.ctx
21+
try {
22+
const receipt = await coreRelay(logger, requestId, validatedRelayRequest)
23+
logger.info({ receipt }, "sending back")
24+
res.send({ receipt })
25+
} catch (e) {
26+
internalError(next, e)
27+
return
28+
}
29+
}

scripts/postinstall.sh

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -19,22 +19,24 @@ fi
1919
printf "${GREEN}Setting up initial package links...\n${NC}"
2020
{
2121
# First ensure react-native exists in root node_modules for patch-package
22-
if [ ! -e "node_modules/react-native" ]; then
22+
if [ ! -e "node_modules/react-native" ] && [ -e "./packages/mobile/node_modules/react-native" ]; then
2323
printf "${GREEN}Moving react-native to root node_modules...\n${NC}"
2424
cp -R ./packages/mobile/node_modules/react-native ./node_modules/
2525
rm -rf ./packages/mobile/node_modules/react-native
2626
fi
2727

28-
cd ./packages/mobile/node_modules
28+
if [ -d "./packages/mobile/node_modules" ]; then
29+
cd ./packages/mobile/node_modules
2930

30-
# Link react-native-code-push from root since it's not in mobile/node_modules
31-
source_path=../../../node_modules/react-native-code-push
32-
target_path=react-native-code-push
33-
if [ ! -e "$target_path" ]; then
34-
ln -s "$source_path" "$target_path"
35-
fi
31+
# Link react-native-code-push from root since it's not in mobile/node_modules
32+
source_path=../../../node_modules/react-native-code-push
33+
target_path=react-native-code-push
34+
if [ ! -e "$target_path" ]; then
35+
ln -s "$source_path" "$target_path"
36+
fi
3637

37-
cd ../../..
38+
cd ../../..
39+
fi
3840
} > /dev/null
3941

4042
printf "${GREEN}Applying patches...\n${NC}"
@@ -43,7 +45,7 @@ npm run patch-package > /dev/null
4345
printf "${GREEN}Moving react-native back to mobile...\n${NC}"
4446
{
4547
# Move react-native back to mobile/node_modules for pod install
46-
if [ -e "node_modules/react-native" ]; then
48+
if [ -e "node_modules/react-native" ] && [ -d "./packages/mobile/node_modules" ]; then
4749
rm -rf ./packages/mobile/node_modules/react-native
4850
mv ./node_modules/react-native ./packages/mobile/node_modules/
4951
# Create symlink back to root

0 commit comments

Comments
 (0)