28 lines
642 B
TypeScript
28 lines
642 B
TypeScript
import 'dotenv/config';
|
|
import express from 'express';
|
|
|
|
import authRoutes from './routes/auth';
|
|
import videosRoutes from './routes/videos';
|
|
|
|
const app = express();
|
|
|
|
app.use(express.json());
|
|
|
|
app.get('/', (_req, res) => {
|
|
res.send('API is running');
|
|
});
|
|
|
|
app.use('/auth', authRoutes);
|
|
app.use('/videos', videosRoutes);
|
|
|
|
app.use((err: unknown, _req: express.Request, res: express.Response, _next: express.NextFunction) => {
|
|
console.error(err);
|
|
res.status(500).json({ message: 'Internal server error' });
|
|
});
|
|
|
|
const port = Number(process.env.PORT ?? 3000);
|
|
|
|
app.listen(port, () => {
|
|
console.log(`Server is running on port ${port}`);
|
|
});
|