-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.ts
More file actions
38 lines (29 loc) · 958 Bytes
/
index.ts
File metadata and controls
38 lines (29 loc) · 958 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
import express, { Request, Response } from 'express';
import dotenv from 'dotenv';
import userRoutes from './routes/user-routes';
import authRoutes from './routes/auth-routes';
import ddlRoutes from './routes/ddl-routes';
import { sequelize } from './config/database';
sequelize
.sync({ force: true })
.then(async () => {
console.log('Database synchronized successfully.');
})
.catch((err) => {
console.error('Failed to synchronize database:', err);
});
dotenv.config();
const app = express();
const PORT = process.env.PORT || 3000;
app.use(express.json());
const apiRouter = express.Router();
apiRouter.use('/auth', authRoutes);
apiRouter.use('/users', userRoutes);
apiRouter.use('/migrate', ddlRoutes);
app.use('/api', apiRouter);
app.get('/health', (req: Request, res: Response) => {
res.send('Hello, TypeScript with Express!');
});
app.listen(PORT, () => {
console.log(`Server is running on http://localhost:${PORT}`);
});