2023-09-02 12:13:50 +00:00
|
|
|
import 'dotenv/config';
|
2023-08-31 13:17:57 +00:00
|
|
|
import express from 'express';
|
|
|
|
import ViteExpress from 'vite-express';
|
2023-09-02 14:53:57 +00:00
|
|
|
import compression from 'compression';
|
|
|
|
import { userRouter } from './router/user';
|
2023-08-31 13:17:57 +00:00
|
|
|
|
|
|
|
const app = express();
|
|
|
|
|
2023-09-02 14:53:57 +00:00
|
|
|
app.use(compression());
|
|
|
|
app.use(express.json());
|
|
|
|
|
|
|
|
// http://expressjs.com/en/advanced/best-practice-security.html#at-a-minimum-disable-x-powered-by-header
|
|
|
|
app.disable('x-powered-by');
|
|
|
|
|
|
|
|
app.use('/api/user', userRouter);
|
|
|
|
|
|
|
|
app.use((err: any, req: any, res: any, next: any) => {
|
|
|
|
res.status(500);
|
|
|
|
res.json({ error: err.message });
|
2023-08-31 13:17:57 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
ViteExpress.listen(app, 3000, () => {
|
|
|
|
console.log('Server is listening on port 3000...');
|
|
|
|
console.log('Website: http://localhost:3000');
|
|
|
|
});
|