@@ -8,22 +8,26 @@ npm run dev
88compile = """ # Runs before debug too. Lacks custom env vars.
99SECONDS=0
1010FEATHERS_DIR="feathers-chat-ts"
11+ FEATHERS_ORIGIN="https://$REPL_SLUG.$REPL_OWNER.repl.co"
1112clear
1213echo [compile]
1314
1415if [ ! -d "$FEATHERS_DIR/node_modules" ]; then
1516 cd $FEATHERS_DIR
1617 npm i &> /dev/null
17- export PERF1=$SECONDS
18- npm run migrate # Sets up the tables, login will not work without this!l
1918
2019 # For TS clients
2120 # npm run compile # Drastically faster dev cold boot without
2221 # npm run bundle:client # Generates .tgz types for loading into TS clients
23-
24- export PERF2=$(($SECONDS - $PERF1))
2522 cd -
2623fi
24+ PERF1=$SECONDS
25+
26+ # Sets up the tables, login will not work without this!
27+ if [ ! -f "$FEATHERS_DIR/feathers-chat.sqlite" ]; then
28+ sh -c "cd '$FEATHERS_DIR'; npm run migrate"
29+ fi
30+ PERF2=$(($SECONDS - $PERF1))
2731
2832# Helper script to deal with lack of CWD support in the Debugger
2933mkdir -p .config
@@ -44,14 +48,23 @@ echo Node version: "$(node --version)"
4448EOF
4549fi
4650
51+ # Append origin for OAuth. Alternatively, set it as an env var
52+ CONFIG_FILE="$FEATHERS_DIR/config/default.json"
53+ if ! grep -q "$FEATHERS_ORIGIN" "$CONFIG_FILE"; then
54+ sed -i "/\\"origins\\"/a \\ \\"$FEATHERS_ORIGIN\\"," "$CONFIG_FILE"
55+ fi
56+
4757INDEX_TS="$FEATHERS_DIR/src/index.ts"
4858if ! grep -q "console.time" "$INDEX_TS"; then
49- sed -i "1i console.time('App startup time')" "$INDEX_TS"
50- sed -i "/Feathers app listening on /a console.timeEnd('App startup time')" "$INDEX_TS"
51- clear
52- echo "[compile] took ${SECONDS}s. ($PERF1 + $PERF2)"
59+ sed -i "/Feathers app listening on /a \\
60+ \\ logger.info(\\`Remote: \\${process.env.FEATHERS_ORIGIN}\\`)\\n\\
61+ console.timeEnd('App startup time')" "$INDEX_TS"
62+
63+ sed -i "1i console.time('App startup time')" "$INDEX_TS"
64+ clear
65+ echo "[compile] took ${SECONDS}s. ($PERF1 + $PERF2)"
5366else
54- clear
67+ clear
5568fi
5669""" # """
5770
@@ -77,10 +90,11 @@ channel = "stable-22_11"
7790[env]
7891FEATHERS_DIR = "feathers-chat-ts"
7992PATH = "/home/runner/$REPL_SLUG/.config/npm/node_global/bin:/home/runner/$REPL_SLUG/node_modules/.bin:/home/runner/$REPL_SLUG/$FEATHERS_DIR/node_modules/.bin"
80- EDITOR= "replit-git-editor"
93+ EDITOR = "replit-git-editor"
8194npm_config_prefix = "/home/runner/$REPL_SLUG/.config/npm/node_global"
82- HOSTNAME="0.0.0.0"
83- NODE_OPTIONS="--max_old_space_size=384"
95+ HOSTNAME = "0.0.0.0"
96+ FEATHERS_ORIGIN = "https://$REPL_SLUG.$REPL_OWNER.repl.co"
97+ NODE_OPTIONS = "--max_old_space_size=384"
8498
8599# Enables Secrets and Auth, without the Replit packager
86100[packager]
@@ -139,4 +153,5 @@ support = true
139153
140154 [debugger.interactive.launchMessage.arguments.env]
141155 PORT = 9000
156+ FEATHERS_ORIGIN = "https://$REPL_SLUG.$REPL_OWNER.repl.co:9000"
142157
0 commit comments