Skip to content

Instantly share code, notes, and snippets.

@stuart-haas
Created September 10, 2020 19:06
Show Gist options
  • Save stuart-haas/fff9a330b01bc056058cf431ab352e94 to your computer and use it in GitHub Desktop.
Save stuart-haas/fff9a330b01bc056058cf431ab352e94 to your computer and use it in GitHub Desktop.
Typeorm project setup
# Install dependencies
echo "Installing dependencies"
npm install --prefix ./client && npm install --prefix ./server && npm install
# Copy the .env.example to .env
cd server
if [ ! -f .env ]; then
echo "\nCreating the .env file"
cp -v .env.example .env
# Generate the session secret key and add it to the .env
SESSION_SECRET=$(openssl rand -base64 32)
sed -i '' "/^SESSION_SECRET=/s/=.*/=$SESSION_SECRET/" .env
else
echo "\nThe .env already exists"
fi
# Generate and run migrations
echo "\nRunning migrations"
npm run migration:generate "initial_migration"
npm run migration:run
echo "\nSetup complete!"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment