@server/next 0.20.39 → 0.20.41
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/package.json +1 -1
- package/src/helpers/getMachine.js +12 -15
- package/src/helpers/handleRequest.js +3 -1
- package/src/index.js +1 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@server/next",
|
|
3
|
-
"version": "0.20.
|
|
3
|
+
"version": "0.20.41",
|
|
4
4
|
"description": "A fully-fledged web server with routing, file uploads, sessions, static files, schema validation, websockets, testing, etc.",
|
|
5
5
|
"homepage": "https://server-js.com/",
|
|
6
6
|
"repository": "https://github.com/franciscop/server-next.git",
|
|
@@ -1,29 +1,26 @@
|
|
|
1
1
|
function getProvider() {
|
|
2
|
-
if (
|
|
3
|
-
return null;
|
|
4
|
-
}
|
|
5
|
-
|
|
6
|
-
function getService() {
|
|
2
|
+
if (typeof Netlify !== "undefined") return "netlify";
|
|
7
3
|
return null;
|
|
8
4
|
}
|
|
9
5
|
|
|
10
6
|
function getRuntime() {
|
|
11
|
-
if (
|
|
12
|
-
if (
|
|
7
|
+
if (typeof Bun !== "undefined") return "bun";
|
|
8
|
+
if (typeof Deno !== "undefined") return "deno";
|
|
13
9
|
if (globalThis.process?.versions?.node) return "node";
|
|
14
10
|
return null;
|
|
15
11
|
}
|
|
16
12
|
|
|
13
|
+
function getProduction() {
|
|
14
|
+
// Can I cry now?
|
|
15
|
+
if (typeof Netlify !== "undefined")
|
|
16
|
+
return Netlify.env.get("NETLIFY_DEV") !== "true";
|
|
17
|
+
return process.env.NODE_ENV === "production";
|
|
18
|
+
}
|
|
19
|
+
|
|
17
20
|
export default function getMachine() {
|
|
18
|
-
const provider = getProvider();
|
|
19
21
|
return {
|
|
20
|
-
provider,
|
|
21
|
-
service: getService(),
|
|
22
|
+
provider: getProvider(),
|
|
22
23
|
runtime: getRuntime(),
|
|
23
|
-
|
|
24
|
-
production:
|
|
25
|
-
provider === "netlify"
|
|
26
|
-
? Netlify.env.get("NETLIFY_DEV") !== "true"
|
|
27
|
-
: process.env.NODE_ENV === "production",
|
|
24
|
+
production: getProduction(),
|
|
28
25
|
};
|
|
29
26
|
}
|
|
@@ -41,7 +41,9 @@ export default async function handleRequest(handlers, ctx) {
|
|
|
41
41
|
// the edge function to just go ahead and consume the original resource. But
|
|
42
42
|
// we have already "consumed" the resource, so we can only return the next one
|
|
43
43
|
if (ctx.machine.provider === "netlify") {
|
|
44
|
-
|
|
44
|
+
const response = await ctx.req.context.next();
|
|
45
|
+
console.log(response instanceof Response, response);
|
|
46
|
+
return response;
|
|
45
47
|
}
|
|
46
48
|
|
|
47
49
|
// In other environments, a non-response is wrong and we should 404 then
|
package/src/index.js
CHANGED
|
@@ -105,6 +105,7 @@ server.prototype.node = async function () {
|
|
|
105
105
|
|
|
106
106
|
// Netlify
|
|
107
107
|
server.prototype.callback = async function (request, context) {
|
|
108
|
+
// Consider simply renaming to "ctx.next()"
|
|
108
109
|
request.context = context;
|
|
109
110
|
try {
|
|
110
111
|
if (typeof Netlify === "undefined") {
|