Format logs, bump version, update Traefik config
- Reformat logging calls in server.js for readability - Bump API version from 1.0.0 to 2.1.2 - Update Traefik labels; switch TLS certresolver to letsencrypt-cloudflare
This commit is contained in:
@@ -8,7 +8,12 @@ import jwt from '@fastify/jwt'
|
||||
import closeWithGrace from 'close-with-grace'
|
||||
|
||||
// Import configurations
|
||||
import { jwtConfig, corsConfig, serverConfig, rateLimitConfig } from './config/jwt.js'
|
||||
import {
|
||||
jwtConfig,
|
||||
corsConfig,
|
||||
serverConfig,
|
||||
rateLimitConfig
|
||||
} from './config/jwt.js'
|
||||
import dbManager from './config/database.js'
|
||||
|
||||
// Import routes
|
||||
@@ -26,22 +31,28 @@ export default async function build(opts = {}) {
|
||||
// Add request logging hook
|
||||
app.addHook('onRequest', async (request, reply) => {
|
||||
request.startTime = Date.now()
|
||||
app.log.debug({
|
||||
method: request.method,
|
||||
url: request.url,
|
||||
ip: request.ip
|
||||
}, 'Incoming request')
|
||||
app.log.debug(
|
||||
{
|
||||
method: request.method,
|
||||
url: request.url,
|
||||
ip: request.ip
|
||||
},
|
||||
'Incoming request'
|
||||
)
|
||||
})
|
||||
|
||||
// Add response logging hook
|
||||
app.addHook('onResponse', async (request, reply) => {
|
||||
const duration = Date.now() - (request.startTime || Date.now())
|
||||
app.log.debug({
|
||||
method: request.method,
|
||||
url: request.url,
|
||||
statusCode: reply.statusCode,
|
||||
durationMs: duration
|
||||
}, 'Request completed')
|
||||
app.log.debug(
|
||||
{
|
||||
method: request.method,
|
||||
url: request.url,
|
||||
statusCode: reply.statusCode,
|
||||
durationMs: duration
|
||||
},
|
||||
'Request completed'
|
||||
)
|
||||
})
|
||||
|
||||
await app.register(jwt, {
|
||||
@@ -108,7 +119,7 @@ export default async function build(opts = {}) {
|
||||
app.get('/', async (request, reply) => {
|
||||
return {
|
||||
message: 'EDH/Commander Stats API',
|
||||
version: '1.0.0',
|
||||
version: '2.1.2',
|
||||
status: 'running'
|
||||
}
|
||||
})
|
||||
|
||||
10
deploy.sh
10
deploy.sh
@@ -375,19 +375,13 @@ services:
|
||||
depends_on:
|
||||
- backend
|
||||
labels:
|
||||
# Enable Traefik discovery for this service
|
||||
- traefik.enable=true
|
||||
# Routing rule - change edh.example.com to your domain
|
||||
- traefik.http.routers.edh-stats-frontend.rule=Host(\`edh.zlor.fi\`)
|
||||
# Entry points: web (HTTP) and websecure (HTTPS)
|
||||
- traefik.http.routers.edh-stats-frontend.entrypoints=web,websecure
|
||||
# Service configuration
|
||||
- traefik.http.routers.edh-stats-frontend.entrypoints=websecure
|
||||
- traefik.http.routers.edh-stats-frontend.service=edh-stats-frontend
|
||||
# Backend port (nginx internal port)
|
||||
- traefik.http.services.edh-stats-frontend.loadbalancer.server.port=80
|
||||
# Enable TLS with Let's Encrypt
|
||||
- traefik.http.routers.edh-stats-frontend.tls=true
|
||||
- traefik.http.routers.edh-stats-frontend.tls.certresolver=letsencrypt
|
||||
- traefik.http.routers.edh-stats-frontend.tls.certresolver=letsencrypt-cloudflare
|
||||
deploy:
|
||||
resources:
|
||||
limits:
|
||||
|
||||
Reference in New Issue
Block a user