-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest-server.js
More file actions
38 lines (31 loc) · 1.04 KB
/
Copy pathtest-server.js
File metadata and controls
38 lines (31 loc) · 1.04 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
// Simple test to verify the server starts
const express = require('express');
const SnipLog = require('./src/node');
console.log('1. Loading Express...');
const app = express();
app.use(express.json());
console.log('2. Creating SnipLog instance...');
const sniplog = new SnipLog({
endpoint: 'http://localhost:3001/api/errors',
projectKey: 'dev-project-key',
autoCaptureExceptions: false, // Disable for testing
timeout: 5000
});
console.log('3. Adding middleware...');
app.use(sniplog.requestMiddleware());
console.log('4. Adding routes...');
app.get('/', (req, res) => {
res.json({ message: 'Test app running!' });
});
app.get('/test', (req, res) => {
req.sniplog.captureMessage('Test endpoint hit');
res.json({ status: 'ok' });
});
console.log('5. Adding error middleware...');
app.use(sniplog.errorMiddleware());
console.log('6. Starting server...');
const PORT = 4000;
app.listen(PORT, () => {
console.log(`✓ Server started successfully on http://localhost:${PORT}`);
console.log('Test with: curl http://localhost:4000/');
});