feat(privat/CV): sync to latest upstream (cv-upstream/main, 30f9608b)
This commit is contained in:
@@ -0,0 +1,50 @@
|
||||
import express from 'express'
|
||||
import cors from 'cors'
|
||||
import helmet from 'helmet'
|
||||
import { dirname } from 'path'
|
||||
import { fileURLToPath } from 'url'
|
||||
import contactRouter from './routes/contact.js'
|
||||
import talkRequestRouter from './routes/talk-request.js'
|
||||
import newsletterRouter from './routes/newsletter.js'
|
||||
import resourceDownloadRouter from './routes/resource-download.js'
|
||||
import speakerCvRouter from './routes/speaker-cv.js'
|
||||
|
||||
const __dirname = dirname(fileURLToPath(import.meta.url))
|
||||
const PORT = process.env.PORT || 3003
|
||||
|
||||
const app = express()
|
||||
|
||||
// Behind Caddy reverse proxy — trust the first proxy hop so rate limiting
|
||||
// and IP logging use the real client IP.
|
||||
app.set('trust proxy', 1)
|
||||
app.disable('x-powered-by')
|
||||
|
||||
app.use(helmet())
|
||||
app.use(cors({
|
||||
origin: process.env.NODE_ENV === 'production'
|
||||
? 'https://andreknie.de'
|
||||
: 'http://localhost:5173',
|
||||
credentials: true,
|
||||
}))
|
||||
app.use(express.json({ limit: '10kb' }))
|
||||
|
||||
// Routes
|
||||
app.get('/api/health', (_req, res) => {
|
||||
res.json({ status: 'ok', time: new Date().toISOString() })
|
||||
})
|
||||
|
||||
app.use('/api/contact', contactRouter)
|
||||
app.use('/api/talk-request', talkRequestRouter)
|
||||
app.use('/api/newsletter', newsletterRouter)
|
||||
app.use('/api/resource-download', resourceDownloadRouter)
|
||||
app.use('/api/speaker-cv', speakerCvRouter)
|
||||
|
||||
// Error handler
|
||||
app.use((err, _req, res, _next) => {
|
||||
console.error('[Server Error]', err.message)
|
||||
res.status(500).json({ error: 'Interner Serverfehler.' })
|
||||
})
|
||||
|
||||
app.listen(PORT, () => {
|
||||
console.log(`[andreknie.de Backend] Running on port ${PORT}`)
|
||||
})
|
||||
Reference in New Issue
Block a user