feat(auth): add user schema and auth api
This commit is contained in:
+33
@@ -0,0 +1,33 @@
|
||||
import express from 'express';
|
||||
import cors from 'cors';
|
||||
import helmet from 'helmet';
|
||||
import cookieParser from 'cookie-parser';
|
||||
import morgan from 'morgan';
|
||||
import routes from './routes/index.js';
|
||||
|
||||
const app = express();
|
||||
|
||||
app.use(
|
||||
cors({
|
||||
origin: process.env.CLIENT_URL || 'http://localhost:5173',
|
||||
credentials: true,
|
||||
})
|
||||
);
|
||||
app.use(helmet());
|
||||
app.use(express.json({ limit: '2mb' }));
|
||||
app.use(cookieParser());
|
||||
app.use(morgan(process.env.NODE_ENV === 'production' ? 'combined' : 'dev'));
|
||||
app.use('/api', routes);
|
||||
|
||||
app.use((req, res) => {
|
||||
res.status(404).json({ success: false, message: 'Route not found' });
|
||||
});
|
||||
|
||||
app.use((err, req, res, next) => {
|
||||
const status = err.status || 500;
|
||||
res
|
||||
.status(status)
|
||||
.json({ success: false, message: err.message || 'Server error' });
|
||||
});
|
||||
|
||||
export default app;
|
||||
Reference in New Issue
Block a user