Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
104 changes: 52 additions & 52 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
@@ -1,52 +1,52 @@
name: Deploy ReCollect Backend

on:
push:
branches:
- main

jobs:
build-and-deploy:
runs-on: ubuntu-latest
steps:
- name: Checkout Code
uses: actions/checkout@v4

- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '24' # Change to match your preferred backend version

- name: Install Dependencies
run: npm ci

- name: Build TypeScript
run: npm run build

- name: Install SSH Key
uses: shimataro/ssh-key-action@v2
with:
key: ${{ secrets.SERVER_SSH_KEY }}
known_hosts: unnecessary

- name: Add Known Hosts
run: ssh-keyscan -H ${{ secrets.SERVER_IP }} >> ~/.ssh/known_hosts

- name: Sync Backend Assets
run: |
# Sync only what's needed for production
# Notice we keep .env on the server!
rsync -avz --delete \
--rsync-path="sudo rsync" \
--exclude '.git' \
--exclude '.github' \
--exclude 'node_modules' \
--exclude 'src' \
--exclude '.env' \
--exclude '.dep_auth.log' \
./ ubuntu@${{ secrets.SERVER_IP }}:/home/ubuntu/ReCollect_Backend/

- name: Restart PM2 Processes
run: |
# Initialize NVM to make PM2 available over non-interactive SSH, then reload
ssh ubuntu@${{ secrets.SERVER_IP }} "export NVM_DIR=\"\$HOME/.nvm\" && [ -s \"\$NVM_DIR/nvm.sh\" ] && \. \"\$NVM_DIR/nvm.sh\" && cd /home/ubuntu/ReCollect_Backend && pm2 reload ecosystem.config.js --env production"
# name: Deploy ReCollect Backend

# on:
# push:
# branches:
# - main

# jobs:
# build-and-deploy:
# runs-on: ubuntu-latest
# steps:
# - name: Checkout Code
# uses: actions/checkout@v4

# - name: Setup Node.js
# uses: actions/setup-node@v4
# with:
# node-version: '24' # Change to match your preferred backend version

# - name: Install Dependencies
# run: npm ci

# - name: Build TypeScript
# run: npm run build

# - name: Install SSH Key
# uses: shimataro/ssh-key-action@v2
# with:
# key: ${{ secrets.SERVER_SSH_KEY }}
# known_hosts: unnecessary

# - name: Add Known Hosts
# run: ssh-keyscan -H ${{ secrets.SERVER_IP }} >> ~/.ssh/known_hosts

# - name: Sync Backend Assets
# run: |
# # Sync only what's needed for production
# # Notice we keep .env on the server!
# rsync -avz --delete \
# --rsync-path="sudo rsync" \
# --exclude '.git' \
# --exclude '.github' \
# --exclude 'node_modules' \
# --exclude 'src' \
# --exclude '.env' \
# --exclude '.dep_auth.log' \
# ./ ubuntu@${{ secrets.SERVER_IP }}:/home/ubuntu/ReCollect_Backend/

# - name: Restart PM2 Processes
# run: |
# # Initialize NVM to make PM2 available over non-interactive SSH, then reload
# ssh ubuntu@${{ secrets.SERVER_IP }} "export NVM_DIR=\"\$HOME/.nvm\" && [ -s \"\$NVM_DIR/nvm.sh\" ] && \. \"\$NVM_DIR/nvm.sh\" && cd /home/ubuntu/ReCollect_Backend && pm2 reload ecosystem.config.js --env production"
9 changes: 9 additions & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,15 @@ app.use(express.json({ limit: '50mb' }));
app.use(express.urlencoded({ extended: true, limit: '50mb' }));
app.use(morgan('dev'));
app.use(cookieParser())
// disable caching for the API
app.use((req, res, next) => {
res.setHeader('Cache-Control', 'no-store, no-cache, must-revalidate, proxy-revalidate');
res.setHeader('Pragma', 'no-cache');
res.setHeader('Expires', '0');
res.setHeader('Surrogate-Control', 'no-store'); // Tells Cloudflare explicitly not to cache
next();
});


//require('./models');
ConnectDb();
Expand Down