VISHAL18for4 commited on
Commit
8d16d20
Β·
verified Β·
1 Parent(s): 2c4fdae

Update server.js

Browse files
Files changed (1) hide show
  1. server.js +20 -5
server.js CHANGED
@@ -68,7 +68,22 @@ app.get('/snapshots/:filename', (req, res) => {
68
  });
69
 
70
  // ============================================================
71
- // 5. POST /api/snapshot – Save New Snapshot
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
72
  // ============================================================
73
  app.post('/api/snapshot', (req, res) => {
74
  try {
@@ -121,7 +136,7 @@ app.post('/api/snapshot', (req, res) => {
121
  });
122
 
123
  // ============================================================
124
- // 6. GET /api/snapshots/list – List All Snapshots (for Admin)
125
  // ============================================================
126
  app.get('/api/snapshots/list', (req, res) => {
127
  try {
@@ -138,7 +153,7 @@ app.get('/api/snapshots/list', (req, res) => {
138
  });
139
 
140
  // ============================================================
141
- // 7. DELETE /api/snapshots/:filename – Delete a Snapshot
142
  // ============================================================
143
  app.delete('/api/snapshots/:filename', (req, res) => {
144
  const filename = req.params.filename;
@@ -163,14 +178,14 @@ app.delete('/api/snapshots/:filename', (req, res) => {
163
  });
164
 
165
  // ============================================================
166
- // 8. Health Check
167
  // ============================================================
168
  app.get('/health', (req, res) => {
169
  res.status(200).send('OK');
170
  });
171
 
172
  // ============================================================
173
- // 9. Start Server
174
  // ============================================================
175
  app.listen(PORT, () => {
176
  console.log(`[SERVER] Running on port ${PORT}`);
 
68
  });
69
 
70
  // ============================================================
71
+ // 5. POST /api/log – Receive frontend logs and print to container
72
+ // ============================================================
73
+ app.post('/api/log', (req, res) => {
74
+ try {
75
+ const { message, level = 'info', timestamp } = req.body;
76
+ const logMsg = `[Frontend ${level}] ${timestamp || new Date().toISOString()} ${message || ''}`;
77
+ console.log(logMsg);
78
+ res.status(200).json({ success: true });
79
+ } catch (err) {
80
+ console.error('[SERVER] Log error:', err);
81
+ res.status(500).json({ success: false, error: err.message });
82
+ }
83
+ });
84
+
85
+ // ============================================================
86
+ // 6. POST /api/snapshot – Save New Snapshot
87
  // ============================================================
88
  app.post('/api/snapshot', (req, res) => {
89
  try {
 
136
  });
137
 
138
  // ============================================================
139
+ // 7. GET /api/snapshots/list – List All Snapshots (for Admin)
140
  // ============================================================
141
  app.get('/api/snapshots/list', (req, res) => {
142
  try {
 
153
  });
154
 
155
  // ============================================================
156
+ // 8. DELETE /api/snapshots/:filename – Delete a Snapshot
157
  // ============================================================
158
  app.delete('/api/snapshots/:filename', (req, res) => {
159
  const filename = req.params.filename;
 
178
  });
179
 
180
  // ============================================================
181
+ // 9. Health Check
182
  // ============================================================
183
  app.get('/health', (req, res) => {
184
  res.status(200).send('OK');
185
  });
186
 
187
  // ============================================================
188
+ // 10. Start Server
189
  // ============================================================
190
  app.listen(PORT, () => {
191
  console.log(`[SERVER] Running on port ${PORT}`);