instaserve 1.1.8 → 1.1.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/module.mjs +3 -1
- package/package.json +1 -1
- package/test.js +0 -28
package/module.mjs
CHANGED
|
@@ -62,7 +62,9 @@ export default async function (routes, port = params.port || 3000, ip = params.i
|
|
|
62
62
|
s.writeHead(result)
|
|
63
63
|
s.end()
|
|
64
64
|
} else {
|
|
65
|
-
|
|
65
|
+
if (result != "SSE") {
|
|
66
|
+
s.end(typeof result === 'string' ? result : JSON.stringify(result))
|
|
67
|
+
}
|
|
66
68
|
}
|
|
67
69
|
}
|
|
68
70
|
|
package/package.json
CHANGED
package/test.js
DELETED
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
export default {
|
|
2
|
-
// Middleware functions (prefixed with _) run on every request
|
|
3
|
-
// Return false to continue processing, or a value to use as response
|
|
4
|
-
|
|
5
|
-
// Example: Log all requests
|
|
6
|
-
_log: (req, res, data) => {
|
|
7
|
-
console.log(`${req.method} ${req.url}`)
|
|
8
|
-
return false // Continue to next middleware or route
|
|
9
|
-
},
|
|
10
|
-
|
|
11
|
-
// Example: Basic authentication (commented out)
|
|
12
|
-
// _auth: (req, res, data) => {
|
|
13
|
-
// if (!data.token) {
|
|
14
|
-
// res.writeHead(401)
|
|
15
|
-
// return 'Unauthorized'
|
|
16
|
-
// }
|
|
17
|
-
// return false // Continue if authorized
|
|
18
|
-
// },
|
|
19
|
-
|
|
20
|
-
// Regular route handlers
|
|
21
|
-
hello: (req, res, data) => {
|
|
22
|
-
return { message: 'Hello World' }
|
|
23
|
-
},
|
|
24
|
-
|
|
25
|
-
api: (req, res, data) => {
|
|
26
|
-
return { message: 'API endpoint', data }
|
|
27
|
-
}
|
|
28
|
-
}
|