Skip to content

Commit b520e92

Browse files
committed
fix: error connecting to the server
1 parent 853979e commit b520e92

File tree

3 files changed

+95
-105
lines changed

3 files changed

+95
-105
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
node_modules/
22

3+
.mastra
34

45
dist/
56

src/app.ts

Lines changed: 9 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -11,34 +11,23 @@ const app = express();
1111
app.use(express.json());
1212
app.use(requestLogger);
1313

14-
// Unified CORS configuration
15-
const corsOptions = {
16-
origin:
17-
process.env.NODE_ENV === "development"
18-
? ["http://localhost:3000"]
19-
: ["https://telex.im"],
20-
methods: ["GET", "POST", "PUT", "DELETE", "OPTIONS"],
21-
allowedHeaders: ["Content-Type", "Authorization"],
22-
exposedHeaders: ["Content-Length", "X-Requested-With"],
23-
credentials: false,
24-
maxAge: 3600,
25-
};
26-
27-
app.use(cors(corsOptions));
14+
app.use(
15+
cors({
16+
origin: "https://telex.im",
17+
methods: ["GET", "POST"],
18+
allowedHeaders: ["Content-Type"],
19+
})
20+
);
2821

2922
// Export the CORS options for use in other parts of the application
30-
export { corsOptions };
3123

24+
app.use(cors());
3225
app.use("/api", errorRoutes);
3326
app.use(integrationRoutes);
3427
app.use(tickRoute);
3528

3629
app.get("/health", (_req, res) => {
37-
res.json({
38-
status: "running",
39-
timestamp: new Date().toISOString(),
40-
version: process.env.npm_package_version || "1.0.0",
41-
});
30+
res.json({ status: "running", timestamp: new Date().toISOString() });
4231
});
4332

4433
export default app;

src/routes/integrations.ts

Lines changed: 85 additions & 85 deletions
Original file line numberDiff line numberDiff line change
@@ -1,80 +1,9 @@
1-
// import { Router, Request, Response } from "express";
2-
// import { ENV_CONFIG } from "../utils/envConfig";
3-
4-
// const router = Router();
5-
6-
// router.get("/integration-json", (req: Request, res: Response) => {
7-
// const integrationData = {
8-
// data: {
9-
// date: {
10-
// created_at: "2025-02-20 22:25:37",
11-
// updated_at: "2025-02-20 22:25:37",
12-
// },
13-
// descriptions: {
14-
// app_description:
15-
// "Analyzes your codebase for static errors and reports them to Telex channels with prioritized error classification.",
16-
// app_logo: "https://example.com/path-to-code-error-agent-logo.png",
17-
// app_name: "Code Error Agent",
18-
// app_url: ENV_CONFIG.SERVER_URL,
19-
// background_color: "#FF4444",
20-
// },
21-
// integration_category: "AI & Machine Learning",
22-
// integration_type: "interval",
23-
// is_active: true,
24-
// output: [
25-
// {
26-
// label: "error_notifications",
27-
// value: true,
28-
// },
29-
// ],
30-
// key_features: [
31-
// "Static code error detection using ESLint",
32-
// "Prioritized error classification (High, Medium, Low)",
33-
// "Automated error reporting to Telex channels",
34-
// "Configurable analysis intervals",
35-
// "Integration with development pipelines",
36-
// ],
37-
// settings: [
38-
// {
39-
// label: "codeBasePath",
40-
// type: "text",
41-
// required: true,
42-
// default: process.env.CODE_BASE_PATH || "./src",
43-
// },
44-
// {
45-
// label: "errorThreshold",
46-
// type: "text",
47-
// required: true,
48-
// default: "1",
49-
// },
50-
// {
51-
// label: "interval",
52-
// type: "text",
53-
// required: true,
54-
// default: "*/15 * * * *",
55-
// },
56-
// ],
57-
// tick_url: `${ENV_CONFIG.SERVER_URL}/tick`,
58-
// target_url: `${ENV_CONFIG.SERVER_URL}/webhook`,
59-
// },
60-
// };
61-
62-
// res.json(integrationData);
63-
// });
64-
65-
// export default router;
66-
671
import { Router, Request, Response } from "express";
68-
import { ENV_CONFIG } from "../utils/envConfig.js";
2+
import { ENV_CONFIG } from "../utils/envConfig";
693

704
const router = Router();
715

726
router.get("/integration-json", (req: Request, res: Response) => {
73-
// Get the host from the request headers
74-
const host = req.get("host");
75-
const protocol = req.protocol;
76-
const baseUrl = `${protocol}://${host}`;
77-
787
const integrationData = {
798
data: {
809
date: {
@@ -86,7 +15,7 @@ router.get("/integration-json", (req: Request, res: Response) => {
8615
"Analyzes your codebase for static errors and reports them to Telex channels with prioritized error classification.",
8716
app_logo: "https://example.com/path-to-code-error-agent-logo.png",
8817
app_name: "Code Error Agent",
89-
app_url: baseUrl,
18+
app_url: ENV_CONFIG.SERVER_URL,
9019
background_color: "#FF4444",
9120
},
9221
integration_category: "AI & Machine Learning",
@@ -125,23 +54,94 @@ router.get("/integration-json", (req: Request, res: Response) => {
12554
default: "*/15 * * * *",
12655
},
12756
],
128-
// Use the ngrok URL for these endpoints
129-
tick_url: `${baseUrl}/code-error-integration/tick`,
130-
target_url: `${baseUrl}/code-error-integration/webhook`,
57+
tick_url: `${ENV_CONFIG.SERVER_URL}/tick`,
58+
target_url: `${ENV_CONFIG.SERVER_URL}/webhook`,
13159
},
13260
};
13361

13462
res.json(integrationData);
13563
});
13664

137-
// Add webhook handler
138-
router.post("/webhook", (req: Request, res: Response) => {
139-
// console.log("=== WEBHOOK RECEIVED ===");
140-
// console.log("Headers:", req.headers);
141-
// console.log("Body:", req.body);
142-
// console.log("=====================");
65+
export default router;
14366

144-
res.status(200).json({ status: "success" });
145-
});
67+
// import { Router, Request, Response } from "express";
68+
// import { ENV_CONFIG } from "../utils/envConfig.js";
14669

147-
export default router;
70+
// const router = Router();
71+
72+
// router.get("/integration-json", (req: Request, res: Response) => {
73+
// // Get the host from the request headers
74+
// const host = req.get("host");
75+
// const protocol = req.protocol;
76+
// const baseUrl = `${protocol}://${host}`;
77+
78+
// const integrationData = {
79+
// data: {
80+
// date: {
81+
// created_at: "2025-02-20 22:25:37",
82+
// updated_at: "2025-02-20 22:25:37",
83+
// },
84+
// descriptions: {
85+
// app_description:
86+
// "Analyzes your codebase for static errors and reports them to Telex channels with prioritized error classification.",
87+
// app_logo: "https://example.com/path-to-code-error-agent-logo.png",
88+
// app_name: "Code Error Agent",
89+
// app_url: baseUrl,
90+
// background_color: "#FF4444",
91+
// },
92+
// integration_category: "AI & Machine Learning",
93+
// integration_type: "interval",
94+
// is_active: true,
95+
// output: [
96+
// {
97+
// label: "error_notifications",
98+
// value: true,
99+
// },
100+
// ],
101+
// key_features: [
102+
// "Static code error detection using ESLint",
103+
// "Prioritized error classification (High, Medium, Low)",
104+
// "Automated error reporting to Telex channels",
105+
// "Configurable analysis intervals",
106+
// "Integration with development pipelines",
107+
// ],
108+
// settings: [
109+
// {
110+
// label: "codeBasePath",
111+
// type: "text",
112+
// required: true,
113+
// default: process.env.CODE_BASE_PATH || "./src",
114+
// },
115+
// {
116+
// label: "errorThreshold",
117+
// type: "text",
118+
// required: true,
119+
// default: "1",
120+
// },
121+
// {
122+
// label: "interval",
123+
// type: "text",
124+
// required: true,
125+
// default: "*/15 * * * *",
126+
// },
127+
// ],
128+
// // Use the ngrok URL for these endpoints
129+
// tick_url: `${baseUrl}/code-error-integration/tick`,
130+
// target_url: `${baseUrl}/code-error-integration/webhook`,
131+
// },
132+
// };
133+
134+
// res.json(integrationData);
135+
// });
136+
137+
// // Add webhook handler
138+
// // router.post("/webhook", (req: Request, res: Response) => {
139+
// // // console.log("=== WEBHOOK RECEIVED ===");
140+
// // // console.log("Headers:", req.headers);
141+
// // // console.log("Body:", req.body);
142+
// // // console.log("=====================");
143+
144+
// // res.status(200).json({ status: "success" });
145+
// // });
146+
147+
// export default router;

0 commit comments

Comments
 (0)