-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.js
More file actions
42 lines (31 loc) · 1.2 KB
/
app.js
File metadata and controls
42 lines (31 loc) · 1.2 KB
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
39
40
41
42
import express, { json, urlencoded } from 'express';
import {PORT} from './config/env.js';
import userRoutes from './routes/users.routes.js';
import authRoutes from './routes/auth.routes.js';
import subscriptionRoutes from './routes/subscription.routes.js';
import connectToDatabase from './database/mongoDB.js';
import errorMiddleware from './middlewares/error.middleware.js';
import cookieParser from 'cookie-parser';
import arcjetMiddleware from './middlewares/arcjet.middleware.js';
import workflowRouter from './routes/Workflow.routes.js';
const app = express();
//basic configs: json, cookies, url, arcjet
app.use(express.json());
app.use(express.urlencoded({extended: false}));
app.use(cookieParser());
app.use(arcjetMiddleware);
//routes
app.use('/api/v1/auth', authRoutes);
app.use('/api/v1/users', userRoutes);
app.use('/api/v1/subscriptions', subscriptionRoutes);
app.use('/api/v1/workflows', workflowRouter);
//middleware created to error handling
app.use(errorMiddleware);
app.get('/', (req, res) => {
res.send("Welcome to the subscriptiontrackerapi");
});
app.listen(PORT, async () => {
console.log(`Server running on http://localhost:${PORT}`);
await connectToDatabase();
})
export default app