feat: add Express API base structure
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
31
apps/api/src/app.ts
Normal file
31
apps/api/src/app.ts
Normal file
@@ -0,0 +1,31 @@
|
||||
import express from 'express';
|
||||
import cors from 'cors';
|
||||
import helmet from 'helmet';
|
||||
import { env } from './config/env.js';
|
||||
import { errorMiddleware } from './middlewares/error.middleware.js';
|
||||
|
||||
const app = express();
|
||||
|
||||
// Security
|
||||
app.use(helmet());
|
||||
app.use(cors({
|
||||
origin: env.CORS_ORIGIN,
|
||||
credentials: true,
|
||||
}));
|
||||
|
||||
// Body parsing
|
||||
app.use(express.json());
|
||||
app.use(express.urlencoded({ extended: true }));
|
||||
|
||||
// Health check
|
||||
app.get('/health', (req, res) => {
|
||||
res.json({ status: 'ok', timestamp: new Date().toISOString() });
|
||||
});
|
||||
|
||||
// API Routes (to be added)
|
||||
// app.use('/api/auth', authRoutes);
|
||||
|
||||
// Error handling
|
||||
app.use(errorMiddleware);
|
||||
|
||||
export { app };
|
||||
Reference in New Issue
Block a user