-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.js
More file actions
36 lines (27 loc) · 1.03 KB
/
app.js
File metadata and controls
36 lines (27 loc) · 1.03 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
import express from "express";
import { PORT } from './config/env.js' ;
import userRouter from "./routes/user.router.js";
import authRouter from "./routes/auth.routes.js";
import subscriptionRouter from "./routes/subscription.route.js";
import connectToDatabase from "./database/mongodb.js";
import errorMiddleware from "./middleware/error.middleware.js";
import cookieParser from "cookie-parser";
import arcjetMiddleware from "./middleware/arcjet.middleware.js";
const app = express();
app.use(express.json());
app.use(express.urlencoded({ extended: false }));
app.use(cookieParser());
app.use(arcjetMiddleware);
// Routes
app.use("/api/auth" , authRouter);
app.use("/api/users" , userRouter);
app.use("/api/subscriptions" , subscriptionRouter);
app.use(errorMiddleware);
app.get("/" , function(req,res){
res.send({body:"Welcome to Subscription Tracker API"});
});
app.listen(PORT , ()=>{
console.log(`Server running on http://localhost:${PORT} ` );
connectToDatabase() ;
});
export default app ;