diff --git a/deploy/server-info.md b/deploy/server-info.md new file mode 100644 index 0000000..c166b52 --- /dev/null +++ b/deploy/server-info.md @@ -0,0 +1,89 @@ +# Marketplace — Server Deployment Info + +## Server Access +- **IP**: 173.212.212.157 +- **OS**: Ubuntu 24.04.2 LTS +- **SSH User**: root +- **SSH Password**: V8Padp8oIwl8m3RP0Mi28o5TVrkh +- **Connect**: `sshpass -p 'V8Padp8oIwl8m3RP0Mi28o5TVrkh' ssh root@173.212.212.157` + +## Domain & SSL +- **Domain**: marketplace.173.212.212.157.sslip.io +- **URL**: https://marketplace.173.212.212.157.sslip.io +- **DNS Provider**: sslip.io (automatic IP-based DNS, no account needed) +- **SSL**: Let's Encrypt via Certbot +- **Certificate Path**: /etc/letsencrypt/live/marketplace.173.212.212.157.sslip.io/ +- **Certificate Expiry**: 2026-05-23 +- **Auto-renewal**: certbot.timer (systemd), runs twice daily + +## Server Software +- **Node.js**: v20.20.0 +- **Nginx**: 1.24.0 +- **PostgreSQL**: 16 +- **PM2**: process manager +- **Certbot**: 2.9.0 + +## File Paths +- **Frontend (static)**: /var/www/marketplace/ +- **Backend (app)**: /var/www/marketplace-app/ +- **Server code**: /var/www/marketplace-app/server/ +- **Uploads**: /var/www/marketplace-app/server/uploads/ +- **Nginx config**: /etc/nginx/sites-available/marketplace +- **Server .env**: /var/www/marketplace-app/server/.env + +## Database +- **Type**: PostgreSQL 16 +- **Host**: localhost:5432 +- **Database**: marketplace +- **User**: marketplace +- **Password**: marketplace_dev +- **Connection**: `postgresql://marketplace:marketplace_dev@localhost:5432/marketplace` + +## Backend +- **Port**: 3001 +- **PM2 name**: marketplace-api +- **Start command**: `pm2 start "npx tsx src/index.ts" --name marketplace-api` +- **Health check**: https://marketplace.173.212.212.157.sslip.io/api/health + +## JWT Secrets +- **Access Token**: mkt-jwt-secret-prod-2026-xK9mP2 +- **Refresh Token**: mkt-refresh-secret-prod-2026-qW7nL4 + +## Nginx Configuration +- HTTP (port 80) -> HTTPS redirect +- `/` -> SPA with try_files fallback to index.html +- `/api/*` -> proxy to http://127.0.0.1:3001/api/ +- `/socket.io/*` -> WebSocket proxy to http://127.0.0.1:3001/socket.io/ +- `/uploads/*` -> alias to /var/www/marketplace-app/server/uploads/ +- `/assets/*` -> cached 1 year, immutable + +## Git Repository +- **Gitea**: https://git.sensey24.ru/aibot777/marketplace +- **Credentials**: aibot777:aibot777 +- **Clone**: `git clone https://aibot777:aibot777@git.sensey24.ru/aibot777/marketplace.git` + +## Deployment Steps + +### Frontend (client) +```bash +cd /Users/tony/Downloads/marketplace +npm run build --workspace=client +sshpass -p 'V8Padp8oIwl8m3RP0Mi28o5TVrkh' scp -r client/dist/* root@173.212.212.157:/var/www/marketplace/ +``` + +### Backend (server) +```bash +sshpass -p 'V8Padp8oIwl8m3RP0Mi28o5TVrkh' ssh root@173.212.212.157 'cd /var/www/marketplace-app && git pull && cd server && npm install && npx prisma db push && pm2 restart marketplace-api' +``` + +### Full redeploy +```bash +npm run build --workspace=client +sshpass -p 'V8Padp8oIwl8m3RP0Mi28o5TVrkh' scp -r client/dist/* root@173.212.212.157:/var/www/marketplace/ +sshpass -p 'V8Padp8oIwl8m3RP0Mi28o5TVrkh' ssh root@173.212.212.157 'cd /var/www/marketplace-app && git pull && cd server && npm install && npx prisma db push && pm2 restart marketplace-api' +``` + +## Stripe (Not configured yet) +- STRIPE_SECRET_KEY: (empty) +- STRIPE_WEBHOOK_SECRET: (empty) +- Test card: 4242 4242 4242 4242 diff --git a/server/package.json b/server/package.json index 6bf82db..a00e3cf 100644 --- a/server/package.json +++ b/server/package.json @@ -25,7 +25,8 @@ "stripe": "^17.5.0", "helmet": "^8.0.0", "express-rate-limit": "^7.5.0", - "cookie-parser": "^1.4.7" + "cookie-parser": "^1.4.7", + "dotenv": "^16.4.0" }, "devDependencies": { "@types/express": "^4.17.21", diff --git a/server/src/config/env.ts b/server/src/config/env.ts index 96458b0..1c6c61a 100644 --- a/server/src/config/env.ts +++ b/server/src/config/env.ts @@ -1,3 +1,5 @@ +import 'dotenv/config'; + export const env = { PORT: parseInt(process.env['PORT'] || '3000', 10), DATABASE_URL: process.env['DATABASE_URL'] || 'postgresql://marketplace:marketplace_dev@localhost:5432/marketplace',