Skip to content

Commit

Permalink
Request cannot be tested with util.emptyObj
Browse files Browse the repository at this point in the history
  • Loading branch information
ignoramous committed Jan 23, 2022
1 parent 465223d commit e3deac7
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
8 changes: 4 additions & 4 deletions src/core/deno/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ import EnvManager from "../env.js";

// In global scope.
declare global {
// TypeScript compiler needs to know type of every variable / property.
// So, we extend the window object (globalThis) with declaration merging.
// See: https://www.typescriptlang.org/docs/handbook/declaration-merging.html
// TypeScript must know type of every var / property. Extend Window
// (globalThis) with declaration merging (archive.is/YUWh2) to define types
// Ref: www.typescriptlang.org/docs/handbook/declaration-merging.html
interface Window {
envManager?: EnvManager;
log?: Log;
Expand Down Expand Up @@ -44,7 +44,7 @@ function setup() {

window.log = new Log(
window.env.logLevel,
isProd, // set console level only in prod.
isProd // set console level only in prod.
);

system.pub("ready");
Expand Down
3 changes: 2 additions & 1 deletion src/server-deno.ts
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,8 @@ async function resolveQuery(q: Uint8Array) {
}

function mkFetchEvent(r: Request, ...fns: Function[]) {
if (util.emptyObj(r)) throw new Error("missing request");
// just like with URL objs, util.emptyObj does not work for Request
if (!r) throw new Error("missing request");

// deno.land/manual/runtime/http_server_apis#http-requests-and-responses
// a service-worker event, with properties: type and request; and methods:
Expand Down

0 comments on commit e3deac7

Please sign in to comment.