Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@remix-run/deno

Package Overview
Dependencies
Maintainers
2
Versions
922
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@remix-run/deno - npm Package Compare versions

Comparing version 0.0.0-experimental-bb4495f3 to 0.0.0-experimental-e0ead3bf

magicExports/esm/platform.js

2

cookieSigning.js
/**
* @remix-run/deno v0.0.0-experimental-bb4495f3
* @remix-run/deno v0.0.0-experimental-e0ead3bf
*

@@ -4,0 +4,0 @@ * Copyright (c) Remix Software Inc.

@@ -0,1 +1,10 @@

declare global {
interface ProcessEnv {
NODE_ENV: "development" | "production" | "test";
}
interface Process {
env: ProcessEnv;
}
var process: Process;
}
export declare function installGlobals(): void;
/**
* @remix-run/deno v0.0.0-experimental-bb4495f3
* @remix-run/deno v0.0.0-experimental-e0ead3bf
*

@@ -4,0 +4,0 @@ * Copyright (c) Remix Software Inc.

@@ -1,1 +0,2 @@

export { createRequestHandlerWithStaticFiles } from "./server";
export { createRequestHandler, createRequestHandlerWithStaticFiles, serveStaticFiles } from "./server";
export { createFileSessionStorage } from "./sessions/fileStorage";
/**
* @remix-run/deno v0.0.0-experimental-bb4495f3
* @remix-run/deno v0.0.0-experimental-e0ead3bf
*

@@ -12,4 +12,5 @@ * Copyright (c) Remix Software Inc.

import { installGlobals } from './globals.js';
export { createRequestHandlerWithStaticFiles } from './server.js';
export { createRequestHandler, createRequestHandlerWithStaticFiles, serveStaticFiles } from './server.js';
export { createFileSessionStorage } from './sessions/fileStorage.js';
installGlobals();
{
"name": "@remix-run/deno",
"description": "Deno platform abstractions for Remix",
"version": "0.0.0-experimental-bb4495f3",
"version": "0.0.0-experimental-e0ead3bf",
"license": "MIT",

@@ -17,3 +17,3 @@ "module": "./index.js",

"dependencies": {
"@remix-run/server-runtime": "0.0.0-experimental-bb4495f3",
"@remix-run/server-runtime": "0.0.0-experimental-e0ead3bf",
"mime": "^3.0.0"

@@ -20,0 +20,0 @@ },

import type { ServerBuild } from "@remix-run/server-runtime";
export declare function defaultCacheControl(url: URL): "public, max-age=31536000, immutable" | "public, max-age=600";
export declare function createRequestHandlerWithStaticFiles({ build, mode, staticFiles: { cacheControl, publicDir } }: {
export declare function createRequestHandler<Context = unknown>({ build, mode, getLoadContext }: {
build: ServerBuild;
mode?: string;
getLoadContext?: (request: Request) => Promise<Context> | Context;
}): (request: Request) => Promise<Response>;
export declare function serveStaticFiles(request: Request, { cacheControl, publicDir, assetsPublicPath }: {
cacheControl?: string | ((url: URL) => string);
publicDir?: string;
assetsPublicPath?: string;
}): Promise<Response>;
export declare function createRequestHandlerWithStaticFiles<Context = unknown>({ build, mode, getLoadContext, staticFiles }: {
build: ServerBuild;
mode?: string;
getLoadContext?: (request: Request) => Promise<Context> | Context;
staticFiles?: {
cacheControl?: string | ((url: URL) => string);
publicDir?: string;
assetsPublicPath?: string;
};
}): (request: Request) => Promise<Response>;
/**
* @remix-run/deno v0.0.0-experimental-bb4495f3
* @remix-run/deno v0.0.0-experimental-e0ead3bf
*

@@ -11,7 +11,8 @@ * Copyright (c) Remix Software Inc.

*/
import { createRequestHandler } from '@remix-run/server-runtime';
import mime from 'mime';
import { createRequestHandler as createRequestHandler$1 } from '@remix-run/server-runtime';
import * as path from 'https://deno.land/std/path/mod.ts';
import { getType } from 'mime';
function defaultCacheControl(url) {
if (url.pathname.startsWith("/build/")) {
function defaultCacheControl(url, assetsPublicPath = "/build/") {
if (url.pathname.startsWith(assetsPublicPath)) {
return "public, max-age=31536000, immutable";

@@ -22,46 +23,14 @@ } else {

}
function createRequestHandlerWithStaticFiles({
function createRequestHandler({
build,
mode,
staticFiles: {
cacheControl,
publicDir
} = {
cacheControl: defaultCacheControl,
publicDir: "./public"
}
getLoadContext
}) {
let remixHandler = createRequestHandler(build, {}, mode);
let remixHandler = createRequestHandler$1(build, {}, mode);
return async request => {
try {
const url = new URL(request.url);
const headers = new Headers();
const contentType = mime.getType(url.pathname);
if (contentType) {
headers.set("Content-Type", contentType);
}
if (typeof cacheControl === "function") {
headers.set("Cache-Control", cacheControl(url));
} else if (cacheControl) {
headers.set("Cache-Control", cacheControl);
} else {
headers.set("Cache-Control", defaultCacheControl(url));
} // @ts-expect-error
const file = await Deno.readFile(`${publicDir || "./public"}${url.pathname}`);
return new Response(file, {
headers
});
let loadContext = getLoadContext ? await getLoadContext(request) : undefined;
return await remixHandler(request, loadContext);
} catch (e) {
if (e.code !== "EISDIR" && e.code !== "ENOENT") {
throw e;
}
}
try {
return await remixHandler(request);
} catch (e) {
console.error(e);

@@ -74,3 +43,55 @@ return new Response("Internal Error", {

}
async function serveStaticFiles(request, {
cacheControl,
publicDir = "./public",
assetsPublicPath = "/build/"
}) {
let url = new URL(request.url);
let headers = new Headers();
let contentType = getType(url.pathname);
export { createRequestHandlerWithStaticFiles, defaultCacheControl };
if (contentType) {
headers.set("Content-Type", contentType);
}
if (typeof cacheControl === "function") {
headers.set("Cache-Control", cacheControl(url));
} else if (cacheControl) {
headers.set("Cache-Control", cacheControl);
} else {
headers.set("Cache-Control", defaultCacheControl(url, assetsPublicPath));
}
let file = await Deno.readFile(path.join(publicDir, url.pathname));
return new Response(file, {
headers
});
}
function createRequestHandlerWithStaticFiles({
build,
mode,
getLoadContext,
staticFiles = {
publicDir: "./public",
assetsPublicPath: "/build/"
}
}) {
let remixHandler = createRequestHandler({
build,
mode,
getLoadContext
});
return async request => {
try {
return await serveStaticFiles(request, staticFiles);
} catch (error) {
if (error.code !== "EISDIR" && error.code !== "ENOENT") {
throw error;
}
}
return remixHandler(request);
};
}
export { createRequestHandler, createRequestHandlerWithStaticFiles, serveStaticFiles };
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc