@server/next 0.20.29 → 0.20.31

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@server/next",
3
- "version": "0.20.29",
3
+ "version": "0.20.31",
4
4
  "description": "An experimental reimplementation of server.js focused on the DX",
5
5
  "homepage": "https://node-server.com/",
6
6
  "repository": "https://github.com/franciscop/server-next.git",
package/src/index.js CHANGED
@@ -168,10 +168,14 @@ export default function server(options = {}) {
168
168
  };
169
169
 
170
170
  this.netlify = async (request) => {
171
- if (typeof Netlify === "undefined") throw new Error("Unknown");
172
- console.log("Experimental Netlify");
173
171
  try {
174
- options = validateOptions(options, Netlify.env.toObject());
172
+ if (typeof Netlify === "undefined") {
173
+ throw new Error("Netlify doesn't exist");
174
+ }
175
+ if (typeof import.meta === "undefined") {
176
+ throw new Error("import.meta.env doesn't exist");
177
+ }
178
+ options = validateOptions(options, import.meta.env);
175
179
  const ctx = await createWinterContext(request, options, this);
176
180
  extendWithDefaults(ctx);
177
181
  return await handleRequest(this.handlers, ctx);
package/src/polyfill.js CHANGED
@@ -1,26 +1,12 @@
1
- const self =
2
- typeof globalThis !== "undefined"
3
- ? globalThis
4
- : typeof global !== "undefined"
5
- ? global
6
- : typeof window !== "undefined"
7
- ? window
8
- : null;
9
-
10
1
  // out = new Response(out, { headers: { "content-type": type } });
11
2
  if (typeof Response === "undefined") {
12
- self.Response = function Response(body, other = {}) {
3
+ global.Response = function Response(body, other = {}) {
13
4
  return { body, ...other };
14
5
  };
15
6
  }
16
7
 
17
8
  // Polyfill Netlify's environment variables
18
- if (typeof Netlify !== "undefined") {
19
- if (!self.process) {
20
- self.process = {};
21
- }
22
- if (!self.process.env) {
23
- self.process.env = {};
24
- }
25
- Object.assign(self.process.env, Netlify.env.toObject());
9
+ if (typeof Netlify !== "undefined" && typeof import.meta !== "undefined") {
10
+ if (!import.meta.env) import.meta.env = {};
11
+ Object.assign(import.meta.env, Netlify.env.toObject());
26
12
  }