-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.js
More file actions
56 lines (36 loc) · 1.51 KB
/
app.js
File metadata and controls
56 lines (36 loc) · 1.51 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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
import express from "express";
import {PORT} from './config/env.js';
import userRouter from "./routes/user.routes.js";
import authRouter from './routes/auth.routes.js';
import subscriptionRouter from './routes/subscription.routes.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";
import workflowRouter from "./routes/workflow.routes.js";
const app=express();
app.use(express.json());
app.use(express.urlencoded({extended:false}));
app.use(cookieParser());
app.use(arcjetMiddleware);
app.use('/api/v1/auth',authRouter);
app.use('/api/v1/users',userRouter);
app.use('/api/v1/subscriptions',subscriptionRouter);
app.use('/api/v1/workflows',workflowRouter);
app.use(errorMiddleware);
app.get('/',(req,res)=>{
res.send('welcome to subscription Tracker API!');
});
app.listen(PORT,async()=>{
console.log(`Subscription-tracker is running on http://localhost:${PORT}`);
await connectToDatabase();
});
export default app;
// 🔧 How to fix for development with Postman
// Since you obviously need to test APIs with Postman (without constantly being blocked), you can:
// ✅ Option 1: Use DRY_RUN in dev
// detectBot({
// mode: "DRY_RUN", // just logs detections, doesn’t block
// allow: ["CATEGORY:SEARCH_ENGINE"], // must not be empty
// }),
// This way, Arcjet will still tell you if it thinks Postman is a bot, but won’t block you.