feat: add authentication routes, update environment variables, and enhance error handling
This commit is contained in:
@@ -1,11 +1,25 @@
|
||||
import 'dotenv/config';
|
||||
import express from 'express';
|
||||
|
||||
import authRoutes from './routes/auth';
|
||||
|
||||
const app = express();
|
||||
|
||||
app.get('/', (req, res) => {
|
||||
res.send('Hello World');
|
||||
app.use(express.json());
|
||||
|
||||
app.get('/', (_req, res) => {
|
||||
res.send('API is running');
|
||||
});
|
||||
|
||||
app.listen(3000, () => {
|
||||
console.log('Server is running on port 3000');
|
||||
app.use('/auth', authRoutes);
|
||||
|
||||
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}`);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user