From bf83669380776f8525cdc988c0be74507150dd12 Mon Sep 17 00:00:00 2001 From: Logan McAnsh Date: Tue, 10 Aug 2021 12:08:07 -0400 Subject: [PATCH 01/68] test(express): add basic test for createRemixRequest Signed-off-by: Logan McAnsh --- packages/remix-express/package.json | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/remix-express/package.json b/packages/remix-express/package.json index 8f1d2cf0ea8..5062bd00ce6 100644 --- a/packages/remix-express/package.json +++ b/packages/remix-express/package.json @@ -17,6 +17,7 @@ "@remix-run/node": "1.6.8" }, "devDependencies": { + "@jest-mock/express": "^1.4.3", "@types/express": "^4.17.9", "@types/supertest": "^2.0.10", "express": "^4.17.1", From 010d5c40f2807df9bdb0bc0c7075985869a58f3d Mon Sep 17 00:00:00 2001 From: Logan McAnsh Date: Tue, 10 Aug 2021 14:18:03 -0400 Subject: [PATCH 02/68] test(architect): add tests for headers Signed-off-by: Logan McAnsh --- packages/remix-architect/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/remix-architect/package.json b/packages/remix-architect/package.json index aa4108e77d2..65b2805035d 100644 --- a/packages/remix-architect/package.json +++ b/packages/remix-architect/package.json @@ -32,4 +32,4 @@ "LICENSE.md", "README.md" ] -} +} \ No newline at end of file From f1f10baecf8af36ff0326b26129f437ae0fe1a22 Mon Sep 17 00:00:00 2001 From: Logan McAnsh Date: Tue, 10 Aug 2021 14:50:43 -0400 Subject: [PATCH 03/68] test(vercel): extract headers conversion function, start adding tests around it Signed-off-by: Logan McAnsh --- packages/remix-vercel/package.json | 2 +- yarn.lock | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/packages/remix-vercel/package.json b/packages/remix-vercel/package.json index a358f91228c..a72691f6ae8 100644 --- a/packages/remix-vercel/package.json +++ b/packages/remix-vercel/package.json @@ -35,4 +35,4 @@ "LICENSE.md", "README.md" ] -} +} \ No newline at end of file diff --git a/yarn.lock b/yarn.lock index fd112c3ee6f..d1e7bf86243 100644 --- a/yarn.lock +++ b/yarn.lock @@ -11834,6 +11834,11 @@ test-exclude@^6.0.0: glob "^7.1.4" minimatch "^3.0.4" +test-listen@^1.1.0: + version "1.1.0" + resolved "https://registry.yarnpkg.com/test-listen/-/test-listen-1.1.0.tgz#2ba614d96c3bc9157469003027b42a495dd83b6a" + integrity sha512-OyEVi981C1sb9NX1xayfgZls3p8QTDRwp06EcgxSgd1kktaENBW8dO15i8v/7Fi15j0IYQctJzk5J+hyEBId2w== + text-table@^0.2.0: version "0.2.0" resolved "https://registry.npmjs.org/text-table/-/text-table-0.2.0.tgz" From 5e64fd330cbbd50ddbb36ac2e430be60f654938d Mon Sep 17 00:00:00 2001 From: Logan McAnsh Date: Tue, 10 Aug 2021 14:57:50 -0400 Subject: [PATCH 04/68] test(vercel): shutdown server after running test Signed-off-by: Logan McAnsh --- packages/remix-vercel/__tests__/server-test.ts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/packages/remix-vercel/__tests__/server-test.ts b/packages/remix-vercel/__tests__/server-test.ts index 4e4e72c246c..acbb2e2c0ec 100644 --- a/packages/remix-vercel/__tests__/server-test.ts +++ b/packages/remix-vercel/__tests__/server-test.ts @@ -41,6 +41,10 @@ function createApp() { return server; } +beforeEach(() => { + consumeEventMock.mockClear(); +}); + describe("vercel createRequestHandler", () => { describe("basic requests", () => { afterEach(async () => { From 70bc39fb5bdcd2096191a3a3b67e74205354836d Mon Sep 17 00:00:00 2001 From: Logan McAnsh Date: Tue, 10 Aug 2021 16:16:47 -0400 Subject: [PATCH 05/68] chore: remove `Object.fromEntries(responseHeaders)` spreading Signed-off-by: Logan McAnsh --- docs/guides/styling.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/docs/guides/styling.md b/docs/guides/styling.md index 263edb2365f..1b8662eea9d 100644 --- a/docs/guides/styling.md +++ b/docs/guides/styling.md @@ -754,6 +754,8 @@ Here's some sample code to show how you might use Styled Components with Remix ( responseHeaders.set("Content-Type", "text/html"); + responseHeaders.set("Content-Type","text/html") + return new Response("" + markup, { status: responseStatusCode, headers: responseHeaders, From 6f8d02ba98d7b1f77e40f19837f2bc1d92f75ac0 Mon Sep 17 00:00:00 2001 From: Logan McAnsh Date: Tue, 10 Aug 2021 19:47:59 -0400 Subject: [PATCH 06/68] test(vercel): add more tests Signed-off-by: Logan McAnsh --- packages/remix-vercel/__tests__/server-test.ts | 4 ---- 1 file changed, 4 deletions(-) diff --git a/packages/remix-vercel/__tests__/server-test.ts b/packages/remix-vercel/__tests__/server-test.ts index acbb2e2c0ec..4e4e72c246c 100644 --- a/packages/remix-vercel/__tests__/server-test.ts +++ b/packages/remix-vercel/__tests__/server-test.ts @@ -41,10 +41,6 @@ function createApp() { return server; } -beforeEach(() => { - consumeEventMock.mockClear(); -}); - describe("vercel createRequestHandler", () => { describe("basic requests", () => { afterEach(async () => { From 10f1b1115abd3191c4ff61997ba65bb70ae11600 Mon Sep 17 00:00:00 2001 From: Logan McAnsh Date: Wed, 11 Aug 2021 16:10:29 -0400 Subject: [PATCH 07/68] test(vercel): add test for createRequestHandler vercel requests are regular http IncomingMessages but with various methods on it to make it more like express, so we'll just treat it like express.. Signed-off-by: Logan McAnsh --- packages/remix-vercel/__tests__/server-test.ts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/packages/remix-vercel/__tests__/server-test.ts b/packages/remix-vercel/__tests__/server-test.ts index 4e4e72c246c..46c3cc3310e 100644 --- a/packages/remix-vercel/__tests__/server-test.ts +++ b/packages/remix-vercel/__tests__/server-test.ts @@ -271,7 +271,11 @@ describe("vercel createRemixRequest", () => { "method": "GET", "parsedURL": "http://localhost:3000/foo/bar", "redirect": "follow", +<<<<<<< HEAD "signal": AbortSignal {}, +======= + "signal": null, +>>>>>>> 739084c6 (test(vercel): add test for createRequestHandler) }, } `); From e19177bb89f0d08909aee4e7f1501e4c2a273810 Mon Sep 17 00:00:00 2001 From: Logan McAnsh Date: Wed, 11 Aug 2021 21:41:10 -0400 Subject: [PATCH 08/68] test(vercel): use supertest for better header testing Signed-off-by: Logan McAnsh --- yarn.lock | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/yarn.lock b/yarn.lock index d1e7bf86243..cbae33c9b0b 100644 --- a/yarn.lock +++ b/yarn.lock @@ -11724,6 +11724,14 @@ supertest@^6.1.5: methods "^1.1.2" superagent "^6.1.0" +supertest@^6.1.5: + version "6.1.5" + resolved "https://registry.yarnpkg.com/supertest/-/supertest-6.1.5.tgz#b011c8465281b30c64e9d4be4cb3808b91cd1ec0" + integrity sha512-Is3pFB2TxSFPohDS2tIM8h2JOMvUQwbJ9TvTfsWAm89ZZv1CF4VTLAsQz+5+5S1wOgaMqFqSpFriU15L3e2AXQ== + dependencies: + methods "^1.1.2" + superagent "^6.1.0" + supports-color@^5.3.0: version "5.5.0" resolved "https://registry.npmjs.org/supports-color/-/supports-color-5.5.0.tgz" @@ -11834,11 +11842,6 @@ test-exclude@^6.0.0: glob "^7.1.4" minimatch "^3.0.4" -test-listen@^1.1.0: - version "1.1.0" - resolved "https://registry.yarnpkg.com/test-listen/-/test-listen-1.1.0.tgz#2ba614d96c3bc9157469003027b42a495dd83b6a" - integrity sha512-OyEVi981C1sb9NX1xayfgZls3p8QTDRwp06EcgxSgd1kktaENBW8dO15i8v/7Fi15j0IYQctJzk5J+hyEBId2w== - text-table@^0.2.0: version "0.2.0" resolved "https://registry.npmjs.org/text-table/-/text-table-0.2.0.tgz" From 5c94bd33e8f7d3ca958fec17427e25c65602040a Mon Sep 17 00:00:00 2001 From: Logan McAnsh Date: Thu, 12 Aug 2021 10:32:58 -0400 Subject: [PATCH 09/68] fix(express): read port from request app settings Signed-off-by: Logan McAnsh --- packages/remix-express/server.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/packages/remix-express/server.ts b/packages/remix-express/server.ts index 576be2c0d33..1d933a33a5c 100644 --- a/packages/remix-express/server.ts +++ b/packages/remix-express/server.ts @@ -92,6 +92,8 @@ export function createRemixHeaders( export function createRemixRequest(req: express.Request): NodeRequest { let origin = `${req.protocol}://${req.get("host")}`; let url = new URL(req.url, origin); + let port = req.app.settings?.port; + if (port) url.port = port; let controller = new AbortController(); From cabc7acafa7ccb35140cc667a67ca27f9ff6ab27 Mon Sep 17 00:00:00 2001 From: Logan McAnsh Date: Thu, 12 Aug 2021 10:42:06 -0400 Subject: [PATCH 10/68] fix(express): req.get("host") returns the port Signed-off-by: Logan McAnsh --- packages/remix-express/server.ts | 2 -- 1 file changed, 2 deletions(-) diff --git a/packages/remix-express/server.ts b/packages/remix-express/server.ts index 1d933a33a5c..576be2c0d33 100644 --- a/packages/remix-express/server.ts +++ b/packages/remix-express/server.ts @@ -92,8 +92,6 @@ export function createRemixHeaders( export function createRemixRequest(req: express.Request): NodeRequest { let origin = `${req.protocol}://${req.get("host")}`; let url = new URL(req.url, origin); - let port = req.app.settings?.port; - if (port) url.port = port; let controller = new AbortController(); From df40493232bee7c1779e18a2fd10c930da34babb Mon Sep 17 00:00:00 2001 From: Logan McAnsh Date: Thu, 12 Aug 2021 10:52:37 -0400 Subject: [PATCH 11/68] test(express): update request mocking Signed-off-by: Logan McAnsh --- packages/remix-express/package.json | 1 - 1 file changed, 1 deletion(-) diff --git a/packages/remix-express/package.json b/packages/remix-express/package.json index 5062bd00ce6..8f1d2cf0ea8 100644 --- a/packages/remix-express/package.json +++ b/packages/remix-express/package.json @@ -17,7 +17,6 @@ "@remix-run/node": "1.6.8" }, "devDependencies": { - "@jest-mock/express": "^1.4.3", "@types/express": "^4.17.9", "@types/supertest": "^2.0.10", "express": "^4.17.1", From b36f60db85dfd9af99f2982eb393580a798d1f38 Mon Sep 17 00:00:00 2001 From: Logan McAnsh Date: Thu, 12 Aug 2021 17:00:03 -0400 Subject: [PATCH 12/68] feat: initial azure adapter Signed-off-by: Logan McAnsh --- package.json | 2 +- packages/remix-azure/__tests__/server-test.ts | 121 ++++++++++++++++++ packages/remix-azure/globals.ts | 2 + packages/remix-azure/index.ts | 4 + packages/remix-azure/jest.config.js | 5 + packages/remix-azure/package.json | 18 +++ packages/remix-azure/rollup.config.js | 6 + packages/remix-azure/server.ts | 78 +++++++++++ packages/remix-azure/tsconfig.json | 16 +++ rollup.utils.js | 2 +- 10 files changed, 252 insertions(+), 2 deletions(-) create mode 100644 packages/remix-azure/__tests__/server-test.ts create mode 100644 packages/remix-azure/globals.ts create mode 100644 packages/remix-azure/index.ts create mode 100644 packages/remix-azure/jest.config.js create mode 100644 packages/remix-azure/package.json create mode 100644 packages/remix-azure/rollup.config.js create mode 100644 packages/remix-azure/server.ts create mode 100644 packages/remix-azure/tsconfig.json diff --git a/package.json b/package.json index 876b692f39a..bfc025cf954 100644 --- a/package.json +++ b/package.json @@ -122,4 +122,4 @@ "engines": { "node": ">=14" } -} +} \ No newline at end of file diff --git a/packages/remix-azure/__tests__/server-test.ts b/packages/remix-azure/__tests__/server-test.ts new file mode 100644 index 00000000000..e2739c862a6 --- /dev/null +++ b/packages/remix-azure/__tests__/server-test.ts @@ -0,0 +1,121 @@ +import { createRequestHandler as createRemixRequestHandler } from "@remix-run/node/server"; + +import { createRemixHeaders, createRemixRequest } from "../server"; + +// We don't want to test that the remix server works here (that's what the +// puppetteer tests do), we just want to test the azure adapter +jest.mock("@remix-run/node/server"); +let mockedCreateRequestHandler = createRemixRequestHandler as jest.MockedFunction< + typeof createRemixRequestHandler +>; + +describe.skip("azure createRequestHandler", () => { + describe("basic requests", () => { + afterEach(() => { + mockedCreateRequestHandler.mockReset(); + }); + + afterAll(() => { + jest.restoreAllMocks(); + }); + + it.todo("handles requests"); + + it.todo("handles status codes"); + + it.todo("sets headers"); + }); +}); + +describe("azure createRemixHeaders", () => { + describe("creates fetch headers from azure headers", () => { + it("handles empty headers", () => { + expect(createRemixHeaders({})).toMatchInlineSnapshot(` + Headers { + Symbol(map): Object {}, + } + `); + }); + + it("handles simple headers", () => { + expect(createRemixHeaders({ "x-foo": "bar" })).toMatchInlineSnapshot(` + Headers { + Symbol(map): Object { + "x-foo": Array [ + "bar", + ], + }, + } + `); + }); + + it("handles multiple headers", () => { + expect(createRemixHeaders({ "x-foo": "bar", "x-bar": "baz" })) + .toMatchInlineSnapshot(` + Headers { + Symbol(map): Object { + "x-bar": Array [ + "baz", + ], + "x-foo": Array [ + "bar", + ], + }, + } + `); + }); + + it("handles headers with multiple values", () => { + expect(createRemixHeaders({ "x-foo": "bar, baz" })) + .toMatchInlineSnapshot(` + Headers { + Symbol(map): Object { + "x-foo": Array [ + "bar, baz", + ], + }, + } + `); + }); + + it("handles headers with multiple values and multiple headers", () => { + expect(createRemixHeaders({ "x-foo": "bar, baz", "x-bar": "baz" })) + .toMatchInlineSnapshot(` + Headers { + Symbol(map): Object { + "x-bar": Array [ + "baz", + ], + "x-foo": Array [ + "bar, baz", + ], + }, + } + `); + }); + + it.skip("handles multiple set-cookie headers", () => { + expect( + createRemixHeaders({ + "set-cookie": [ + "__session=some_value; Path=/; Secure; HttpOnly; MaxAge=7200; SameSite=Lax", + "__other=some_other_value; Path=/; Secure; HttpOnly; MaxAge=3600; SameSite=Lax" + ] + }) + ).toMatchInlineSnapshot(` + Headers { + Symbol(map): Object { + "set-cookie": Array [ + "__session=some_value; Path=/; Secure; HttpOnly; MaxAge=7200; SameSite=Lax", + "__other=some_other_value; Path=/; Secure; HttpOnly; MaxAge=3600; SameSite=Lax", + ], + }, + } + `); + }); + }); +}); + +describe("azure createRemixRequest", () => { + it.todo("creates a request with the correct headers"); +}); diff --git a/packages/remix-azure/globals.ts b/packages/remix-azure/globals.ts new file mode 100644 index 00000000000..917305ac938 --- /dev/null +++ b/packages/remix-azure/globals.ts @@ -0,0 +1,2 @@ +import { installGlobals } from "@remix-run/node"; +installGlobals(); diff --git a/packages/remix-azure/index.ts b/packages/remix-azure/index.ts new file mode 100644 index 00000000000..fb640bf4799 --- /dev/null +++ b/packages/remix-azure/index.ts @@ -0,0 +1,4 @@ +import "./globals"; + +export type { GetLoadContextFunction, RequestHandler } from "./server"; +export { createRequestHandler } from "./server"; diff --git a/packages/remix-azure/jest.config.js b/packages/remix-azure/jest.config.js new file mode 100644 index 00000000000..05fd7594ed4 --- /dev/null +++ b/packages/remix-azure/jest.config.js @@ -0,0 +1,5 @@ +/** @type {import('@jest/types').Config.InitialOptions} */ +module.exports = { + ...require("../../jest/jest.config.shared"), + displayName: "azure", +}; diff --git a/packages/remix-azure/package.json b/packages/remix-azure/package.json new file mode 100644 index 00000000000..015d43d9110 --- /dev/null +++ b/packages/remix-azure/package.json @@ -0,0 +1,18 @@ +{ + "name": "@remix-run/azure", + "description": "Azure server request handler for Remix", + "version": "0.18.0-pre.0", + "repository": "https://github.com/remix-run/packages", + "dependencies": { + "@remix-run/node": "0.18.0-pre.0" + }, + "peerDependencies": { + "@azure/functions": "^1.2.3" + }, + "devDependencies": { + "@azure/functions": "^1.2.3", + "@types/supertest": "^2.0.10", + "node-mocks-http": "^1.10.1", + "supertest": "^6.0.1" + } +} diff --git a/packages/remix-azure/rollup.config.js b/packages/remix-azure/rollup.config.js new file mode 100644 index 00000000000..ec8b73d2dd4 --- /dev/null +++ b/packages/remix-azure/rollup.config.js @@ -0,0 +1,6 @@ +const { getAdapterConfig } = require("../../rollup.utils"); + +/** @returns {import("rollup").RollupOptions[]} */ +module.exports = function rollup() { + return [getAdapterConfig("azure")]; +}; diff --git a/packages/remix-azure/server.ts b/packages/remix-azure/server.ts new file mode 100644 index 00000000000..5bed2c8ec5b --- /dev/null +++ b/packages/remix-azure/server.ts @@ -0,0 +1,78 @@ +import { + AzureFunction, + Context, + HttpRequest, + HttpRequestHeaders +} from "@azure/functions"; +import type { AppLoadContext, RequestInit, ServerBuild } from "@remix-run/node"; +import { + Headers, + Request, + createRequestHandler as createRemixRequestHandler +} from "@remix-run/node"; + +/** + * A function that returns the value to use as `context` in route `loader` and + * `action` functions. + * + * You can think of this as an escape hatch that allows you to pass + * environment/platform-specific values through to your loader/action, such as + * values that are generated by Express middleware like `req.session`. + */ +export interface GetLoadContextFunction { + (req: HttpRequest): AppLoadContext; +} + +export type RequestHandler = ReturnType; + +export function createRequestHandler({ + build, + getLoadContext, + mode = process.env.NODE_ENV +}: { + build: ServerBuild; + getLoadContext?: GetLoadContextFunction; + mode?: string; +}): AzureFunction { + let handleRequest = createRemixRequestHandler(build, mode); + + return async (context: Context, req: HttpRequest) => { + let request = createRemixRequest(req); + let loadContext = getLoadContext ? getLoadContext(req) : undefined; + + let response = await handleRequest(request, loadContext); + + context.res = { + status: response.status, + headers: createRemixHeaders(req.headers), + body: await response.text() + }; + }; +} + +export function createRemixHeaders(requestHeaders: HttpRequestHeaders) { + let headers = new Headers(); + + for (let [key, value] of Object.entries(requestHeaders)) { + if (!value) break; + headers.set(key, value); + } + + return headers; +} + +export function createRemixRequest(req: HttpRequest) { + let url = req.headers["x-ms-original-url"]!; + + let init: RequestInit = { + // TODO: why is this optional? + method: req.method || "GET", + headers: createRemixHeaders(req.headers) + }; + + if (req.body && req.method !== "GET" && req.method !== "HEAD") { + init.body = req.body; + } + + return new Request(url, init); +} diff --git a/packages/remix-azure/tsconfig.json b/packages/remix-azure/tsconfig.json new file mode 100644 index 00000000000..b725b116c12 --- /dev/null +++ b/packages/remix-azure/tsconfig.json @@ -0,0 +1,16 @@ +{ + "exclude": ["dist", "__tests__"], + "compilerOptions": { + "lib": ["ES2019", "DOM.Iterable"], + "target": "ES2019", + + "moduleResolution": "node", + "allowSyntheticDefaultImports": true, + "strict": true, + "declaration": true, + "emitDeclarationOnly": true, + "rootDir": ".", + "outDir": "../../build/node_modules/@remix-run/azure/dist", + "composite": true + } +} diff --git a/rollup.utils.js b/rollup.utils.js index 183b13b1447..9d6e6e24058 100644 --- a/rollup.utils.js +++ b/rollup.utils.js @@ -419,7 +419,7 @@ module.exports = { /** * @typedef {Record} MagicExports - * @typedef {"architect" | "cloudflare-pages" | "cloudflare-workers" | "express" | "netlify" | "vercel"} RemixAdapter + * @typedef {"architect" | "azure" | "cloudflare-pages" | "cloudflare-workers" | "express" | "netlify" | "vercel"} RemixAdapter * @typedef {"cloudflare" | "node" | "deno"} RemixRuntime * @typedef {`@remix-run/${RemixAdapter | RemixRuntime | "dev" | "eslint-config" | "react" | "serve" | "server-runtime"}`} ScopedRemixPackage * @typedef {"create-remix" | "remix" | ScopedRemixPackage} RemixPackage From b7c613d91ab0c6180ea5bfef64576c34c933c44b Mon Sep 17 00:00:00 2001 From: Logan McAnsh Date: Thu, 12 Aug 2021 17:49:54 -0400 Subject: [PATCH 13/68] test(azure): add test for createRemixRequest Signed-off-by: Logan McAnsh --- packages/remix-azure/__tests__/server-test.ts | 57 ++++++++++++++++++- 1 file changed, 56 insertions(+), 1 deletion(-) diff --git a/packages/remix-azure/__tests__/server-test.ts b/packages/remix-azure/__tests__/server-test.ts index e2739c862a6..83aeb335c91 100644 --- a/packages/remix-azure/__tests__/server-test.ts +++ b/packages/remix-azure/__tests__/server-test.ts @@ -1,3 +1,4 @@ +import { HttpRequest } from "@azure/functions"; import { createRequestHandler as createRemixRequestHandler } from "@remix-run/node/server"; import { createRemixHeaders, createRemixRequest } from "../server"; @@ -117,5 +118,59 @@ describe("azure createRemixHeaders", () => { }); describe("azure createRemixRequest", () => { - it.todo("creates a request with the correct headers"); + it("creates a request with the correct headers", async () => { + const request: HttpRequest = { + method: "GET", + url: "/foo/bar", + rawBody: "", + headers: { + "x-ms-original-url": "http://localhost:3000/foo/bar" + }, + params: {}, + query: {}, + body: "" + }; + + expect(createRemixRequest(request)).toMatchInlineSnapshot(` + Request { + "agent": undefined, + "compress": true, + "counter": 0, + "follow": 20, + "size": 0, + "timeout": 0, + Symbol(Body internals): Object { + "body": null, + "disturbed": false, + "error": null, + }, + Symbol(Request internals): Object { + "headers": Headers { + Symbol(map): Object { + "x-ms-original-url": Array [ + "http://localhost:3000/foo/bar", + ], + }, + }, + "method": "GET", + "parsedURL": Url { + "auth": null, + "hash": null, + "host": "localhost:3000", + "hostname": "localhost", + "href": "http://localhost:3000/foo/bar", + "path": "/foo/bar", + "pathname": "/foo/bar", + "port": "3000", + "protocol": "http:", + "query": null, + "search": null, + "slashes": true, + }, + "redirect": "follow", + "signal": null, + }, + } + `); + }); }); From 22e2292269fdd35217223c19c6fac47dec3a79a2 Mon Sep 17 00:00:00 2001 From: Logan McAnsh Date: Thu, 12 Aug 2021 17:57:14 -0400 Subject: [PATCH 14/68] test(azure): add initial test for createRequestHandler Signed-off-by: Logan McAnsh --- packages/remix-azure/__tests__/server-test.ts | 42 ++++++++++++++++--- 1 file changed, 37 insertions(+), 5 deletions(-) diff --git a/packages/remix-azure/__tests__/server-test.ts b/packages/remix-azure/__tests__/server-test.ts index 83aeb335c91..c99f96b6edd 100644 --- a/packages/remix-azure/__tests__/server-test.ts +++ b/packages/remix-azure/__tests__/server-test.ts @@ -1,7 +1,12 @@ -import { HttpRequest } from "@azure/functions"; +import { Context, HttpRequest } from "@azure/functions"; import { createRequestHandler as createRemixRequestHandler } from "@remix-run/node/server"; +import { Response, Headers } from "@remix-run/node"; -import { createRemixHeaders, createRemixRequest } from "../server"; +import { + createRemixHeaders, + createRemixRequest, + createRequestHandler +} from "../server"; // We don't want to test that the remix server works here (that's what the // puppetteer tests do), we just want to test the azure adapter @@ -10,7 +15,13 @@ let mockedCreateRequestHandler = createRemixRequestHandler as jest.MockedFunctio typeof createRemixRequestHandler >; -describe.skip("azure createRequestHandler", () => { +describe("azure createRequestHandler", () => { + let context: Context; + + beforeEach(() => { + context = ({ log: jest.fn() } as unknown) as Context; + }); + describe("basic requests", () => { afterEach(() => { mockedCreateRequestHandler.mockReset(); @@ -20,7 +31,28 @@ describe.skip("azure createRequestHandler", () => { jest.restoreAllMocks(); }); - it.todo("handles requests"); + it("handles requests", async () => { + mockedCreateRequestHandler.mockImplementation(() => async req => { + return new Response(`URL: ${new URL(req.url).pathname}`); + }); + + let mockedRequest: HttpRequest = { + method: "GET", + url: "/foo/bar", + rawBody: "", + headers: { + "x-ms-original-url": "http://localhost:3000/foo/bar" + }, + params: {}, + query: {}, + body: "" + }; + + await createRequestHandler({ build: undefined })(context, mockedRequest); + + expect(context.res.status).toBe(200); + expect(context.res.body).toBe("URL: /foo/bar"); + }); it.todo("handles status codes"); @@ -119,7 +151,7 @@ describe("azure createRemixHeaders", () => { describe("azure createRemixRequest", () => { it("creates a request with the correct headers", async () => { - const request: HttpRequest = { + let request: HttpRequest = { method: "GET", url: "/foo/bar", rawBody: "", From b40a51fa988afc9f05374ade81ba0e077b847d88 Mon Sep 17 00:00:00 2001 From: Logan McAnsh Date: Thu, 12 Aug 2021 18:00:32 -0400 Subject: [PATCH 15/68] chore: update remix-node version Signed-off-by: Logan McAnsh --- packages/remix-azure/package.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/remix-azure/package.json b/packages/remix-azure/package.json index 015d43d9110..177a649a44c 100644 --- a/packages/remix-azure/package.json +++ b/packages/remix-azure/package.json @@ -1,10 +1,10 @@ { "name": "@remix-run/azure", "description": "Azure server request handler for Remix", - "version": "0.18.0-pre.0", + "version": "0.17.5", "repository": "https://github.com/remix-run/packages", "dependencies": { - "@remix-run/node": "0.18.0-pre.0" + "@remix-run/node": "0.17.5" }, "peerDependencies": { "@azure/functions": "^1.2.3" From 389719c3c8361bed4ea3338be95add4c79c40030 Mon Sep 17 00:00:00 2001 From: Logan McAnsh Date: Fri, 13 Aug 2021 13:56:00 -0400 Subject: [PATCH 16/68] chore: update notes --- packages/remix-vercel/__tests__/server-test.ts | 4 ---- 1 file changed, 4 deletions(-) diff --git a/packages/remix-vercel/__tests__/server-test.ts b/packages/remix-vercel/__tests__/server-test.ts index 46c3cc3310e..4e4e72c246c 100644 --- a/packages/remix-vercel/__tests__/server-test.ts +++ b/packages/remix-vercel/__tests__/server-test.ts @@ -271,11 +271,7 @@ describe("vercel createRemixRequest", () => { "method": "GET", "parsedURL": "http://localhost:3000/foo/bar", "redirect": "follow", -<<<<<<< HEAD "signal": AbortSignal {}, -======= - "signal": null, ->>>>>>> 739084c6 (test(vercel): add test for createRequestHandler) }, } `); From 7e5083404a880e50d61a98871ddf18ec738f2cac Mon Sep 17 00:00:00 2001 From: Logan McAnsh Date: Mon, 16 Aug 2021 17:10:55 -0400 Subject: [PATCH 17/68] chore(azure): use return instead of `context.res = {}` Signed-off-by: Logan McAnsh --- packages/remix-azure/__tests__/server-test.ts | 11 +++++++---- packages/remix-azure/server.ts | 15 ++++++++------- 2 files changed, 15 insertions(+), 11 deletions(-) diff --git a/packages/remix-azure/__tests__/server-test.ts b/packages/remix-azure/__tests__/server-test.ts index c99f96b6edd..e6969b3ad3f 100644 --- a/packages/remix-azure/__tests__/server-test.ts +++ b/packages/remix-azure/__tests__/server-test.ts @@ -1,6 +1,6 @@ import { Context, HttpRequest } from "@azure/functions"; import { createRequestHandler as createRemixRequestHandler } from "@remix-run/node/server"; -import { Response, Headers } from "@remix-run/node"; +import { Response } from "@remix-run/node"; import { createRemixHeaders, @@ -48,10 +48,13 @@ describe("azure createRequestHandler", () => { body: "" }; - await createRequestHandler({ build: undefined })(context, mockedRequest); + const res = await createRequestHandler({ build: undefined })( + context, + mockedRequest + ); - expect(context.res.status).toBe(200); - expect(context.res.body).toBe("URL: /foo/bar"); + expect(res.status).toBe(200); + expect(res.body).toBe("URL: /foo/bar"); }); it.todo("handles status codes"); diff --git a/packages/remix-azure/server.ts b/packages/remix-azure/server.ts index 5bed2c8ec5b..e61e6f28459 100644 --- a/packages/remix-azure/server.ts +++ b/packages/remix-azure/server.ts @@ -1,4 +1,4 @@ -import { +import type { AzureFunction, Context, HttpRequest, @@ -42,30 +42,31 @@ export function createRequestHandler({ let response = await handleRequest(request, loadContext); - context.res = { + return { status: response.status, - headers: createRemixHeaders(req.headers), + headers: response.headers.raw(), body: await response.text() }; }; } -export function createRemixHeaders(requestHeaders: HttpRequestHeaders) { +export function createRemixHeaders( + requestHeaders: HttpRequestHeaders +): Headers { let headers = new Headers(); for (let [key, value] of Object.entries(requestHeaders)) { - if (!value) break; + if (!value) continue; headers.set(key, value); } return headers; } -export function createRemixRequest(req: HttpRequest) { +export function createRemixRequest(req: HttpRequest): Request { let url = req.headers["x-ms-original-url"]!; let init: RequestInit = { - // TODO: why is this optional? method: req.method || "GET", headers: createRemixHeaders(req.headers) }; From 9206f3dfa597461a52ebb19d65a47b0a06622d2a Mon Sep 17 00:00:00 2001 From: Logan McAnsh Date: Mon, 16 Aug 2021 17:21:44 -0400 Subject: [PATCH 18/68] chore: input headers are just a string Signed-off-by: Logan McAnsh --- packages/remix-azure/__tests__/server-test.ts | 20 ------------------- 1 file changed, 20 deletions(-) diff --git a/packages/remix-azure/__tests__/server-test.ts b/packages/remix-azure/__tests__/server-test.ts index e6969b3ad3f..8cf32023919 100644 --- a/packages/remix-azure/__tests__/server-test.ts +++ b/packages/remix-azure/__tests__/server-test.ts @@ -129,26 +129,6 @@ describe("azure createRemixHeaders", () => { } `); }); - - it.skip("handles multiple set-cookie headers", () => { - expect( - createRemixHeaders({ - "set-cookie": [ - "__session=some_value; Path=/; Secure; HttpOnly; MaxAge=7200; SameSite=Lax", - "__other=some_other_value; Path=/; Secure; HttpOnly; MaxAge=3600; SameSite=Lax" - ] - }) - ).toMatchInlineSnapshot(` - Headers { - Symbol(map): Object { - "set-cookie": Array [ - "__session=some_value; Path=/; Secure; HttpOnly; MaxAge=7200; SameSite=Lax", - "__other=some_other_value; Path=/; Secure; HttpOnly; MaxAge=3600; SameSite=Lax", - ], - }, - } - `); - }); }); }); From 49832176779b947899ff33d699a135f924217db8 Mon Sep 17 00:00:00 2001 From: Logan McAnsh Date: Tue, 17 Aug 2021 12:43:08 -0400 Subject: [PATCH 19/68] feat: add initial azure template TODO: - [ ] README - [ ] decide if we should include the github action Signed-off-by: Logan McAnsh --- templates/azure/README.md | 4 +++ templates/azure/azure/function.json | 27 ++++++++++++++ templates/azure/azure/function/index.js | 48 +++++++++++++++++++++++++ templates/azure/gitignore | 5 +++ templates/azure/host.json | 20 +++++++++++ templates/azure/local.settings.json | 7 ++++ templates/azure/package.json | 13 +++++++ templates/azure/remix.config.js | 7 ++++ 8 files changed, 131 insertions(+) create mode 100644 templates/azure/README.md create mode 100644 templates/azure/azure/function.json create mode 100644 templates/azure/azure/function/index.js create mode 100644 templates/azure/gitignore create mode 100644 templates/azure/host.json create mode 100644 templates/azure/local.settings.json create mode 100644 templates/azure/package.json create mode 100644 templates/azure/remix.config.js diff --git a/templates/azure/README.md b/templates/azure/README.md new file mode 100644 index 00000000000..247b635258c --- /dev/null +++ b/templates/azure/README.md @@ -0,0 +1,4 @@ +# Welcome to Remix! + +- [Remix Docs](https://docs.remix.run) +- [Customer Dashboard](https://remix.run/dashboard) diff --git a/templates/azure/azure/function.json b/templates/azure/azure/function.json new file mode 100644 index 00000000000..7eb6dd4e1ae --- /dev/null +++ b/templates/azure/azure/function.json @@ -0,0 +1,27 @@ +{ + "bindings": [ + { + "authLevel": "anonymous", + "type": "httpTrigger", + "direction": "in", + "name": "req", + "methods": [ + "get", + "head", + "post", + "put", + "delete", + "connect", + "options", + "trace", + "patch" + ] + }, + { + "type": "http", + "direction": "out", + "name": "$return" + } + ], + "scriptFile": "./function/index.js" +} diff --git a/templates/azure/azure/function/index.js b/templates/azure/azure/function/index.js new file mode 100644 index 00000000000..7e5715ca3b1 --- /dev/null +++ b/templates/azure/azure/function/index.js @@ -0,0 +1,48 @@ +const path = require("path"); +const express = require("express"); +const compression = require("compression"); +const morgan = require("morgan"); +const { createRequestHandler } = require("@remix-run/express"); + +const MODE = process.env.NODE_ENV; +const BUILD_DIR = path.join(process.cwd(), "server/build"); + +let app = express(); +app.use(compression()); +app.use(morgan("tiny")); + +// You may want to be more aggressive with this caching +app.use(express.static("public", { maxAge: "1h" })); + +// Remix fingerprints its assets so we can cache forever +app.use(express.static("public/build", { immutable: true, maxAge: "1y" })); + +app.all( + "*", + MODE === "production" + ? createRequestHandler({ build: require("./build") }) + : (req, res, next) => { + purgeRequireCache(); + let build = require("./build"); + return createRequestHandler({ build, mode: MODE })(req, res, next); + } +); + +let port = process.env.PORT || 3000; +app.listen(port, () => { + console.log(`Express server listening on port ${port}`); +}); + +//////////////////////////////////////////////////////////////////////////////// +function purgeRequireCache() { + // purge require cache on requests for "server side HMR" this won't let + // you have in-memory objects between requests in development, + // alternatively you can set up nodemon/pm2-dev to restart the server on + // file changes, we prefer the DX of this though, so we've included it + // for you by default + for (let key in require.cache) { + if (key.startsWith(BUILD_DIR)) { + delete require.cache[key]; + } + } +} diff --git a/templates/azure/gitignore b/templates/azure/gitignore new file mode 100644 index 00000000000..ed7790835c9 --- /dev/null +++ b/templates/azure/gitignore @@ -0,0 +1,5 @@ +node_modules + +/.cache +/azure/function/build +/public/build diff --git a/templates/azure/host.json b/templates/azure/host.json new file mode 100644 index 00000000000..9bbc8364f87 --- /dev/null +++ b/templates/azure/host.json @@ -0,0 +1,20 @@ +{ + "version": "2.0", + "logging": { + "applicationInsights": { + "samplingSettings": { + "isEnabled": true, + "excludedTypes": "Request" + } + } + }, + "extensions": { + "http": { + "routePrefix": "api" + } + }, + "extensionBundle": { + "id": "Microsoft.Azure.Functions.ExtensionBundle", + "version": "[2.*, 3.0.0)" + } +} diff --git a/templates/azure/local.settings.json b/templates/azure/local.settings.json new file mode 100644 index 00000000000..4e3da2cc65c --- /dev/null +++ b/templates/azure/local.settings.json @@ -0,0 +1,7 @@ +{ + "IsEncrypted": false, + "Values": { + "AzureWebJobsStorage": "", + "FUNCTIONS_WORKER_RUNTIME": "node" + } +} diff --git a/templates/azure/package.json b/templates/azure/package.json new file mode 100644 index 00000000000..e800cb5b4da --- /dev/null +++ b/templates/azure/package.json @@ -0,0 +1,13 @@ +{ + "scripts": { + "build": "remix build", + "dev": "swa start ./public --run \"remix dev\" --api ." + }, + "dependencies": { + "@remix-run/express": "*", + "@remix-run/node": "*" + }, + "devDependencies": { + "@azure/functions": "^1.2.3" + } +} diff --git a/templates/azure/remix.config.js b/templates/azure/remix.config.js new file mode 100644 index 00000000000..fff35829093 --- /dev/null +++ b/templates/azure/remix.config.js @@ -0,0 +1,7 @@ +module.exports = { + appDirectory: "app", + browserBuildDirectory: "public/build", + publicPath: "/build/", + serverBuildDirectory: "azure/function/build", + devServerPort: 8002 +}; From d7406f2d1ebb81cb49d3b3b06cbea4d6c452dcc8 Mon Sep 17 00:00:00 2001 From: Logan McAnsh Date: Wed, 18 Aug 2021 10:49:56 -0400 Subject: [PATCH 20/68] chore(azure): update template readme, add tweaked github action that azure provides during setup also updates the cli to copy a `github-action` directory to `.github/workflows` Signed-off-by: Logan McAnsh --- templates/azure/README.md | 21 ++++++++ ...e-static-web-apps-brave-wave-0feb78710.yml | 48 +++++++++++++++++++ templates/azure/package.json | 3 +- 3 files changed, 71 insertions(+), 1 deletion(-) create mode 100644 templates/azure/github-actions/azure-static-web-apps-brave-wave-0feb78710.yml diff --git a/templates/azure/README.md b/templates/azure/README.md index 247b635258c..0e370b4b516 100644 --- a/templates/azure/README.md +++ b/templates/azure/README.md @@ -2,3 +2,24 @@ - [Remix Docs](https://docs.remix.run) - [Customer Dashboard](https://remix.run/dashboard) + +## Development + +From your terminal: + +```sh +npm run dev +``` + +This starts your app in development mode, rebuilding assets on file changes. + +## Deploying + +Prerequisites: + +- [Azure Account](https://portal.azure.com/) +- [GitHub Account](https://github.com/) + +First, you need to follow the [instructions](https://docs.microsoft.com/en-us/azure/static-web-apps/get-started-portal?tabs=vanilla-javascript) to create a new project on Azure. + +Next, you'll need to add your `REMIX_TOKEN` as a GitHub project [secret](https://docs.github.com/en/actions/reference/encrypted-secrets) diff --git a/templates/azure/github-actions/azure-static-web-apps-brave-wave-0feb78710.yml b/templates/azure/github-actions/azure-static-web-apps-brave-wave-0feb78710.yml new file mode 100644 index 00000000000..16389e95e3e --- /dev/null +++ b/templates/azure/github-actions/azure-static-web-apps-brave-wave-0feb78710.yml @@ -0,0 +1,48 @@ +name: Azure Static Web Apps CI/CD + +on: + push: + branches: + - main + pull_request: + types: [opened, synchronize, reopened, closed] + branches: + - main + +jobs: + build_and_deploy_job: + if: github.event_name == 'push' || (github.event_name == 'pull_request' && github.event.action != 'closed') + runs-on: ubuntu-latest + name: Build and Deploy Job + steps: + - uses: actions/checkout@v2 + with: + submodules: true + - name: Build And Deploy + id: builddeploy + uses: Azure/static-web-apps-deploy@v1 + env: + REMIX_TOKEN: ${{ secrets.REMIX_TOKEN }} + with: + azure_static_web_apps_api_token: ${{ secrets.AZURE_STATIC_WEB_APPS_API_TOKEN_BRAVE_WAVE_0FEB78710 }} + repo_token: ${{ secrets.GITHUB_TOKEN }} # Used for Github integrations (i.e. PR comments) + action: "upload" + ###### Repository/Build Configurations - These values can be configured to match your app requirements. ###### + # For more information regarding Static Web App workflow configurations, please visit: https://aka.ms/swaworkflowconfig + app_location: "/" # App source code path + api_location: "/" # Api source code path - optional + output_location: "public" # Built app content directory - optional + app_build_command: "npm run build" + ###### End of Repository/Build Configurations ###### + + close_pull_request_job: + if: github.event_name == 'pull_request' && github.event.action == 'closed' + runs-on: ubuntu-latest + name: Close Pull Request Job + steps: + - name: Close Pull Request + id: closepullrequest + uses: Azure/static-web-apps-deploy@v1 + with: + azure_static_web_apps_api_token: ${{ secrets.AZURE_STATIC_WEB_APPS_API_TOKEN_BRAVE_WAVE_0FEB78710 }} + action: "close" diff --git a/templates/azure/package.json b/templates/azure/package.json index e800cb5b4da..74dfac58502 100644 --- a/templates/azure/package.json +++ b/templates/azure/package.json @@ -8,6 +8,7 @@ "@remix-run/node": "*" }, "devDependencies": { - "@azure/functions": "^1.2.3" + "@azure/functions": "^1.2.3", + "@azure/static-web-apps-cli": "^0.6.1" } } From 265521d28dd8a34cf221d21b5e7349e354819285 Mon Sep 17 00:00:00 2001 From: Logan McAnsh Date: Wed, 18 Aug 2021 10:57:13 -0400 Subject: [PATCH 21/68] chore(azure): use generic secret name in github action Signed-off-by: Logan McAnsh --- templates/azure/README.md | 4 +++- .../azure-static-web-apps-brave-wave-0feb78710.yml | 4 ++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/templates/azure/README.md b/templates/azure/README.md index 0e370b4b516..12fbf4a8d58 100644 --- a/templates/azure/README.md +++ b/templates/azure/README.md @@ -22,4 +22,6 @@ Prerequisites: First, you need to follow the [instructions](https://docs.microsoft.com/en-us/azure/static-web-apps/get-started-portal?tabs=vanilla-javascript) to create a new project on Azure. -Next, you'll need to add your `REMIX_TOKEN` as a GitHub project [secret](https://docs.github.com/en/actions/reference/encrypted-secrets) +Next, you'll need to add your `REMIX_TOKEN`, and your `AZURE_STATIC_WEB_APPS_TOKEN` as a GitHub project [secrets](https://docs.github.com/en/actions/reference/encrypted-secrets) + +You can find your azure token in the Azure portal for your static web app under "management deployment token". diff --git a/templates/azure/github-actions/azure-static-web-apps-brave-wave-0feb78710.yml b/templates/azure/github-actions/azure-static-web-apps-brave-wave-0feb78710.yml index 16389e95e3e..1f8617944f1 100644 --- a/templates/azure/github-actions/azure-static-web-apps-brave-wave-0feb78710.yml +++ b/templates/azure/github-actions/azure-static-web-apps-brave-wave-0feb78710.yml @@ -24,7 +24,7 @@ jobs: env: REMIX_TOKEN: ${{ secrets.REMIX_TOKEN }} with: - azure_static_web_apps_api_token: ${{ secrets.AZURE_STATIC_WEB_APPS_API_TOKEN_BRAVE_WAVE_0FEB78710 }} + azure_static_web_apps_api_token: ${{ secrets.AZURE_STATIC_WEB_APPS_TOKEN }} repo_token: ${{ secrets.GITHUB_TOKEN }} # Used for Github integrations (i.e. PR comments) action: "upload" ###### Repository/Build Configurations - These values can be configured to match your app requirements. ###### @@ -44,5 +44,5 @@ jobs: id: closepullrequest uses: Azure/static-web-apps-deploy@v1 with: - azure_static_web_apps_api_token: ${{ secrets.AZURE_STATIC_WEB_APPS_API_TOKEN_BRAVE_WAVE_0FEB78710 }} + azure_static_web_apps_api_token: ${{ secrets.AZURE_STATIC_WEB_APPS_TOKEN }} action: "close" From 6835d4c6e944f5136e74be09670a96932308b133 Mon Sep 17 00:00:00 2001 From: Logan McAnsh Date: Wed, 18 Aug 2021 10:57:58 -0400 Subject: [PATCH 22/68] chore(azure): remove erroneous 'a' Signed-off-by: Logan McAnsh --- templates/azure/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/templates/azure/README.md b/templates/azure/README.md index 12fbf4a8d58..111cb96b9d2 100644 --- a/templates/azure/README.md +++ b/templates/azure/README.md @@ -22,6 +22,6 @@ Prerequisites: First, you need to follow the [instructions](https://docs.microsoft.com/en-us/azure/static-web-apps/get-started-portal?tabs=vanilla-javascript) to create a new project on Azure. -Next, you'll need to add your `REMIX_TOKEN`, and your `AZURE_STATIC_WEB_APPS_TOKEN` as a GitHub project [secrets](https://docs.github.com/en/actions/reference/encrypted-secrets) +Next, you'll need to add your `REMIX_TOKEN`, and your `AZURE_STATIC_WEB_APPS_TOKEN` as GitHub project [secrets](https://docs.github.com/en/actions/reference/encrypted-secrets) You can find your azure token in the Azure portal for your static web app under "management deployment token". From d6d4ba401465b5b20fb4942c1ddeda9a165a5d77 Mon Sep 17 00:00:00 2001 From: Michael Jackson Date: Wed, 18 Aug 2021 08:42:08 -0700 Subject: [PATCH 23/68] Add space after comma --- docs/guides/styling.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/guides/styling.md b/docs/guides/styling.md index 1b8662eea9d..17233030da0 100644 --- a/docs/guides/styling.md +++ b/docs/guides/styling.md @@ -754,7 +754,7 @@ Here's some sample code to show how you might use Styled Components with Remix ( responseHeaders.set("Content-Type", "text/html"); - responseHeaders.set("Content-Type","text/html") + responseHeaders.set("Content-Type", "text/html") return new Response("" + markup, { status: responseStatusCode, From a39c4395095cb54c48cf8f16086241958efb7d5a Mon Sep 17 00:00:00 2001 From: Logan McAnsh Date: Wed, 18 Aug 2021 13:35:04 -0400 Subject: [PATCH 24/68] feat(getDocumentHeaders): re-add support for multiple set-cookie headers Signed-off-by: Logan McAnsh --- packages/remix-server-runtime/headers.ts | 2 - packages/remix-server-runtime/package.json | 2 +- ...e-static-web-apps-brave-wave-0feb78710.yml | 96 +++++++++---------- yarn.lock | 5 + 4 files changed, 54 insertions(+), 51 deletions(-) diff --git a/packages/remix-server-runtime/headers.ts b/packages/remix-server-runtime/headers.ts index 19b494266ed..2605bf3f9a4 100644 --- a/packages/remix-server-runtime/headers.ts +++ b/packages/remix-server-runtime/headers.ts @@ -1,9 +1,7 @@ import { splitCookiesString } from "set-cookie-parser"; - import type { ServerBuild } from "./build"; import type { ServerRoute } from "./routes"; import type { RouteMatch } from "./routeMatching"; - export function getDocumentHeaders( build: ServerBuild, matches: RouteMatch[], diff --git a/packages/remix-server-runtime/package.json b/packages/remix-server-runtime/package.json index 15032c81dc8..5f3af124654 100644 --- a/packages/remix-server-runtime/package.json +++ b/packages/remix-server-runtime/package.json @@ -42,4 +42,4 @@ "LICENSE.md", "README.md" ] -} +} \ No newline at end of file diff --git a/templates/azure/github-actions/azure-static-web-apps-brave-wave-0feb78710.yml b/templates/azure/github-actions/azure-static-web-apps-brave-wave-0feb78710.yml index 1f8617944f1..3c5b1a3f05b 100644 --- a/templates/azure/github-actions/azure-static-web-apps-brave-wave-0feb78710.yml +++ b/templates/azure/github-actions/azure-static-web-apps-brave-wave-0feb78710.yml @@ -1,48 +1,48 @@ -name: Azure Static Web Apps CI/CD - -on: - push: - branches: - - main - pull_request: - types: [opened, synchronize, reopened, closed] - branches: - - main - -jobs: - build_and_deploy_job: - if: github.event_name == 'push' || (github.event_name == 'pull_request' && github.event.action != 'closed') - runs-on: ubuntu-latest - name: Build and Deploy Job - steps: - - uses: actions/checkout@v2 - with: - submodules: true - - name: Build And Deploy - id: builddeploy - uses: Azure/static-web-apps-deploy@v1 - env: - REMIX_TOKEN: ${{ secrets.REMIX_TOKEN }} - with: - azure_static_web_apps_api_token: ${{ secrets.AZURE_STATIC_WEB_APPS_TOKEN }} - repo_token: ${{ secrets.GITHUB_TOKEN }} # Used for Github integrations (i.e. PR comments) - action: "upload" - ###### Repository/Build Configurations - These values can be configured to match your app requirements. ###### - # For more information regarding Static Web App workflow configurations, please visit: https://aka.ms/swaworkflowconfig - app_location: "/" # App source code path - api_location: "/" # Api source code path - optional - output_location: "public" # Built app content directory - optional - app_build_command: "npm run build" - ###### End of Repository/Build Configurations ###### - - close_pull_request_job: - if: github.event_name == 'pull_request' && github.event.action == 'closed' - runs-on: ubuntu-latest - name: Close Pull Request Job - steps: - - name: Close Pull Request - id: closepullrequest - uses: Azure/static-web-apps-deploy@v1 - with: - azure_static_web_apps_api_token: ${{ secrets.AZURE_STATIC_WEB_APPS_TOKEN }} - action: "close" +name: Azure Static Web Apps CI/CD + +on: + push: + branches: + - main + pull_request: + types: [opened, synchronize, reopened, closed] + branches: + - main + +jobs: + build_and_deploy_job: + if: github.event_name == 'push' || (github.event_name == 'pull_request' && github.event.action != 'closed') + runs-on: ubuntu-latest + name: Build and Deploy Job + steps: + - uses: actions/checkout@v2 + with: + submodules: true + - name: Build And Deploy + id: builddeploy + uses: Azure/static-web-apps-deploy@v1 + env: + REMIX_TOKEN: ${{ secrets.REMIX_TOKEN }} + with: + azure_static_web_apps_api_token: ${{ secrets.AZURE_STATIC_WEB_APPS_TOKEN }} + repo_token: ${{ secrets.GITHUB_TOKEN }} # Used for Github integrations (i.e. PR comments) + action: "upload" + ###### Repository/Build Configurations - These values can be configured to match your app requirements. ###### + # For more information regarding Static Web App workflow configurations, please visit: https://aka.ms/swaworkflowconfig + app_location: "/" # App source code path + api_location: "/" # Api source code path - optional + output_location: "public" # Built app content directory - optional + app_build_command: "npm run build" + ###### End of Repository/Build Configurations ###### + + close_pull_request_job: + if: github.event_name == 'pull_request' && github.event.action == 'closed' + runs-on: ubuntu-latest + name: Close Pull Request Job + steps: + - name: Close Pull Request + id: closepullrequest + uses: Azure/static-web-apps-deploy@v1 + with: + azure_static_web_apps_api_token: ${{ secrets.AZURE_STATIC_WEB_APPS_TOKEN }} + action: "close" diff --git a/yarn.lock b/yarn.lock index cbae33c9b0b..8083c0f4684 100644 --- a/yarn.lock +++ b/yarn.lock @@ -11143,6 +11143,11 @@ set-cookie-parser@^2.4.6, set-cookie-parser@^2.4.8: resolved "https://registry.npmjs.org/set-cookie-parser/-/set-cookie-parser-2.4.8.tgz" integrity sha512-edRH8mBKEWNVIVMKejNnuJxleqYE/ZSdcT8/Nem9/mmosx12pctd80s2Oy00KNZzrogMZS5mauK2/ymL1bvlvg== +set-cookie-parser@^2.4.8: + version "2.4.8" + resolved "https://registry.yarnpkg.com/set-cookie-parser/-/set-cookie-parser-2.4.8.tgz#d0da0ed388bc8f24e706a391f9c9e252a13c58b2" + integrity sha512-edRH8mBKEWNVIVMKejNnuJxleqYE/ZSdcT8/Nem9/mmosx12pctd80s2Oy00KNZzrogMZS5mauK2/ymL1bvlvg== + set-getter@^0.1.0: version "0.1.1" resolved "https://registry.npmjs.org/set-getter/-/set-getter-0.1.1.tgz" From 6b3f71bcdc52b6c501f2ccbf7e1d31892148b462 Mon Sep 17 00:00:00 2001 From: Logan McAnsh Date: Wed, 18 Aug 2021 14:14:33 -0400 Subject: [PATCH 25/68] chore(azure): update adapter to use update request/response/headers Signed-off-by: Logan McAnsh --- jest.config.js | 2 +- packages/remix-azure/__tests__/server-test.ts | 4 +-- packages/remix-azure/server.ts | 35 ++++++++++++------- 3 files changed, 26 insertions(+), 15 deletions(-) diff --git a/jest.config.js b/jest.config.js index 11f98c692f4..d4ce0925bce 100644 --- a/jest.config.js +++ b/jest.config.js @@ -20,4 +20,4 @@ module.exports = { require.resolve("jest-watch-typeahead/filename"), require.resolve("jest-watch-typeahead/testname"), ], -}; +}; \ No newline at end of file diff --git a/packages/remix-azure/__tests__/server-test.ts b/packages/remix-azure/__tests__/server-test.ts index 8cf32023919..8782a0e980d 100644 --- a/packages/remix-azure/__tests__/server-test.ts +++ b/packages/remix-azure/__tests__/server-test.ts @@ -1,5 +1,5 @@ import { Context, HttpRequest } from "@azure/functions"; -import { createRequestHandler as createRemixRequestHandler } from "@remix-run/node/server"; +import { createRequestHandler as createRemixRequestHandler } from "@remix-run/server-runtime"; import { Response } from "@remix-run/node"; import { @@ -10,7 +10,7 @@ import { // We don't want to test that the remix server works here (that's what the // puppetteer tests do), we just want to test the azure adapter -jest.mock("@remix-run/node/server"); +jest.mock("@remix-run/server-runtime"); let mockedCreateRequestHandler = createRemixRequestHandler as jest.MockedFunction< typeof createRemixRequestHandler >; diff --git a/packages/remix-azure/server.ts b/packages/remix-azure/server.ts index e61e6f28459..9f77bb4c1a0 100644 --- a/packages/remix-azure/server.ts +++ b/packages/remix-azure/server.ts @@ -4,11 +4,18 @@ import type { HttpRequest, HttpRequestHeaders } from "@azure/functions"; -import type { AppLoadContext, RequestInit, ServerBuild } from "@remix-run/node"; +import type { + AppLoadContext, + ServerBuild, + ServerPlatform +} from "@remix-run/server-runtime"; +import { createRequestHandler as createRemixRequestHandler } from "@remix-run/server-runtime"; import { - Headers, - Request, - createRequestHandler as createRemixRequestHandler + formatServerError, + Headers as NodeHeaders, + Request as NodeRequest, + Response as NodeResponse, + RequestInit as NodeRequestInit } from "@remix-run/node"; /** @@ -34,13 +41,17 @@ export function createRequestHandler({ getLoadContext?: GetLoadContextFunction; mode?: string; }): AzureFunction { - let handleRequest = createRemixRequestHandler(build, mode); + let platform: ServerPlatform = { formatServerError }; + let handleRequest = createRemixRequestHandler(build, platform, mode); - return async (context: Context, req: HttpRequest) => { + return async (_context: Context, req: HttpRequest) => { let request = createRemixRequest(req); let loadContext = getLoadContext ? getLoadContext(req) : undefined; - let response = await handleRequest(request, loadContext); + let response = ((await handleRequest( + (request as unknown) as Request, + loadContext + )) as unknown) as NodeResponse; return { status: response.status, @@ -52,8 +63,8 @@ export function createRequestHandler({ export function createRemixHeaders( requestHeaders: HttpRequestHeaders -): Headers { - let headers = new Headers(); +): NodeHeaders { + let headers = new NodeHeaders(); for (let [key, value] of Object.entries(requestHeaders)) { if (!value) continue; @@ -63,10 +74,10 @@ export function createRemixHeaders( return headers; } -export function createRemixRequest(req: HttpRequest): Request { +export function createRemixRequest(req: HttpRequest): NodeRequest { let url = req.headers["x-ms-original-url"]!; - let init: RequestInit = { + let init: NodeRequestInit = { method: req.method || "GET", headers: createRemixHeaders(req.headers) }; @@ -75,5 +86,5 @@ export function createRemixRequest(req: HttpRequest): Request { init.body = req.body; } - return new Request(url, init); + return new NodeRequest(url, init); } From 505647b67d7779e51289e6771b9f80efe0e07a79 Mon Sep 17 00:00:00 2001 From: Logan McAnsh Date: Wed, 18 Aug 2021 14:39:54 -0400 Subject: [PATCH 26/68] chore: rename azure action Signed-off-by: Logan McAnsh --- ...eb-apps-brave-wave-0feb78710.yml => azure-static-web-apps.yml} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename templates/azure/github-actions/{azure-static-web-apps-brave-wave-0feb78710.yml => azure-static-web-apps.yml} (100%) diff --git a/templates/azure/github-actions/azure-static-web-apps-brave-wave-0feb78710.yml b/templates/azure/github-actions/azure-static-web-apps.yml similarity index 100% rename from templates/azure/github-actions/azure-static-web-apps-brave-wave-0feb78710.yml rename to templates/azure/github-actions/azure-static-web-apps.yml From b18919ce1cfe2df95ed9ae8fc1f0533e663de581 Mon Sep 17 00:00:00 2001 From: Logan McAnsh Date: Wed, 18 Aug 2021 15:02:25 -0400 Subject: [PATCH 27/68] chore(init/azure): update handler Signed-off-by: Logan McAnsh --- templates/azure/azure/function/index.js | 49 +------------------------ 1 file changed, 2 insertions(+), 47 deletions(-) diff --git a/templates/azure/azure/function/index.js b/templates/azure/azure/function/index.js index 7e5715ca3b1..7e356edbed6 100644 --- a/templates/azure/azure/function/index.js +++ b/templates/azure/azure/function/index.js @@ -1,48 +1,3 @@ -const path = require("path"); -const express = require("express"); -const compression = require("compression"); -const morgan = require("morgan"); -const { createRequestHandler } = require("@remix-run/express"); +const { createRequestHandler } = require("./handler"); -const MODE = process.env.NODE_ENV; -const BUILD_DIR = path.join(process.cwd(), "server/build"); - -let app = express(); -app.use(compression()); -app.use(morgan("tiny")); - -// You may want to be more aggressive with this caching -app.use(express.static("public", { maxAge: "1h" })); - -// Remix fingerprints its assets so we can cache forever -app.use(express.static("public/build", { immutable: true, maxAge: "1y" })); - -app.all( - "*", - MODE === "production" - ? createRequestHandler({ build: require("./build") }) - : (req, res, next) => { - purgeRequireCache(); - let build = require("./build"); - return createRequestHandler({ build, mode: MODE })(req, res, next); - } -); - -let port = process.env.PORT || 3000; -app.listen(port, () => { - console.log(`Express server listening on port ${port}`); -}); - -//////////////////////////////////////////////////////////////////////////////// -function purgeRequireCache() { - // purge require cache on requests for "server side HMR" this won't let - // you have in-memory objects between requests in development, - // alternatively you can set up nodemon/pm2-dev to restart the server on - // file changes, we prefer the DX of this though, so we've included it - // for you by default - for (let key in require.cache) { - if (key.startsWith(BUILD_DIR)) { - delete require.cache[key]; - } - } -} +module.exports = createRequestHandler({ build: require("./build") }); From f82b0e7c88320151a89b69cf3939ada9e2961be9 Mon Sep 17 00:00:00 2001 From: Logan McAnsh Date: Thu, 19 Aug 2021 11:53:35 -0400 Subject: [PATCH 28/68] chore(init/azure): add rewrites and required index.html file Signed-off-by: Logan McAnsh --- templates/azure/public/favicon.png | Bin 0 -> 1988 bytes templates/azure/public/index.html | 15 +++++++++++++++ templates/azure/public/staticwebapp.config.json | 15 +++++++++++++++ 3 files changed, 30 insertions(+) create mode 100644 templates/azure/public/favicon.png create mode 100644 templates/azure/public/index.html create mode 100644 templates/azure/public/staticwebapp.config.json diff --git a/templates/azure/public/favicon.png b/templates/azure/public/favicon.png new file mode 100644 index 0000000000000000000000000000000000000000..188762f08ce87a5eb22685cd4c5b787cbee05586 GIT binary patch literal 1988 zcmV;#2RrzQP)`D{TR5DNyKh+L=CP?)Cf5o!icIV1;_x zGw0lM&i%jteE;K|YvCTn^E|7)y?w9iy3et8S(dedV=1;#wjsV^-QzV4d0dm@nhe`J zY_Hq4-NSmKudnYk$GnyAl?iHUYI=$bKjzCFD;Gb=GiCNt=E1?i!Jmrd*ueuQt>)(D zcewD(zYQ)7$&_qi2rIx{>J%p43nol!Q$JHJc=u(!@P@|~lID_S_TjpITO!bZpd#-M z3=F)lC!;`tcI{mD)qC#YMl(<;xVI z0`ikRGDk>sw6wIy=03QD3B0NbZcPom+626K99{*La2!q=IISuaf45eiJ0>XR=3r&B zux4gq&9drwf#XyxD8ix=!rW}NwY5Ey%jHf5lcL#LiuaQpULtKY}gu z&=gjw0$s9&lFYJ1b!ku8Et8(cOl2j~6eyZQWhUSl9X3RzD>+xeeuQn58>q5f*vvbN zn>OLp3;YA-O4rtr8+vrJ35yMO_?N-$?}uCjs&izNUt^HP%9EQod{ zCy#$ptf*Ma$tM^kxDiasl?xKBtyuL~2OMQZy&gy~T^n{~78kmTD1(w5=4#dPHOVR5I zT0un=0V;Dmkj5D)BaHd}t5<gd3(S6{}uWSu#Tw6j?fdwG0w>;6`uTO zAsdbBaf!ZUE-Abd6th4EhG`z}`VzSRj>&i)!>=k{!`OCEO~KWq)l?ck${I<;dCJVg zCcWp5pTG!(PjH7bq*zC?OrazEVY0X7h5gJcyj|%$VEPV+Ka*4@qlluo#;(VaXl(QooV?ek zhf!|#IH^=B&zs4C5+$g)Offk&$>X@$9LEy`9i`Bl1Q_NutNXJf$PNscQ&So4Hm_f` z+qYqs!Y8Td7}t(bkumkjNDWWSk>g)6B^S&g4vzeLqZeKa?d4b~8eidUOrf4ufLMwqk8zPWJ+nh_v2Up!CB;>k6iL zo880gm#650um@?hbH0Cw)PJDeOV$ztf#Co9 + + + + + + Remix + + +

+ This is a placeholder file you should never see, we'll rewrite all + requests to our azure function +

+ + diff --git a/templates/azure/public/staticwebapp.config.json b/templates/azure/public/staticwebapp.config.json new file mode 100644 index 00000000000..bb87234a918 --- /dev/null +++ b/templates/azure/public/staticwebapp.config.json @@ -0,0 +1,15 @@ +{ + "routes": [ + { + "route": "/", + "rewrite": "/api/azure" + }, + { + "route": "/index.html", + "rewrite": "/api/azure" + } + ], + "navigationFallback": { + "rewrite": "/api/azure" + } +} From fca6d0abb70b49de53ce3244e2ff233e2fe70803 Mon Sep 17 00:00:00 2001 From: Logan McAnsh Date: Thu, 19 Aug 2021 11:57:28 -0400 Subject: [PATCH 29/68] feat(azure): add support for dev for whatever reason in development, the `@azure/static-web-apps-cli` cli doesn't remove the original path from the rewrite, so we have to manually remove the `/api/azure` part. with that in mind, our azure function has to be named azure... --- packages/remix-azure/server.ts | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/packages/remix-azure/server.ts b/packages/remix-azure/server.ts index 9f77bb4c1a0..a45b258f926 100644 --- a/packages/remix-azure/server.ts +++ b/packages/remix-azure/server.ts @@ -75,7 +75,14 @@ export function createRemixHeaders( } export function createRemixRequest(req: HttpRequest): NodeRequest { - let url = req.headers["x-ms-original-url"]!; + let url: URL; + if (process.env.NODE_ENV === "production") { + url = new URL(req.headers["x-ms-original-url"]!); + } else { + url = new URL(req.url); + url.host = req.headers["host"]!; + url.pathname = url.pathname.replace("/api/azure", ""); + } let init: NodeRequestInit = { method: req.method || "GET", From fc6bcdb0c3946e74e90300c2cf18cd54b667ac94 Mon Sep 17 00:00:00 2001 From: Logan McAnsh Date: Thu, 19 Aug 2021 12:05:36 -0400 Subject: [PATCH 30/68] Revert "feat(azure): add support for dev" This reverts commit 82f4115de2288d7d328106dd4dea8418454f57b0. --- packages/remix-azure/server.ts | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/packages/remix-azure/server.ts b/packages/remix-azure/server.ts index a45b258f926..9f77bb4c1a0 100644 --- a/packages/remix-azure/server.ts +++ b/packages/remix-azure/server.ts @@ -75,14 +75,7 @@ export function createRemixHeaders( } export function createRemixRequest(req: HttpRequest): NodeRequest { - let url: URL; - if (process.env.NODE_ENV === "production") { - url = new URL(req.headers["x-ms-original-url"]!); - } else { - url = new URL(req.url); - url.host = req.headers["host"]!; - url.pathname = url.pathname.replace("/api/azure", ""); - } + let url = req.headers["x-ms-original-url"]!; let init: NodeRequestInit = { method: req.method || "GET", From 36070e9948d0b457d98c75678ba24de0489b1940 Mon Sep 17 00:00:00 2001 From: Aaron Powell Date: Mon, 28 Mar 2022 06:28:25 +0000 Subject: [PATCH 31/68] chore(CLA) --- contributors.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/contributors.yml b/contributors.yml index 4c632d504ae..8312616ea9b 100644 --- a/contributors.yml +++ b/contributors.yml @@ -1,3 +1,4 @@ +- aaronpowell - aaronpowell96 - aaronshaf - abereghici From 0bdbe0cf519f74cd37ea42a80aead8e1e7411efc Mon Sep 17 00:00:00 2001 From: Aaron Powell Date: Tue, 29 Mar 2022 04:31:24 +0000 Subject: [PATCH 32/68] chore: fix up from linting problems --- packages/remix-azure/__tests__/server-test.ts | 21 ++++++++-------- packages/remix-azure/magicExports/remix.ts | 7 ++++++ packages/remix-azure/server.ts | 24 +++++++++---------- templates/azure/remix.config.js | 2 +- 4 files changed, 30 insertions(+), 24 deletions(-) create mode 100644 packages/remix-azure/magicExports/remix.ts diff --git a/packages/remix-azure/__tests__/server-test.ts b/packages/remix-azure/__tests__/server-test.ts index 8782a0e980d..88fe2e7b0e2 100644 --- a/packages/remix-azure/__tests__/server-test.ts +++ b/packages/remix-azure/__tests__/server-test.ts @@ -5,21 +5,22 @@ import { Response } from "@remix-run/node"; import { createRemixHeaders, createRemixRequest, - createRequestHandler + createRequestHandler, } from "../server"; // We don't want to test that the remix server works here (that's what the // puppetteer tests do), we just want to test the azure adapter jest.mock("@remix-run/server-runtime"); -let mockedCreateRequestHandler = createRemixRequestHandler as jest.MockedFunction< - typeof createRemixRequestHandler ->; +let mockedCreateRequestHandler = + createRemixRequestHandler as jest.MockedFunction< + typeof createRemixRequestHandler + >; describe("azure createRequestHandler", () => { let context: Context; beforeEach(() => { - context = ({ log: jest.fn() } as unknown) as Context; + context = { log: jest.fn() } as unknown as Context; }); describe("basic requests", () => { @@ -32,7 +33,7 @@ describe("azure createRequestHandler", () => { }); it("handles requests", async () => { - mockedCreateRequestHandler.mockImplementation(() => async req => { + mockedCreateRequestHandler.mockImplementation(() => async (req) => { return new Response(`URL: ${new URL(req.url).pathname}`); }); @@ -41,11 +42,11 @@ describe("azure createRequestHandler", () => { url: "/foo/bar", rawBody: "", headers: { - "x-ms-original-url": "http://localhost:3000/foo/bar" + "x-ms-original-url": "http://localhost:3000/foo/bar", }, params: {}, query: {}, - body: "" + body: "", }; const res = await createRequestHandler({ build: undefined })( @@ -139,11 +140,11 @@ describe("azure createRemixRequest", () => { url: "/foo/bar", rawBody: "", headers: { - "x-ms-original-url": "http://localhost:3000/foo/bar" + "x-ms-original-url": "http://localhost:3000/foo/bar", }, params: {}, query: {}, - body: "" + body: "", }; expect(createRemixRequest(request)).toMatchInlineSnapshot(` diff --git a/packages/remix-azure/magicExports/remix.ts b/packages/remix-azure/magicExports/remix.ts new file mode 100644 index 00000000000..13af755e242 --- /dev/null +++ b/packages/remix-azure/magicExports/remix.ts @@ -0,0 +1,7 @@ +// Re-export everything from this package that is available in `remix`. + +export { + RequestHandler, + createRequestHandler, + GetLoadContextFunction, +} from "@remix-run/azure"; diff --git a/packages/remix-azure/server.ts b/packages/remix-azure/server.ts index 9f77bb4c1a0..8a2e4f59312 100644 --- a/packages/remix-azure/server.ts +++ b/packages/remix-azure/server.ts @@ -2,20 +2,18 @@ import type { AzureFunction, Context, HttpRequest, - HttpRequestHeaders + HttpRequestHeaders, } from "@azure/functions"; -import type { - AppLoadContext, - ServerBuild, - ServerPlatform -} from "@remix-run/server-runtime"; +import type { AppLoadContext, ServerBuild } from "@remix-run/server-runtime"; import { createRequestHandler as createRemixRequestHandler } from "@remix-run/server-runtime"; import { formatServerError, Headers as NodeHeaders, Request as NodeRequest, +} from "@remix-run/node"; +import type { Response as NodeResponse, - RequestInit as NodeRequestInit + RequestInit as NodeRequestInit, } from "@remix-run/node"; /** @@ -35,7 +33,7 @@ export type RequestHandler = ReturnType; export function createRequestHandler({ build, getLoadContext, - mode = process.env.NODE_ENV + mode = process.env.NODE_ENV, }: { build: ServerBuild; getLoadContext?: GetLoadContextFunction; @@ -48,15 +46,15 @@ export function createRequestHandler({ let request = createRemixRequest(req); let loadContext = getLoadContext ? getLoadContext(req) : undefined; - let response = ((await handleRequest( - (request as unknown) as Request, + let response = (await handleRequest( + request as unknown as Request, loadContext - )) as unknown) as NodeResponse; + )) as unknown as NodeResponse; return { status: response.status, headers: response.headers.raw(), - body: await response.text() + body: await response.text(), }; }; } @@ -79,7 +77,7 @@ export function createRemixRequest(req: HttpRequest): NodeRequest { let init: NodeRequestInit = { method: req.method || "GET", - headers: createRemixHeaders(req.headers) + headers: createRemixHeaders(req.headers), }; if (req.body && req.method !== "GET" && req.method !== "HEAD") { diff --git a/templates/azure/remix.config.js b/templates/azure/remix.config.js index fff35829093..3957ec73b97 100644 --- a/templates/azure/remix.config.js +++ b/templates/azure/remix.config.js @@ -3,5 +3,5 @@ module.exports = { browserBuildDirectory: "public/build", publicPath: "/build/", serverBuildDirectory: "azure/function/build", - devServerPort: 8002 + devServerPort: 8002, }; From 369ee577597bdca5625cf1025a49ed0dad38c84f Mon Sep 17 00:00:00 2001 From: Aaron Powell Date: Tue, 29 Mar 2022 05:30:04 +0000 Subject: [PATCH 33/68] fix: better package name and sample app --- package.json | 1 + .../__tests__/server-test.ts | 0 .../globals.ts | 0 .../index.ts | 0 .../jest.config.js | 2 +- .../magicExports/remix.ts | 2 +- .../package.json | 4 +-- .../rollup.config.js | 2 +- .../server.ts | 0 .../tsconfig.json | 0 rollup.utils.js | 2 +- templates/azure/app/entry.client.tsx | 4 +++ templates/azure/app/entry.server.tsx | 21 ++++++++++++ templates/azure/app/root.tsx | 32 +++++++++++++++++++ templates/azure/app/routes/index.tsx | 32 +++++++++++++++++++ templates/azure/gitignore | 1 + templates/azure/package.json | 8 ++--- 17 files changed, 101 insertions(+), 10 deletions(-) rename packages/{remix-azure => remix-azure-functions}/__tests__/server-test.ts (100%) rename packages/{remix-azure => remix-azure-functions}/globals.ts (100%) rename packages/{remix-azure => remix-azure-functions}/index.ts (100%) rename packages/{remix-azure => remix-azure-functions}/jest.config.js (79%) rename packages/{remix-azure => remix-azure-functions}/magicExports/remix.ts (80%) rename packages/{remix-azure => remix-azure-functions}/package.json (76%) rename packages/{remix-azure => remix-azure-functions}/rollup.config.js (76%) rename packages/{remix-azure => remix-azure-functions}/server.ts (100%) rename packages/{remix-azure => remix-azure-functions}/tsconfig.json (100%) create mode 100644 templates/azure/app/entry.client.tsx create mode 100644 templates/azure/app/entry.server.tsx create mode 100644 templates/azure/app/root.tsx create mode 100644 templates/azure/app/routes/index.tsx diff --git a/package.json b/package.json index bfc025cf954..5a6477bc3b8 100644 --- a/package.json +++ b/package.json @@ -6,6 +6,7 @@ "packages/create-remix", "packages/remix", "packages/remix-architect", + "packages/remix-azure-functions", "packages/remix-cloudflare", "packages/remix-cloudflare-pages", "packages/remix-cloudflare-workers", diff --git a/packages/remix-azure/__tests__/server-test.ts b/packages/remix-azure-functions/__tests__/server-test.ts similarity index 100% rename from packages/remix-azure/__tests__/server-test.ts rename to packages/remix-azure-functions/__tests__/server-test.ts diff --git a/packages/remix-azure/globals.ts b/packages/remix-azure-functions/globals.ts similarity index 100% rename from packages/remix-azure/globals.ts rename to packages/remix-azure-functions/globals.ts diff --git a/packages/remix-azure/index.ts b/packages/remix-azure-functions/index.ts similarity index 100% rename from packages/remix-azure/index.ts rename to packages/remix-azure-functions/index.ts diff --git a/packages/remix-azure/jest.config.js b/packages/remix-azure-functions/jest.config.js similarity index 79% rename from packages/remix-azure/jest.config.js rename to packages/remix-azure-functions/jest.config.js index 05fd7594ed4..6d55c862313 100644 --- a/packages/remix-azure/jest.config.js +++ b/packages/remix-azure-functions/jest.config.js @@ -1,5 +1,5 @@ /** @type {import('@jest/types').Config.InitialOptions} */ module.exports = { ...require("../../jest/jest.config.shared"), - displayName: "azure", + displayName: "azure-functions", }; diff --git a/packages/remix-azure/magicExports/remix.ts b/packages/remix-azure-functions/magicExports/remix.ts similarity index 80% rename from packages/remix-azure/magicExports/remix.ts rename to packages/remix-azure-functions/magicExports/remix.ts index 13af755e242..5313959a9f6 100644 --- a/packages/remix-azure/magicExports/remix.ts +++ b/packages/remix-azure-functions/magicExports/remix.ts @@ -4,4 +4,4 @@ export { RequestHandler, createRequestHandler, GetLoadContextFunction, -} from "@remix-run/azure"; +} from "@remix-run/azure-functions"; diff --git a/packages/remix-azure/package.json b/packages/remix-azure-functions/package.json similarity index 76% rename from packages/remix-azure/package.json rename to packages/remix-azure-functions/package.json index 177a649a44c..51dba74cf74 100644 --- a/packages/remix-azure/package.json +++ b/packages/remix-azure-functions/package.json @@ -1,6 +1,6 @@ { - "name": "@remix-run/azure", - "description": "Azure server request handler for Remix", + "name": "@remix-run/azure-functions", + "description": "Azure Functions server request handler for Remix", "version": "0.17.5", "repository": "https://github.com/remix-run/packages", "dependencies": { diff --git a/packages/remix-azure/rollup.config.js b/packages/remix-azure-functions/rollup.config.js similarity index 76% rename from packages/remix-azure/rollup.config.js rename to packages/remix-azure-functions/rollup.config.js index ec8b73d2dd4..a7e5bd46427 100644 --- a/packages/remix-azure/rollup.config.js +++ b/packages/remix-azure-functions/rollup.config.js @@ -2,5 +2,5 @@ const { getAdapterConfig } = require("../../rollup.utils"); /** @returns {import("rollup").RollupOptions[]} */ module.exports = function rollup() { - return [getAdapterConfig("azure")]; + return [getAdapterConfig("azure-functions")]; }; diff --git a/packages/remix-azure/server.ts b/packages/remix-azure-functions/server.ts similarity index 100% rename from packages/remix-azure/server.ts rename to packages/remix-azure-functions/server.ts diff --git a/packages/remix-azure/tsconfig.json b/packages/remix-azure-functions/tsconfig.json similarity index 100% rename from packages/remix-azure/tsconfig.json rename to packages/remix-azure-functions/tsconfig.json diff --git a/rollup.utils.js b/rollup.utils.js index 9d6e6e24058..66c479fa2b1 100644 --- a/rollup.utils.js +++ b/rollup.utils.js @@ -419,7 +419,7 @@ module.exports = { /** * @typedef {Record} MagicExports - * @typedef {"architect" | "azure" | "cloudflare-pages" | "cloudflare-workers" | "express" | "netlify" | "vercel"} RemixAdapter + * @typedef {"architect" | "azure-functions" | "cloudflare-pages" | "cloudflare-workers" | "express" | "netlify" | "vercel"} RemixAdapter * @typedef {"cloudflare" | "node" | "deno"} RemixRuntime * @typedef {`@remix-run/${RemixAdapter | RemixRuntime | "dev" | "eslint-config" | "react" | "serve" | "server-runtime"}`} ScopedRemixPackage * @typedef {"create-remix" | "remix" | ScopedRemixPackage} RemixPackage diff --git a/templates/azure/app/entry.client.tsx b/templates/azure/app/entry.client.tsx new file mode 100644 index 00000000000..a19979b2527 --- /dev/null +++ b/templates/azure/app/entry.client.tsx @@ -0,0 +1,4 @@ +import { hydrate } from "react-dom"; +import { RemixBrowser } from "remix"; + +hydrate(, document); diff --git a/templates/azure/app/entry.server.tsx b/templates/azure/app/entry.server.tsx new file mode 100644 index 00000000000..cef2e81af71 --- /dev/null +++ b/templates/azure/app/entry.server.tsx @@ -0,0 +1,21 @@ +import { renderToString } from "react-dom/server"; +import { RemixServer } from "remix"; +import type { EntryContext } from "remix"; + +export default function handleRequest( + request: Request, + responseStatusCode: number, + responseHeaders: Headers, + remixContext: EntryContext +) { + let markup = renderToString( + + ); + + responseHeaders.set("Content-Type", "text/html"); + + return new Response("" + markup, { + status: responseStatusCode, + headers: responseHeaders, + }); +} diff --git a/templates/azure/app/root.tsx b/templates/azure/app/root.tsx new file mode 100644 index 00000000000..471e0ac0d57 --- /dev/null +++ b/templates/azure/app/root.tsx @@ -0,0 +1,32 @@ +import { + Links, + LiveReload, + Meta, + Outlet, + Scripts, + ScrollRestoration, +} from "remix"; +import type { MetaFunction } from "remix"; + +export const meta: MetaFunction = () => ({ + charset: "utf-8", + title: "New Remix App", + viewport: "width=device-width,initial-scale=1", +}); + +export default function App() { + return ( + + + + + + + + + + + + + ); +} diff --git a/templates/azure/app/routes/index.tsx b/templates/azure/app/routes/index.tsx new file mode 100644 index 00000000000..cbca6124ea7 --- /dev/null +++ b/templates/azure/app/routes/index.tsx @@ -0,0 +1,32 @@ +export default function Index() { + return ( + + ); +} diff --git a/templates/azure/gitignore b/templates/azure/gitignore index ed7790835c9..860617c3853 100644 --- a/templates/azure/gitignore +++ b/templates/azure/gitignore @@ -3,3 +3,4 @@ node_modules /.cache /azure/function/build /public/build +local.settings.json diff --git a/templates/azure/package.json b/templates/azure/package.json index 74dfac58502..16c66c8dd92 100644 --- a/templates/azure/package.json +++ b/templates/azure/package.json @@ -4,11 +4,11 @@ "dev": "swa start ./public --run \"remix dev\" --api ." }, "dependencies": { - "@remix-run/express": "*", + "@remix-run/azure-functions": "*", "@remix-run/node": "*" }, "devDependencies": { - "@azure/functions": "^1.2.3", - "@azure/static-web-apps-cli": "^0.6.1" + "@azure/functions": "^3.0.0", + "@azure/static-web-apps-cli": "^0.8.3" } -} +} \ No newline at end of file From e37e686c1bffcd0d5d8714f1e8ead3f85cec3f95 Mon Sep 17 00:00:00 2001 From: Aaron Powell Date: Tue, 29 Mar 2022 06:21:29 +0000 Subject: [PATCH 34/68] renamed the template --- .../gitignore => azure-functions/.gitignore} | 0 .../{azure => azure-functions}/README.md | 0 .../app/entry.client.tsx | 0 .../app/entry.server.tsx | 0 .../{azure => azure-functions}/app/root.tsx | 0 .../app/routes/index.tsx | 0 .../azure/function.json | 0 .../azure/function/index.js | 0 .../github-actions/azure-static-web-apps.yml | 0 .../{azure => azure-functions}/host.json | 0 templates/azure-functions/package.json | 22 ++++++++++++++++++ .../public/favicon.png | Bin .../public/index.html | 0 .../public/staticwebapp.config.json | 0 .../remix.config.js | 0 templates/azure/local.settings.json | 7 ------ templates/azure/package.json | 14 ----------- 17 files changed, 22 insertions(+), 21 deletions(-) rename templates/{azure/gitignore => azure-functions/.gitignore} (100%) rename templates/{azure => azure-functions}/README.md (100%) rename templates/{azure => azure-functions}/app/entry.client.tsx (100%) rename templates/{azure => azure-functions}/app/entry.server.tsx (100%) rename templates/{azure => azure-functions}/app/root.tsx (100%) rename templates/{azure => azure-functions}/app/routes/index.tsx (100%) rename templates/{azure => azure-functions}/azure/function.json (100%) rename templates/{azure => azure-functions}/azure/function/index.js (100%) rename templates/{azure => azure-functions}/github-actions/azure-static-web-apps.yml (100%) rename templates/{azure => azure-functions}/host.json (100%) create mode 100644 templates/azure-functions/package.json rename templates/{azure => azure-functions}/public/favicon.png (100%) rename templates/{azure => azure-functions}/public/index.html (100%) rename templates/{azure => azure-functions}/public/staticwebapp.config.json (100%) rename templates/{azure => azure-functions}/remix.config.js (100%) delete mode 100644 templates/azure/local.settings.json delete mode 100644 templates/azure/package.json diff --git a/templates/azure/gitignore b/templates/azure-functions/.gitignore similarity index 100% rename from templates/azure/gitignore rename to templates/azure-functions/.gitignore diff --git a/templates/azure/README.md b/templates/azure-functions/README.md similarity index 100% rename from templates/azure/README.md rename to templates/azure-functions/README.md diff --git a/templates/azure/app/entry.client.tsx b/templates/azure-functions/app/entry.client.tsx similarity index 100% rename from templates/azure/app/entry.client.tsx rename to templates/azure-functions/app/entry.client.tsx diff --git a/templates/azure/app/entry.server.tsx b/templates/azure-functions/app/entry.server.tsx similarity index 100% rename from templates/azure/app/entry.server.tsx rename to templates/azure-functions/app/entry.server.tsx diff --git a/templates/azure/app/root.tsx b/templates/azure-functions/app/root.tsx similarity index 100% rename from templates/azure/app/root.tsx rename to templates/azure-functions/app/root.tsx diff --git a/templates/azure/app/routes/index.tsx b/templates/azure-functions/app/routes/index.tsx similarity index 100% rename from templates/azure/app/routes/index.tsx rename to templates/azure-functions/app/routes/index.tsx diff --git a/templates/azure/azure/function.json b/templates/azure-functions/azure/function.json similarity index 100% rename from templates/azure/azure/function.json rename to templates/azure-functions/azure/function.json diff --git a/templates/azure/azure/function/index.js b/templates/azure-functions/azure/function/index.js similarity index 100% rename from templates/azure/azure/function/index.js rename to templates/azure-functions/azure/function/index.js diff --git a/templates/azure/github-actions/azure-static-web-apps.yml b/templates/azure-functions/github-actions/azure-static-web-apps.yml similarity index 100% rename from templates/azure/github-actions/azure-static-web-apps.yml rename to templates/azure-functions/github-actions/azure-static-web-apps.yml diff --git a/templates/azure/host.json b/templates/azure-functions/host.json similarity index 100% rename from templates/azure/host.json rename to templates/azure-functions/host.json diff --git a/templates/azure-functions/package.json b/templates/azure-functions/package.json new file mode 100644 index 00000000000..3f0cae355fa --- /dev/null +++ b/templates/azure-functions/package.json @@ -0,0 +1,22 @@ +{ + "scripts": { + "build": "remix build", + "dev": "swa start ./public --run \"remix dev\" --api ." + }, + "dependencies": { + "@remix-run/azure-functions": "*", + "@remix-run/node": "*", + "@remix-run/react": "*", + "remix": "*" + }, + "devDependencies": { + "@azure/functions": "^3.0.0", + "@azure/static-web-apps-cli": "^0.8.3", + "@remix-run/dev": "*", + "@remix-run/eslint-config": "*", + "@types/react": "^17.0.24", + "@types/react-dom": "^17.0.9", + "eslint": "^8.11.0", + "npm-run-all": "^4.1.5" + } +} \ No newline at end of file diff --git a/templates/azure/public/favicon.png b/templates/azure-functions/public/favicon.png similarity index 100% rename from templates/azure/public/favicon.png rename to templates/azure-functions/public/favicon.png diff --git a/templates/azure/public/index.html b/templates/azure-functions/public/index.html similarity index 100% rename from templates/azure/public/index.html rename to templates/azure-functions/public/index.html diff --git a/templates/azure/public/staticwebapp.config.json b/templates/azure-functions/public/staticwebapp.config.json similarity index 100% rename from templates/azure/public/staticwebapp.config.json rename to templates/azure-functions/public/staticwebapp.config.json diff --git a/templates/azure/remix.config.js b/templates/azure-functions/remix.config.js similarity index 100% rename from templates/azure/remix.config.js rename to templates/azure-functions/remix.config.js diff --git a/templates/azure/local.settings.json b/templates/azure/local.settings.json deleted file mode 100644 index 4e3da2cc65c..00000000000 --- a/templates/azure/local.settings.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "IsEncrypted": false, - "Values": { - "AzureWebJobsStorage": "", - "FUNCTIONS_WORKER_RUNTIME": "node" - } -} diff --git a/templates/azure/package.json b/templates/azure/package.json deleted file mode 100644 index 16c66c8dd92..00000000000 --- a/templates/azure/package.json +++ /dev/null @@ -1,14 +0,0 @@ -{ - "scripts": { - "build": "remix build", - "dev": "swa start ./public --run \"remix dev\" --api ." - }, - "dependencies": { - "@remix-run/azure-functions": "*", - "@remix-run/node": "*" - }, - "devDependencies": { - "@azure/functions": "^3.0.0", - "@azure/static-web-apps-cli": "^0.8.3" - } -} \ No newline at end of file From 32bb27f568724a0f73ee7515eef235f52fc3d9ac Mon Sep 17 00:00:00 2001 From: Aaron Powell Date: Tue, 29 Mar 2022 23:32:15 +0000 Subject: [PATCH 35/68] tweaking the deps and adding ts --- templates/azure-functions/package.json | 2 ++ templates/azure-functions/tsconfig.json | 20 ++++++++++++++++++++ 2 files changed, 22 insertions(+) create mode 100644 templates/azure-functions/tsconfig.json diff --git a/templates/azure-functions/package.json b/templates/azure-functions/package.json index 3f0cae355fa..a63cef80a82 100644 --- a/templates/azure-functions/package.json +++ b/templates/azure-functions/package.json @@ -7,6 +7,8 @@ "@remix-run/azure-functions": "*", "@remix-run/node": "*", "@remix-run/react": "*", + "react": "^17.0.2", + "react-dom": "^17.0.2", "remix": "*" }, "devDependencies": { diff --git a/templates/azure-functions/tsconfig.json b/templates/azure-functions/tsconfig.json new file mode 100644 index 00000000000..749e4b959e8 --- /dev/null +++ b/templates/azure-functions/tsconfig.json @@ -0,0 +1,20 @@ +{ + "include": ["remix.env.d.ts", "**/*.ts", "**/*.tsx"], + "compilerOptions": { + "lib": ["DOM", "DOM.Iterable", "ES2019"], + "isolatedModules": true, + "esModuleInterop": true, + "jsx": "react-jsx", + "moduleResolution": "node", + "resolveJsonModule": true, + "target": "ES2019", + "strict": true, + "baseUrl": ".", + "paths": { + "~/*": ["./app/*"] + }, + + // Remix takes care of building everything in `remix build`. + "noEmit": true + } +} From 19a1f6dba78839e70562859f78431f36d70e880c Mon Sep 17 00:00:00 2001 From: Aaron Powell Date: Tue, 29 Mar 2022 23:32:55 +0000 Subject: [PATCH 36/68] fix: forgot typescript dep --- templates/azure-functions/package.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/templates/azure-functions/package.json b/templates/azure-functions/package.json index a63cef80a82..00d4391c13f 100644 --- a/templates/azure-functions/package.json +++ b/templates/azure-functions/package.json @@ -19,6 +19,7 @@ "@types/react": "^17.0.24", "@types/react-dom": "^17.0.9", "eslint": "^8.11.0", - "npm-run-all": "^4.1.5" + "npm-run-all": "^4.1.5", + "typescript": "4.6.3" } } \ No newline at end of file From 27df6b173c09b2a8a66b5e94711bf24cd46dd4e3 Mon Sep 17 00:00:00 2001 From: Aaron Powell Date: Wed, 30 Mar 2022 01:24:57 +0000 Subject: [PATCH 37/68] fix: adding function tools as a dependency --- templates/azure-functions/package.json | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/templates/azure-functions/package.json b/templates/azure-functions/package.json index 00d4391c13f..ef049e9f01d 100644 --- a/templates/azure-functions/package.json +++ b/templates/azure-functions/package.json @@ -1,7 +1,8 @@ { "scripts": { "build": "remix build", - "dev": "swa start ./public --run \"remix dev\" --api ." + "dev": "swa start ./public --run \"remix dev\" --api .", + "postinstall": "func init" }, "dependencies": { "@remix-run/azure-functions": "*", @@ -18,6 +19,7 @@ "@remix-run/eslint-config": "*", "@types/react": "^17.0.24", "@types/react-dom": "^17.0.9", + "azure-functions-core-tools": "4.0.3971", "eslint": "^8.11.0", "npm-run-all": "^4.1.5", "typescript": "4.6.3" From 7f152ff90c30c2a25661812f621fa3d78d3cd8b7 Mon Sep 17 00:00:00 2001 From: Aaron Powell Date: Wed, 30 Mar 2022 01:38:19 +0000 Subject: [PATCH 38/68] fix: forgot to set worker/language on init to avoid prompting --- templates/azure-functions/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/templates/azure-functions/package.json b/templates/azure-functions/package.json index ef049e9f01d..587ece3698a 100644 --- a/templates/azure-functions/package.json +++ b/templates/azure-functions/package.json @@ -2,7 +2,7 @@ "scripts": { "build": "remix build", "dev": "swa start ./public --run \"remix dev\" --api .", - "postinstall": "func init" + "postinstall": "func init --worker-runtime node --language typescript" }, "dependencies": { "@remix-run/azure-functions": "*", From 49e463c3ddfc32eb0bd878d7c33feb4cc49b318b Mon Sep 17 00:00:00 2001 From: Aaron Powell Date: Wed, 30 Mar 2022 01:39:40 +0000 Subject: [PATCH 39/68] fix: bad merge on styling doc --- docs/guides/styling.md | 2 -- 1 file changed, 2 deletions(-) diff --git a/docs/guides/styling.md b/docs/guides/styling.md index 17233030da0..263edb2365f 100644 --- a/docs/guides/styling.md +++ b/docs/guides/styling.md @@ -754,8 +754,6 @@ Here's some sample code to show how you might use Styled Components with Remix ( responseHeaders.set("Content-Type", "text/html"); - responseHeaders.set("Content-Type", "text/html") - return new Response("" + markup, { status: responseStatusCode, headers: responseHeaders, From bc19122280ff2e2f0bbfc0c9ca70739544a6710c Mon Sep 17 00:00:00 2001 From: Aaron Powell Date: Wed, 30 Mar 2022 13:36:07 +1100 Subject: [PATCH 40/68] Apply suggestions from code review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Michaël De Boey --- packages/remix-azure-functions/server.ts | 8 +++----- templates/azure-functions/.gitignore | 2 ++ 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/packages/remix-azure-functions/server.ts b/packages/remix-azure-functions/server.ts index 8a2e4f59312..26d2c334fff 100644 --- a/packages/remix-azure-functions/server.ts +++ b/packages/remix-azure-functions/server.ts @@ -24,11 +24,9 @@ import type { * environment/platform-specific values through to your loader/action, such as * values that are generated by Express middleware like `req.session`. */ -export interface GetLoadContextFunction { - (req: HttpRequest): AppLoadContext; -} +export type GetLoadContextFunction = (req: HttpRequest) => AppLoadContext; -export type RequestHandler = ReturnType; +export type RequestHandler = AzureFunction; export function createRequestHandler({ build, @@ -38,7 +36,7 @@ export function createRequestHandler({ build: ServerBuild; getLoadContext?: GetLoadContextFunction; mode?: string; -}): AzureFunction { +}): RequestHandler { let platform: ServerPlatform = { formatServerError }; let handleRequest = createRemixRequestHandler(build, platform, mode); diff --git a/templates/azure-functions/.gitignore b/templates/azure-functions/.gitignore index 860617c3853..fba2dd83f63 100644 --- a/templates/azure-functions/.gitignore +++ b/templates/azure-functions/.gitignore @@ -3,4 +3,6 @@ node_modules /.cache /azure/function/build /public/build +.env + local.settings.json From 0bac7936323ce37bacef04bca1c1dcc7e842e21d Mon Sep 17 00:00:00 2001 From: Aaron Powell Date: Wed, 30 Mar 2022 02:38:19 +0000 Subject: [PATCH 41/68] fix: missing .eslintrc and wrong favicon --- templates/azure-functions/.eslintrc | 3 +++ templates/azure-functions/public/favicon.ico | Bin 0 -> 16958 bytes templates/azure-functions/public/favicon.png | Bin 1988 -> 0 bytes 3 files changed, 3 insertions(+) create mode 100644 templates/azure-functions/.eslintrc create mode 100644 templates/azure-functions/public/favicon.ico delete mode 100644 templates/azure-functions/public/favicon.png diff --git a/templates/azure-functions/.eslintrc b/templates/azure-functions/.eslintrc new file mode 100644 index 00000000000..8828ca31d3a --- /dev/null +++ b/templates/azure-functions/.eslintrc @@ -0,0 +1,3 @@ +{ + "extends": ["@remix-run/eslint-config"] +} diff --git a/templates/azure-functions/public/favicon.ico b/templates/azure-functions/public/favicon.ico new file mode 100644 index 0000000000000000000000000000000000000000..8830cf6821b354114848e6354889b8ecf6d2bc61 GIT binary patch literal 16958 zcmeI3+jCXb9mnJN2h^uNlXH@jlam{_a8F3W{T}Wih>9YJpaf7TUbu)A5fv|h7OMfR zR;q$lr&D!wv|c)`wcw1?>4QT1(&|jdsrI2h`Rn)dTW5t$8pz=s3_5L?#oBxAowe8R z_WfPfN?F+@`q$D@rvC?(W!uWieppskmQ~YG*>*L?{img@tWpnYXZslxeh#TSUS3{q z1Ju6JcfQSbQuORq69@YK(X-3c9vC2c2a2z~zw=F=50@pm0PUiCAm!bAT?2jpM`(^b zC|2&Ngngt^<>oCv#?P(AZ`5_84x#QBPulix)TpkIAUp=(KgGo4CVS~Sxt zVoR4>r5g9%bDh7hi0|v$={zr>CHd`?-l4^Ld(Z9PNz9piFY+llUw_x4ou7Vf-q%$g z)&)J4>6Ft~RZ(uV>dJD|`nxI1^x{X@Z5S<=vf;V3w_(*O-7}W<=e$=}CB9_R;)m9)d7`d_xx+nl^Bg|%ew=?uoKO8w zeQU7h;~8s!@9-k>7Cx}1SDQ7m(&miH zs8!l*wOJ!GHbdh)pD--&W3+w`9YJ=;m^FtMY=`mTq8pyV!-@L6smwp3(q?G>=_4v^ zn(ikLue7!y70#2uhqUVpb7fp!=xu2{aM^1P^pts#+feZv8d~)2sf`sjXLQCEj;pdI z%~f`JOO;*KnziMv^i_6+?mL?^wrE_&=IT9o1i!}Sd4Sx4O@w~1bi1)8(sXvYR-1?7~Zr<=SJ1Cw!i~yfi=4h6o3O~(-Sb2Ilwq%g$+V` z>(C&N1!FV5rWF&iwt8~b)=jIn4b!XbrWrZgIHTISrdHcpjjx=TwJXI7_%Ks4oFLl9 zNT;!%!P4~xH85njXdfqgnIxIFOOKW`W$fxU%{{5wZkVF^G=JB$oUNU5dQSL&ZnR1s z*ckJ$R`eCUJsWL>j6*+|2S1TL_J|Fl&kt=~XZF=+=iT0Xq1*KU-NuH%NAQff$LJp3 zU_*a;@7I0K{mqwux87~vwsp<}@P>KNDb}3U+6$rcZ114|QTMUSk+rhPA(b{$>pQTc zIQri{+U>GMzsCy0Mo4BfWXJlkk;RhfpWpAB{=Rtr*d1MNC+H3Oi5+3D$gUI&AjV-1 z=0ZOox+bGyHe=yk-yu%=+{~&46C$ut^ZN+ysx$NH}*F43)3bKkMsxGyIl#>7Yb8W zO{}&LUO8Ow{7>!bvSq?X{15&Y|4}0w2=o_^0ZzYgB+4HhZ4>s*mW&?RQ6&AY|CPcx z$*LjftNS|H)ePYnIKNg{ck*|y7EJ&Co0ho0K`!{ENPkASeKy-JWE}dF_%}j)Z5a&q zXAI2gPu6`s-@baW=*+keiE$ALIs5G6_X_6kgKK8n3jH2-H9`6bo)Qn1 zZ2x)xPt1=`9V|bE4*;j9$X20+xQCc$rEK|9OwH-O+Q*k`ZNw}K##SkY z3u}aCV%V|j@!gL5(*5fuWo>JFjeU9Qqk`$bdwH8(qZovE2tA7WUpoCE=VKm^eZ|vZ z(k<+j*mGJVah>8CkAsMD6#I$RtF;#57Wi`c_^k5?+KCmX$;Ky2*6|Q^bJ8+s%2MB}OH-g$Ev^ zO3uqfGjuN%CZiu<`aCuKCh{kK!dDZ+CcwgIeU2dsDfz+V>V3BDb~)~ zO!2l!_)m;ZepR~sL+-~sHS7;5ZB|~uUM&&5vDda2b z)CW8S6GI*oF><|ZeY5D^+Mcsri)!tmrM33qvwI4r9o@(GlW!u2R>>sB|E#%W`c*@5 z|0iA|`{6aA7D4Q?vc1{vT-#yytn07`H!QIO^1+X7?zG3%y0gPdIPUJ#s*DNAwd}m1_IMN1^T&be~+E z_z%1W^9~dl|Me9U6+3oNyuMDkF*z_;dOG(Baa*yq;TRiw{EO~O_S6>e*L(+Cdu(TM z@o%xTCV%hi&p)x3_inIF!b|W4|AF5p?y1j)cr9RG@v%QVaN8&LaorC-kJz_ExfVHB za!mtuee#Vb?dh&bwrfGHYAiX&&|v$}U*UBM;#F!N=x>x|G5s0zOa9{(`=k4v^6iK3 z8d&=O@xhDs{;v7JQ%eO;!Bt`&*MH&d zp^K#dkq;jnJz%%bsqwlaKA5?fy zS5JDbO#BgSAdi8NM zDo2SifX6^Z;vn>cBh-?~r_n9qYvP|3ihrnqq6deS-#>l#dV4mX|G%L8|EL;$U+w69 z;rTK3FW$ewUfH|R-Z;3;jvpfiDm?Fvyu9PeR>wi|E8>&j2Z@2h`U}|$>2d`BPV3pz#ViIzH8v6pP^L-p!GbLv<;(p>}_6u&E6XO5- zJ8JEvJ1)0>{iSd|kOQn#?0rTYL=KSmgMHCf$Qbm;7|8d(goD&T-~oCDuZf57iP#_Y zmxaoOSjQsm*^u+m$L9AMqwi=6bpdiAY6k3akjGN{xOZ`_J<~Puyzpi7yhhKrLmXV; z@ftONPy;Uw1F#{_fyGbk04yLE01v=i_5`RqQP+SUH0nb=O?l!J)qCSTdsbmjFJrTm zx4^ef@qt{B+TV_OHOhtR?XT}1Etm(f21;#qyyW6FpnM+S7*M1iME?9fe8d-`Q#InN z?^y{C_|8bxgUE@!o+Z72C)BrS&5D`gb-X8kq*1G7Uld-z19V}HY~mK#!o9MC-*#^+ znEsdc-|jj0+%cgBMy(cEkq4IQ1D*b;17Lyp>Utnsz%LRTfjQKL*vo(yJxwtw^)l|! z7jhIDdtLB}mpkOIG&4@F+9cYkS5r%%jz}I0R#F4oBMf-|Jmmk* zk^OEzF%}%5{a~kGYbFjV1n>HKC+a`;&-n*v_kD2DPP~n5(QE3C;30L<32GB*qV2z$ zWR1Kh=^1-q)P37WS6YWKlUSDe=eD^u_CV+P)q!3^{=$#b^auGS7m8zFfFS<>(e~)TG z&uwWhSoetoe!1^%)O}=6{SUcw-UQmw+i8lokRASPsbT=H|4D|( zk^P7>TUEFho!3qXSWn$m2{lHXw zD>eN6-;wwq9(?@f^F4L2Ny5_6!d~iiA^s~(|B*lbZir-$&%)l>%Q(36yOIAu|326K ztmBWz|MLA{Kj(H_{w2gd*nZ6a@ma(w==~EHIscEk|C=NGJa%Ruh4_+~f|%rt{I5v* zIX@F?|KJID56-ivb+PLo(9hn_CdK{irOcL15>JNQFY112^$+}JPyI{uQ~$&E*=ri; z`d^fH?4f=8vKHT4!p9O*fX(brB75Y9?e>T9=X#Fc@V#%@5^)~#zu5I(=>LQA-EGTS zecy*#6gG+8lapch#Hh%vl(+}J;Q!hC1OKoo;#h3#V%5Js)tQ)|>pTT@1ojd+F9Gey zg`B)zm`|Mo%tH31s4=<+`Pu|B3orXwNyIcNN>;fBkIj^X8P}RXhF= zXQK1u5RLN7k#_Q(KznJrALtMM13!vhfr025ar?@-%{l|uWt@NEd<$~n>RQL{ z+o;->n)+~0tt(u|o_9h!T`%M8%)w2awpV9b*xz9Pl-daUJm3y-HT%xg`^mFd6LBeL z!0~s;zEr)Bn9x)I(wx`;JVwvRcc^io2XX(Nn3vr3dgbrr@YJ?K3w18P*52^ieBCQP z=Up1V$N2~5ppJHRTeY8QfM(7Yv&RG7oWJAyv?c3g(29)P)u;_o&w|&)HGDIinXT~p z3;S|e$=&Tek9Wn!`cdY+d-w@o`37}x{(hl>ykB|%9yB$CGdIcl7Z?d&lJ%}QHck77 zJPR%C+s2w1_Dl_pxu6$Zi!`HmoD-%7OD@7%lKLL^Ixd9VlRSW*o&$^iQ2z+}hTgH) z#91TO#+jH<`w4L}XWOt(`gqM*uTUcky`O(mEyU|4dJoy6*UZJ7%*}ajuos%~>&P2j zk23f5<@GeV?(?`l=ih+D8t`d72xrUjv0wsg;%s1@*2p?TQ;n2$pV7h?_T%sL>iL@w zZ{lmc<|B7!e&o!zs6RW+u8+aDyUdG>ZS(v&rT$QVymB7sEC@VsK1dg^3F@K90-wYB zX!we79qx`(6LA>F$~{{xE8-3Wzyfe`+Lsce(?uj{k@lb97YTJt#>l*Z&LyKX@zjmu?UJC9w~;|NsB{%7G}y*uNDBxirfC EKbET!0{{R3 literal 0 HcmV?d00001 diff --git a/templates/azure-functions/public/favicon.png b/templates/azure-functions/public/favicon.png deleted file mode 100644 index 188762f08ce87a5eb22685cd4c5b787cbee05586..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 1988 zcmV;#2RrzQP)`D{TR5DNyKh+L=CP?)Cf5o!icIV1;_x zGw0lM&i%jteE;K|YvCTn^E|7)y?w9iy3et8S(dedV=1;#wjsV^-QzV4d0dm@nhe`J zY_Hq4-NSmKudnYk$GnyAl?iHUYI=$bKjzCFD;Gb=GiCNt=E1?i!Jmrd*ueuQt>)(D zcewD(zYQ)7$&_qi2rIx{>J%p43nol!Q$JHJc=u(!@P@|~lID_S_TjpITO!bZpd#-M z3=F)lC!;`tcI{mD)qC#YMl(<;xVI z0`ikRGDk>sw6wIy=03QD3B0NbZcPom+626K99{*La2!q=IISuaf45eiJ0>XR=3r&B zux4gq&9drwf#XyxD8ix=!rW}NwY5Ey%jHf5lcL#LiuaQpULtKY}gu z&=gjw0$s9&lFYJ1b!ku8Et8(cOl2j~6eyZQWhUSl9X3RzD>+xeeuQn58>q5f*vvbN zn>OLp3;YA-O4rtr8+vrJ35yMO_?N-$?}uCjs&izNUt^HP%9EQod{ zCy#$ptf*Ma$tM^kxDiasl?xKBtyuL~2OMQZy&gy~T^n{~78kmTD1(w5=4#dPHOVR5I zT0un=0V;Dmkj5D)BaHd}t5<gd3(S6{}uWSu#Tw6j?fdwG0w>;6`uTO zAsdbBaf!ZUE-Abd6th4EhG`z}`VzSRj>&i)!>=k{!`OCEO~KWq)l?ck${I<;dCJVg zCcWp5pTG!(PjH7bq*zC?OrazEVY0X7h5gJcyj|%$VEPV+Ka*4@qlluo#;(VaXl(QooV?ek zhf!|#IH^=B&zs4C5+$g)Offk&$>X@$9LEy`9i`Bl1Q_NutNXJf$PNscQ&So4Hm_f` z+qYqs!Y8Td7}t(bkumkjNDWWSk>g)6B^S&g4vzeLqZeKa?d4b~8eidUOrf4ufLMwqk8zPWJ+nh_v2Up!CB;>k6iL zo880gm#650um@?hbH0Cw)PJDeOV$ztf#Co9 Date: Wed, 30 Mar 2022 02:47:08 +0000 Subject: [PATCH 42/68] fix: linting mistakes --- packages/remix-azure-functions/__tests__/server-test.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/remix-azure-functions/__tests__/server-test.ts b/packages/remix-azure-functions/__tests__/server-test.ts index 88fe2e7b0e2..94982360152 100644 --- a/packages/remix-azure-functions/__tests__/server-test.ts +++ b/packages/remix-azure-functions/__tests__/server-test.ts @@ -1,4 +1,4 @@ -import { Context, HttpRequest } from "@azure/functions"; +import type { Context, HttpRequest } from "@azure/functions"; import { createRequestHandler as createRemixRequestHandler } from "@remix-run/server-runtime"; import { Response } from "@remix-run/node"; @@ -49,7 +49,7 @@ describe("azure createRequestHandler", () => { body: "", }; - const res = await createRequestHandler({ build: undefined })( + let res = await createRequestHandler({ build: undefined })( context, mockedRequest ); From c9a21ed6868a3950f75272b03544f41a44112d27 Mon Sep 17 00:00:00 2001 From: Aaron Powell Date: Wed, 30 Mar 2022 02:47:48 +0000 Subject: [PATCH 43/68] fix: using @remix-run/node not server directly --- packages/remix-azure-functions/server.ts | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/packages/remix-azure-functions/server.ts b/packages/remix-azure-functions/server.ts index 26d2c334fff..867f22ffe82 100644 --- a/packages/remix-azure-functions/server.ts +++ b/packages/remix-azure-functions/server.ts @@ -5,9 +5,8 @@ import type { HttpRequestHeaders, } from "@azure/functions"; import type { AppLoadContext, ServerBuild } from "@remix-run/server-runtime"; -import { createRequestHandler as createRemixRequestHandler } from "@remix-run/server-runtime"; import { - formatServerError, + createRequestHandler as createRemixRequestHandler, Headers as NodeHeaders, Request as NodeRequest, } from "@remix-run/node"; @@ -37,8 +36,7 @@ export function createRequestHandler({ getLoadContext?: GetLoadContextFunction; mode?: string; }): RequestHandler { - let platform: ServerPlatform = { formatServerError }; - let handleRequest = createRemixRequestHandler(build, platform, mode); + let handleRequest = createRemixRequestHandler(build, mode); return async (_context: Context, req: HttpRequest) => { let request = createRemixRequest(req); From 4c150dddc1096037c2156b512921d6eefdec4905 Mon Sep 17 00:00:00 2001 From: Aaron Powell Date: Wed, 30 Mar 2022 02:48:10 +0000 Subject: [PATCH 44/68] chore: reverting whitespace from merge --- packages/remix-server-runtime/headers.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/packages/remix-server-runtime/headers.ts b/packages/remix-server-runtime/headers.ts index 2605bf3f9a4..19b494266ed 100644 --- a/packages/remix-server-runtime/headers.ts +++ b/packages/remix-server-runtime/headers.ts @@ -1,7 +1,9 @@ import { splitCookiesString } from "set-cookie-parser"; + import type { ServerBuild } from "./build"; import type { ServerRoute } from "./routes"; import type { RouteMatch } from "./routeMatching"; + export function getDocumentHeaders( build: ServerBuild, matches: RouteMatch[], From cc6a1b8f3c80315084f4fc5373d0ae9b49dbd76e Mon Sep 17 00:00:00 2001 From: Aaron Powell Date: Wed, 30 Mar 2022 14:35:25 +1100 Subject: [PATCH 45/68] Update packages/remix-azure-functions/package.json MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Michaël De Boey --- packages/remix-azure-functions/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/remix-azure-functions/package.json b/packages/remix-azure-functions/package.json index 51dba74cf74..f570bf260d4 100644 --- a/packages/remix-azure-functions/package.json +++ b/packages/remix-azure-functions/package.json @@ -4,7 +4,7 @@ "version": "0.17.5", "repository": "https://github.com/remix-run/packages", "dependencies": { - "@remix-run/node": "0.17.5" + "@remix-run/node": "1.3.3" }, "peerDependencies": { "@azure/functions": "^1.2.3" From 97766bdeede8d663e4c295ce9b072d679fc0e729 Mon Sep 17 00:00:00 2001 From: Aaron Powell Date: Wed, 30 Mar 2022 14:35:33 +1100 Subject: [PATCH 46/68] Update templates/azure-functions/.eslintrc MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Michaël De Boey --- templates/azure-functions/.eslintrc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/templates/azure-functions/.eslintrc b/templates/azure-functions/.eslintrc index 8828ca31d3a..71569754629 100644 --- a/templates/azure-functions/.eslintrc +++ b/templates/azure-functions/.eslintrc @@ -1,3 +1,3 @@ { - "extends": ["@remix-run/eslint-config"] + "extends": ["@remix-run/eslint-config", "@remix-run/eslint-config/node"] } From b5204bb5e3163ba10678854f31cbdeb7ce3c9aaa Mon Sep 17 00:00:00 2001 From: Aaron Powell Date: Wed, 30 Mar 2022 03:55:32 +0000 Subject: [PATCH 47/68] fix: using the correct packages --- packages/remix-azure-functions/__tests__/server-test.ts | 3 +-- packages/remix-azure-functions/server.ts | 2 +- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/packages/remix-azure-functions/__tests__/server-test.ts b/packages/remix-azure-functions/__tests__/server-test.ts index 94982360152..2b0257423fb 100644 --- a/packages/remix-azure-functions/__tests__/server-test.ts +++ b/packages/remix-azure-functions/__tests__/server-test.ts @@ -1,6 +1,5 @@ import type { Context, HttpRequest } from "@azure/functions"; -import { createRequestHandler as createRemixRequestHandler } from "@remix-run/server-runtime"; -import { Response } from "@remix-run/node"; +import { createRequestHandler as createRemixRequestHandler, Response } from "@remix-run/node"; import { createRemixHeaders, diff --git a/packages/remix-azure-functions/server.ts b/packages/remix-azure-functions/server.ts index 867f22ffe82..4662c72d22a 100644 --- a/packages/remix-azure-functions/server.ts +++ b/packages/remix-azure-functions/server.ts @@ -4,13 +4,13 @@ import type { HttpRequest, HttpRequestHeaders, } from "@azure/functions"; -import type { AppLoadContext, ServerBuild } from "@remix-run/server-runtime"; import { createRequestHandler as createRemixRequestHandler, Headers as NodeHeaders, Request as NodeRequest, } from "@remix-run/node"; import type { + AppLoadContext, ServerBuild, Response as NodeResponse, RequestInit as NodeRequestInit, } from "@remix-run/node"; From 292e671d6543ccd900063d56e7a1963646cba5fa Mon Sep 17 00:00:00 2001 From: Aaron Powell Date: Wed, 30 Mar 2022 05:05:10 +0000 Subject: [PATCH 48/68] fix: azure template works Missed the remix scaffolding step and wasn't pointing to the package properly --- templates/azure-functions/azure/function/index.js | 2 +- templates/azure-functions/package.json | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/templates/azure-functions/azure/function/index.js b/templates/azure-functions/azure/function/index.js index 7e356edbed6..bb3cbad42d5 100644 --- a/templates/azure-functions/azure/function/index.js +++ b/templates/azure-functions/azure/function/index.js @@ -1,3 +1,3 @@ -const { createRequestHandler } = require("./handler"); +const { createRequestHandler } = require("@remix-run/azure-functions"); module.exports = createRequestHandler({ build: require("./build") }); diff --git a/templates/azure-functions/package.json b/templates/azure-functions/package.json index 587ece3698a..eb0f54160f7 100644 --- a/templates/azure-functions/package.json +++ b/templates/azure-functions/package.json @@ -1,13 +1,14 @@ { "scripts": { "build": "remix build", - "dev": "swa start ./public --run \"remix dev\" --api .", - "postinstall": "func init --worker-runtime node --language typescript" + "dev": "swa start ./public --run \"remix dev\" --api-location .", + "postinstall": "func init --worker-runtime node --language typescript && remix setup azure-functions" }, "dependencies": { "@remix-run/azure-functions": "*", "@remix-run/node": "*", "@remix-run/react": "*", + "@remix-run/serve": "*", "react": "^17.0.2", "react-dom": "^17.0.2", "remix": "*" From a81bcb1f285fb36e1685bddf46b28b75e6eaacfc Mon Sep 17 00:00:00 2001 From: Aaron Powell Date: Wed, 30 Mar 2022 05:05:59 +0000 Subject: [PATCH 49/68] chore: linting fixes --- packages/remix-azure-functions/__tests__/server-test.ts | 5 ++++- packages/remix-azure-functions/server.ts | 3 ++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/packages/remix-azure-functions/__tests__/server-test.ts b/packages/remix-azure-functions/__tests__/server-test.ts index 2b0257423fb..d50408815ba 100644 --- a/packages/remix-azure-functions/__tests__/server-test.ts +++ b/packages/remix-azure-functions/__tests__/server-test.ts @@ -1,5 +1,8 @@ import type { Context, HttpRequest } from "@azure/functions"; -import { createRequestHandler as createRemixRequestHandler, Response } from "@remix-run/node"; +import { + createRequestHandler as createRemixRequestHandler, + Response, +} from "@remix-run/node"; import { createRemixHeaders, diff --git a/packages/remix-azure-functions/server.ts b/packages/remix-azure-functions/server.ts index 4662c72d22a..0f8e9561156 100644 --- a/packages/remix-azure-functions/server.ts +++ b/packages/remix-azure-functions/server.ts @@ -10,7 +10,8 @@ import { Request as NodeRequest, } from "@remix-run/node"; import type { - AppLoadContext, ServerBuild, + AppLoadContext, + ServerBuild, Response as NodeResponse, RequestInit as NodeRequestInit, } from "@remix-run/node"; From bf336fa92d8f90d2c75169cb5509096c608739c2 Mon Sep 17 00:00:00 2001 From: Aaron Powell Date: Wed, 30 Mar 2022 05:10:45 +0000 Subject: [PATCH 50/68] feat: Adding Azure to the list of templates --- packages/remix-dev/cli/run.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/remix-dev/cli/run.ts b/packages/remix-dev/cli/run.ts index 130956de70e..3bb0a181989 100644 --- a/packages/remix-dev/cli/run.ts +++ b/packages/remix-dev/cli/run.ts @@ -129,6 +129,7 @@ const templateChoices = [ { name: "Cloudflare Pages", value: "cloudflare-pages" }, { name: "Cloudflare Workers", value: "cloudflare-workers" }, { name: "Deno", value: "deno" }, + { name: "Azure Static Web Apps", value: "azure-functions" }, ]; const npxInterop = { From 6e43ff15ecf6779399b9552d2ef344898b3547e4 Mon Sep 17 00:00:00 2001 From: Aaron Powell Date: Thu, 31 Mar 2022 11:18:02 +1100 Subject: [PATCH 51/68] Apply suggestions from code review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Michaël De Boey --- package.json | 2 +- packages/remix-architect/package.json | 2 +- packages/remix-azure-functions/magicExports/remix.ts | 2 ++ packages/remix-azure-functions/package.json | 2 +- packages/remix-server-runtime/package.json | 2 +- packages/remix-vercel/package.json | 2 +- templates/azure-functions/package.json | 4 +--- 7 files changed, 8 insertions(+), 8 deletions(-) diff --git a/package.json b/package.json index 5a6477bc3b8..faf83d479c3 100644 --- a/package.json +++ b/package.json @@ -123,4 +123,4 @@ "engines": { "node": ">=14" } -} \ No newline at end of file +} diff --git a/packages/remix-architect/package.json b/packages/remix-architect/package.json index 65b2805035d..aa4108e77d2 100644 --- a/packages/remix-architect/package.json +++ b/packages/remix-architect/package.json @@ -32,4 +32,4 @@ "LICENSE.md", "README.md" ] -} \ No newline at end of file +} diff --git a/packages/remix-azure-functions/magicExports/remix.ts b/packages/remix-azure-functions/magicExports/remix.ts index 5313959a9f6..9fa091084fc 100644 --- a/packages/remix-azure-functions/magicExports/remix.ts +++ b/packages/remix-azure-functions/magicExports/remix.ts @@ -1,3 +1,5 @@ +/* eslint-disable import/no-extraneous-dependencies */ + // Re-export everything from this package that is available in `remix`. export { diff --git a/packages/remix-azure-functions/package.json b/packages/remix-azure-functions/package.json index f570bf260d4..1efa6dee109 100644 --- a/packages/remix-azure-functions/package.json +++ b/packages/remix-azure-functions/package.json @@ -1,7 +1,7 @@ { "name": "@remix-run/azure-functions", "description": "Azure Functions server request handler for Remix", - "version": "0.17.5", + "version": "1.3.3", "repository": "https://github.com/remix-run/packages", "dependencies": { "@remix-run/node": "1.3.3" diff --git a/packages/remix-server-runtime/package.json b/packages/remix-server-runtime/package.json index 5f3af124654..15032c81dc8 100644 --- a/packages/remix-server-runtime/package.json +++ b/packages/remix-server-runtime/package.json @@ -42,4 +42,4 @@ "LICENSE.md", "README.md" ] -} \ No newline at end of file +} diff --git a/packages/remix-vercel/package.json b/packages/remix-vercel/package.json index a72691f6ae8..a358f91228c 100644 --- a/packages/remix-vercel/package.json +++ b/packages/remix-vercel/package.json @@ -35,4 +35,4 @@ "LICENSE.md", "README.md" ] -} \ No newline at end of file +} diff --git a/templates/azure-functions/package.json b/templates/azure-functions/package.json index eb0f54160f7..8e15a7e4105 100644 --- a/templates/azure-functions/package.json +++ b/templates/azure-functions/package.json @@ -6,7 +6,6 @@ }, "dependencies": { "@remix-run/azure-functions": "*", - "@remix-run/node": "*", "@remix-run/react": "*", "@remix-run/serve": "*", "react": "^17.0.2", @@ -22,7 +21,6 @@ "@types/react-dom": "^17.0.9", "azure-functions-core-tools": "4.0.3971", "eslint": "^8.11.0", - "npm-run-all": "^4.1.5", "typescript": "4.6.3" } -} \ No newline at end of file +} From 49f42458eaf86d84bc09c4b82a702d9d34612085 Mon Sep 17 00:00:00 2001 From: Aaron Powell Date: Thu, 31 Mar 2022 00:47:39 +0000 Subject: [PATCH 52/68] chore: removing mock that's no longer needed --- packages/remix-azure-functions/__tests__/server-test.ts | 3 --- 1 file changed, 3 deletions(-) diff --git a/packages/remix-azure-functions/__tests__/server-test.ts b/packages/remix-azure-functions/__tests__/server-test.ts index d50408815ba..18537bc9858 100644 --- a/packages/remix-azure-functions/__tests__/server-test.ts +++ b/packages/remix-azure-functions/__tests__/server-test.ts @@ -10,9 +10,6 @@ import { createRequestHandler, } from "../server"; -// We don't want to test that the remix server works here (that's what the -// puppetteer tests do), we just want to test the azure adapter -jest.mock("@remix-run/server-runtime"); let mockedCreateRequestHandler = createRemixRequestHandler as jest.MockedFunction< typeof createRemixRequestHandler From bbfc8f86aa5e814120cc1cbac7e645430e181fd7 Mon Sep 17 00:00:00 2001 From: Aaron Powell Date: Thu, 31 Mar 2022 00:48:10 +0000 Subject: [PATCH 53/68] chore: should be a devDep --- templates/azure-functions/package.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/templates/azure-functions/package.json b/templates/azure-functions/package.json index 8e15a7e4105..3a0d35f1a20 100644 --- a/templates/azure-functions/package.json +++ b/templates/azure-functions/package.json @@ -7,7 +7,6 @@ "dependencies": { "@remix-run/azure-functions": "*", "@remix-run/react": "*", - "@remix-run/serve": "*", "react": "^17.0.2", "react-dom": "^17.0.2", "remix": "*" @@ -17,10 +16,11 @@ "@azure/static-web-apps-cli": "^0.8.3", "@remix-run/dev": "*", "@remix-run/eslint-config": "*", + "@remix-run/serve": "*", "@types/react": "^17.0.24", "@types/react-dom": "^17.0.9", "azure-functions-core-tools": "4.0.3971", "eslint": "^8.11.0", "typescript": "4.6.3" } -} +} \ No newline at end of file From 3e6103b24a104e56c41feeb8f3796a54d181ece7 Mon Sep 17 00:00:00 2001 From: Aaron Powell Date: Thu, 31 Mar 2022 12:00:14 +1100 Subject: [PATCH 54/68] fix: azure-functions extension tests weren't included --- jest.config.js | 1 + packages/remix-azure-functions/__tests__/setup.ts | 2 ++ 2 files changed, 3 insertions(+) create mode 100644 packages/remix-azure-functions/__tests__/setup.ts diff --git a/jest.config.js b/jest.config.js index d4ce0925bce..8f840a7e1f9 100644 --- a/jest.config.js +++ b/jest.config.js @@ -14,6 +14,7 @@ module.exports = { "packages/remix-node", "packages/remix-react", "packages/remix-server-runtime", + "packages/remix-azure-functions", ], watchPlugins: [ require.resolve("jest-watch-select-projects"), diff --git a/packages/remix-azure-functions/__tests__/setup.ts b/packages/remix-azure-functions/__tests__/setup.ts new file mode 100644 index 00000000000..917305ac938 --- /dev/null +++ b/packages/remix-azure-functions/__tests__/setup.ts @@ -0,0 +1,2 @@ +import { installGlobals } from "@remix-run/node"; +installGlobals(); From 4fa20722474516f99e6256f74d8c0964dd607994 Mon Sep 17 00:00:00 2001 From: Aaron Powell Date: Thu, 31 Mar 2022 01:16:10 +0000 Subject: [PATCH 55/68] test: fixing the azure functions tests --- .../remix-azure-functions/__tests__/server-test.ts | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/packages/remix-azure-functions/__tests__/server-test.ts b/packages/remix-azure-functions/__tests__/server-test.ts index 18537bc9858..f397b636b50 100644 --- a/packages/remix-azure-functions/__tests__/server-test.ts +++ b/packages/remix-azure-functions/__tests__/server-test.ts @@ -10,6 +10,16 @@ import { createRequestHandler, } from "../server"; +// We don't want to test that the remix server works here (that's what the +// puppetteer tests do), we just want to test the express adapter +jest.mock("@remix-run/node", () => { + let original = jest.requireActual("@remix-run/node"); + return { + ...original, + createRequestHandler: jest.fn(), + }; +}); + let mockedCreateRequestHandler = createRemixRequestHandler as jest.MockedFunction< typeof createRemixRequestHandler @@ -147,7 +157,8 @@ describe("azure createRemixRequest", () => { }; expect(createRemixRequest(request)).toMatchInlineSnapshot(` - Request { + NodeRequest { + "abortController": undefined, "agent": undefined, "compress": true, "counter": 0, From ee10de7fd666abe555eaa80169f88c69199be113 Mon Sep 17 00:00:00 2001 From: Aaron Powell Date: Thu, 31 Mar 2022 01:41:14 +0000 Subject: [PATCH 56/68] test: adding missing tests --- .../__tests__/server-test.ts | 73 ++++++++++++++++++- 1 file changed, 70 insertions(+), 3 deletions(-) diff --git a/packages/remix-azure-functions/__tests__/server-test.ts b/packages/remix-azure-functions/__tests__/server-test.ts index f397b636b50..54dab2bbada 100644 --- a/packages/remix-azure-functions/__tests__/server-test.ts +++ b/packages/remix-azure-functions/__tests__/server-test.ts @@ -1,7 +1,6 @@ import type { Context, HttpRequest } from "@azure/functions"; import { createRequestHandler as createRemixRequestHandler, - Response, } from "@remix-run/node"; import { @@ -67,9 +66,77 @@ describe("azure createRequestHandler", () => { expect(res.body).toBe("URL: /foo/bar"); }); - it.todo("handles status codes"); + it("handles status codes", async () => { + mockedCreateRequestHandler.mockImplementation(() => async () => { + return new Response (null, { status: 204 }); + }); + + let mockedRequest: HttpRequest = { + method: "GET", + url: "/foo/bar", + rawBody: "", + headers: { + "x-ms-original-url": "http://localhost:3000/foo/bar", + }, + params: {}, + query: {}, + body: "", + }; + + let res = await createRequestHandler({ build: undefined })( + context, + mockedRequest + ); + + expect(res.status).toBe(204); + }); + + it("sets headers", async () => { + mockedCreateRequestHandler.mockImplementation(() => async (req) => { + let headers = new Headers({ "X-Time-Of-Year": "most wonderful" }); + headers.append( + "Set-Cookie", + "first=one; Expires=0; Path=/; HttpOnly; Secure; SameSite=Lax" + ); + headers.append( + "Set-Cookie", + "second=two; MaxAge=1209600; Path=/; HttpOnly; Secure; SameSite=Lax" + ); + headers.append( + "Set-Cookie", + "third=three; Expires=Wed, 21 Oct 2015 07:28:00 GMT; Path=/; HttpOnly; Secure; SameSite=Lax" + ); + for(let [key, value] of req.headers.entries()) { + headers.set(key, value); + } + return new Response (null, { headers }); + }); - it.todo("sets headers"); + let mockedRequest: HttpRequest = { + method: "GET", + url: "/foo/bar", + rawBody: "", + headers: { + "x-ms-original-url": "http://localhost:3000/foo/bar", + }, + params: {}, + query: {}, + body: "", + }; + + let res = await createRequestHandler({ build: undefined })( + context, + mockedRequest + ); + + expect(res.headers["x-ms-original-url"]).toEqual(["http://localhost:3000/foo/bar"]); + expect(res.headers["X-Time-Of-Year"]).toEqual(["most wonderful"]); + expect(res.headers["Set-Cookie"]).toEqual([ + "first=one; Expires=0; Path=/; HttpOnly; Secure; SameSite=Lax", + "second=two; MaxAge=1209600; Path=/; HttpOnly; Secure; SameSite=Lax", + "third=three; Expires=Wed, 21 Oct 2015 07:28:00 GMT; Path=/; HttpOnly; Secure; SameSite=Lax", + ]); + }); }); }); From adb67819c79349eb37f4f1cba41ac080e83daad9 Mon Sep 17 00:00:00 2001 From: Aaron Powell Date: Thu, 31 Mar 2022 13:37:38 +1100 Subject: [PATCH 57/68] Apply suggestions from code review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Michaël De Boey --- templates/azure-functions/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/templates/azure-functions/package.json b/templates/azure-functions/package.json index 3a0d35f1a20..ea916d2e918 100644 --- a/templates/azure-functions/package.json +++ b/templates/azure-functions/package.json @@ -23,4 +23,4 @@ "eslint": "^8.11.0", "typescript": "4.6.3" } -} \ No newline at end of file +} From 266d4b265af9d22c0269451f21813564459a9042 Mon Sep 17 00:00:00 2001 From: Aaron Powell Date: Thu, 31 Mar 2022 02:56:08 +0000 Subject: [PATCH 58/68] chore: tidying up docs for azure functions --- docs/guides/deployment.md | 1 + docs/other-api/adapter.md | 1 + packages/remix-azure-functions/README.md | 17 ++ .../azure-functions/.devcontainer/Dockerfile | 25 +++ .../.devcontainer/devcontainer.json | 27 +++ .../library-scripts/node-debian.sh | 169 ++++++++++++++++++ templates/azure-functions/.nvmrc | 1 + templates/azure-functions/README.md | 14 +- .../github-actions/azure-static-web-apps.yml | 3 - .../public/staticwebapp.config.json | 5 +- 10 files changed, 251 insertions(+), 12 deletions(-) create mode 100644 packages/remix-azure-functions/README.md create mode 100644 templates/azure-functions/.devcontainer/Dockerfile create mode 100644 templates/azure-functions/.devcontainer/devcontainer.json create mode 100644 templates/azure-functions/.devcontainer/library-scripts/node-debian.sh create mode 100644 templates/azure-functions/.nvmrc diff --git a/docs/guides/deployment.md b/docs/guides/deployment.md index aa0cb66ea6a..0239d1141ee 100644 --- a/docs/guides/deployment.md +++ b/docs/guides/deployment.md @@ -18,6 +18,7 @@ npx create-remix@latest Fly.io Netlify Vercel + Azure Static Web Apps ``` Each target has unique file structures, configuration files, cli commands that need to be run, server environment variables to be set etc. Because of this, it's important to read the README.md to deploy the app. It's got all of the steps you need to take to get your app live within minutes. diff --git a/docs/other-api/adapter.md b/docs/other-api/adapter.md index 0eabb3d20b1..2b89b4e0a06 100644 --- a/docs/other-api/adapter.md +++ b/docs/other-api/adapter.md @@ -13,6 +13,7 @@ Idiomatic Remix apps can generally be deployed anywhere because Remix adapt's th - `@remix-run/express` - `@remix-run/netlify` - `@remix-run/vercel` +- `@remix-run/azure-functions` These adapters are imported into your server's entry and is not used inside of your Remix app itself. diff --git a/packages/remix-azure-functions/README.md b/packages/remix-azure-functions/README.md new file mode 100644 index 00000000000..801448197b5 --- /dev/null +++ b/packages/remix-azure-functions/README.md @@ -0,0 +1,17 @@ +# Welcome to Remix! + +[Remix](https://remix.run) is a web framework that helps you build better websites with React. + +To get started, open a new shell and run: + +```sh +npx create-remix@latest +``` + +Then follow the prompts you see in your terminal. + +For more information about Remix, [visit remix.run](https://remix.run)! + +## About + +This package can be used to host Remix within an [Azure Function](https://docs.microsoft.com/azure/azure-functions/) or in [Azure Static Web Apps](https://docs.microsoft.com/azure/static-web-apps) (using the built-in Azure Functions support). diff --git a/templates/azure-functions/.devcontainer/Dockerfile b/templates/azure-functions/.devcontainer/Dockerfile new file mode 100644 index 00000000000..3cfe4a8308a --- /dev/null +++ b/templates/azure-functions/.devcontainer/Dockerfile @@ -0,0 +1,25 @@ +# Find the Dockerfile at this URL +# https://github.com/Azure/azure-functions-docker/blob/dev/host/4/bullseye/amd64/python/python39/python39-core-tools.Dockerfile +FROM mcr.microsoft.com/azure-functions/python:4-python3.9-core-tools + +# Copy library scripts to execute +COPY library-scripts/*.sh library-scripts/*.env /tmp/library-scripts/ + +# Install Node.js, Azure Static Web Apps CLI and Azure Functions Core Tools +ARG NODE_VERSION="16" +ARG CORE_TOOLS_VERSION="4" +ENV NVM_DIR="/usr/local/share/nvm" \ + NVM_SYMLINK_CURRENT=true \ + PATH="${NVM_DIR}/current/bin:${PATH}" +RUN bash /tmp/library-scripts/node-debian.sh "${NVM_DIR}" "${NODE_VERSION}" "${USERNAME}" \ + && su vscode -c "umask 0002 && . /usr/local/share/nvm/nvm.sh && nvm install ${NODE_VERSION} 2>&1" \ + && su vscode -c "umask 0002 && npm install --cache /tmp/empty-cache -g @azure/static-web-apps-cli" \ + && if [ $CORE_TOOLS_VERSION != "4" ]; then apt-get remove -y azure-functions-core-tools-4 && apt-get update && apt-get install -y "azure-functions-core-tools-${CORE_TOOLS_VERSION}"; fi \ + && apt-get clean -y && rm -rf /var/lib/apt/lists/* + +# [Optional] Uncomment this section to install additional OS packages. +# RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \ +# && apt-get -y install --no-install-recommends + +# [Optional] Uncomment this line to install global node packages. +# RUN su vscode -c "source /usr/local/share/nvm/nvm.sh && npm install -g " 2>&1 \ No newline at end of file diff --git a/templates/azure-functions/.devcontainer/devcontainer.json b/templates/azure-functions/.devcontainer/devcontainer.json new file mode 100644 index 00000000000..eecdcf5fab5 --- /dev/null +++ b/templates/azure-functions/.devcontainer/devcontainer.json @@ -0,0 +1,27 @@ +// For format details, see https://aka.ms/devcontainer.json. For config options, see the README at: +// https://github.com/microsoft/vscode-dev-containers/tree/v0.158.0/containers/azure-static-web-apps +{ + "name": "Remix for Azure Static Web App", + "dockerFile": "Dockerfile", + "forwardPorts": [7071, 3000, 4280], + + // Set *default* container specific settings.json values on container create. + "settings": { + }, + + // Add the IDs of extensions you want installed when the container is created. + "extensions": [ + "ms-azuretools.vscode-azurefunctions", + "ms-azuretools.vscode-azurestaticwebapps", + "dbaeumer.vscode-eslint", + "esbenp.prettier-vscode", + "editorconfig.editorconfig" + ], + + // Use 'postCreateCommand' to run commands after the container is created. + "postCreateCommand": "", + + // Comment out connect as root instead. More info: https://aka.ms/vscode-remote/containers/non-root. + "remoteUser": "vscode" + } + \ No newline at end of file diff --git a/templates/azure-functions/.devcontainer/library-scripts/node-debian.sh b/templates/azure-functions/.devcontainer/library-scripts/node-debian.sh new file mode 100644 index 00000000000..5394a8fe5f4 --- /dev/null +++ b/templates/azure-functions/.devcontainer/library-scripts/node-debian.sh @@ -0,0 +1,169 @@ +#!/bin/bash +#------------------------------------------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See https://go.microsoft.com/fwlink/?linkid=2090316 for license information. +#------------------------------------------------------------------------------------------------------------- +# +# Docs: https://github.com/microsoft/vscode-dev-containers/blob/main/script-library/docs/node.md +# Maintainer: The VS Code and Codespaces Teams +# +# Syntax: ./node-debian.sh [directory to install nvm] [node version to install (use "none" to skip)] [non-root user] [Update rc files flag] [install node-gyp deps] + +export NVM_DIR=${1:-"/usr/local/share/nvm"} +export NODE_VERSION=${2:-"lts"} +USERNAME=${3:-"automatic"} +UPDATE_RC=${4:-"true"} +INSTALL_TOOLS_FOR_NODE_GYP="${5:-true}" +export NVM_VERSION="0.38.0" + +set -e + +if [ "$(id -u)" -ne 0 ]; then + echo -e 'Script must be run as root. Use sudo, su, or add "USER root" to your Dockerfile before running this script.' + exit 1 +fi + +# Ensure that login shells get the correct path if the user updated the PATH using ENV. +rm -f /etc/profile.d/00-restore-env.sh +echo "export PATH=${PATH//$(sh -lc 'echo $PATH')/\$PATH}" > /etc/profile.d/00-restore-env.sh +chmod +x /etc/profile.d/00-restore-env.sh + +# Determine the appropriate non-root user +if [ "${USERNAME}" = "auto" ] || [ "${USERNAME}" = "automatic" ]; then + USERNAME="" + POSSIBLE_USERS=("vscode" "node" "codespace" "$(awk -v val=1000 -F ":" '$3==val{print $1}' /etc/passwd)") + for CURRENT_USER in ${POSSIBLE_USERS[@]}; do + if id -u ${CURRENT_USER} > /dev/null 2>&1; then + USERNAME=${CURRENT_USER} + break + fi + done + if [ "${USERNAME}" = "" ]; then + USERNAME=root + fi +elif [ "${USERNAME}" = "none" ] || ! id -u ${USERNAME} > /dev/null 2>&1; then + USERNAME=root +fi + +updaterc() { + if [ "${UPDATE_RC}" = "true" ]; then + echo "Updating /etc/bash.bashrc and /etc/zsh/zshrc..." + if [[ "$(cat /etc/bash.bashrc)" != *"$1"* ]]; then + echo -e "$1" >> /etc/bash.bashrc + fi + if [ -f "/etc/zsh/zshrc" ] && [[ "$(cat /etc/zsh/zshrc)" != *"$1"* ]]; then + echo -e "$1" >> /etc/zsh/zshrc + fi + fi +} + +# Function to run apt-get if needed +apt_get_update_if_needed() +{ + if [ ! -d "/var/lib/apt/lists" ] || [ "$(ls /var/lib/apt/lists/ | wc -l)" = "0" ]; then + echo "Running apt-get update..." + apt-get update + else + echo "Skipping apt-get update." + fi +} + +# Checks if packages are installed and installs them if not +check_packages() { + if ! dpkg -s "$@" > /dev/null 2>&1; then + apt_get_update_if_needed + apt-get -y install --no-install-recommends "$@" + fi +} + +# Ensure apt is in non-interactive to avoid prompts +export DEBIAN_FRONTEND=noninteractive + +# Install dependencies +check_packages apt-transport-https curl ca-certificates tar gnupg2 dirmngr + +# Install yarn +if type yarn > /dev/null 2>&1; then + echo "Yarn already installed." +else + # Import key safely (new method rather than deprecated apt-key approach) and install + curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | gpg --dearmor > /usr/share/keyrings/yarn-archive-keyring.gpg + echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/yarn-archive-keyring.gpg] https://dl.yarnpkg.com/debian/ stable main" > /etc/apt/sources.list.d/yarn.list + apt-get update + apt-get -y install --no-install-recommends yarn +fi + +# Adjust node version if required +if [ "${NODE_VERSION}" = "none" ]; then + export NODE_VERSION= +elif [ "${NODE_VERSION}" = "lts" ]; then + export NODE_VERSION="lts/*" +fi + +# Create a symlink to the installed version for use in Dockerfile PATH statements +export NVM_SYMLINK_CURRENT=true + +# Install the specified node version if NVM directory already exists, then exit +if [ -d "${NVM_DIR}" ]; then + echo "NVM already installed." + if [ "${NODE_VERSION}" != "" ]; then + su ${USERNAME} -c ". $NVM_DIR/nvm.sh && nvm install ${NODE_VERSION} && nvm clear-cache" + fi + exit 0 +fi + +# Create nvm group, nvm dir, and set sticky bit +if ! cat /etc/group | grep -e "^nvm:" > /dev/null 2>&1; then + groupadd -r nvm +fi +umask 0002 +usermod -a -G nvm ${USERNAME} +mkdir -p ${NVM_DIR} +chown :nvm ${NVM_DIR} +chmod g+s ${NVM_DIR} +su ${USERNAME} -c "$(cat << EOF + set -e + umask 0002 + # Do not update profile - we'll do this manually + export PROFILE=/dev/null + curl -so- https://raw.githubusercontent.com/nvm-sh/nvm/v${NVM_VERSION}/install.sh | bash + source ${NVM_DIR}/nvm.sh + if [ "${NODE_VERSION}" != "" ]; then + nvm alias default ${NODE_VERSION} + fi + nvm clear-cache +EOF +)" 2>&1 +# Update rc files +if [ "${UPDATE_RC}" = "true" ]; then +updaterc "$(cat < /dev/null 2>&1; then + to_install="${to_install} make" + fi + if ! type gcc > /dev/null 2>&1; then + to_install="${to_install} gcc" + fi + if ! type g++ > /dev/null 2>&1; then + to_install="${to_install} g++" + fi + if ! type python3 > /dev/null 2>&1; then + to_install="${to_install} python3-minimal" + fi + if [ ! -z "${to_install}" ]; then + apt_get_update_if_needed + apt-get -y install ${to_install} + fi +fi + +echo "Done!" \ No newline at end of file diff --git a/templates/azure-functions/.nvmrc b/templates/azure-functions/.nvmrc new file mode 100644 index 00000000000..b6a7d89c68e --- /dev/null +++ b/templates/azure-functions/.nvmrc @@ -0,0 +1 @@ +16 diff --git a/templates/azure-functions/README.md b/templates/azure-functions/README.md index 111cb96b9d2..1e95d7c49b8 100644 --- a/templates/azure-functions/README.md +++ b/templates/azure-functions/README.md @@ -1,7 +1,7 @@ -# Welcome to Remix! +# Welcome to Remix for Azure Static Web Apps! - [Remix Docs](https://docs.remix.run) -- [Customer Dashboard](https://remix.run/dashboard) +- [Azure Static Web Apps](https://docs.microsoft.com/azure/static-web-apps) ## Development @@ -11,7 +11,9 @@ From your terminal: npm run dev ``` -This starts your app in development mode, rebuilding assets on file changes. +This starts the [Static Web Apps emulator](https://github.com/Azure/static-web-apps-cli) and the Remix server in the background. + +A [VS Code Devcontainer definition](https://code.visualstudio.com/docs/remote/containers) has been included to setup a local development environment with all the dependencies and recommended VS Code extensions. ## Deploying @@ -20,8 +22,4 @@ Prerequisites: - [Azure Account](https://portal.azure.com/) - [GitHub Account](https://github.com/) -First, you need to follow the [instructions](https://docs.microsoft.com/en-us/azure/static-web-apps/get-started-portal?tabs=vanilla-javascript) to create a new project on Azure. - -Next, you'll need to add your `REMIX_TOKEN`, and your `AZURE_STATIC_WEB_APPS_TOKEN` as GitHub project [secrets](https://docs.github.com/en/actions/reference/encrypted-secrets) - -You can find your azure token in the Azure portal for your static web app under "management deployment token". +First, you need to follow the [instructions](https://docs.microsoft.com/azure/static-web-apps/get-started-portal?tabs=vanilla-javascript) to create a new project on Azure. This will also setup the GitHub Actions workflow to perform automated deployments of your site. diff --git a/templates/azure-functions/github-actions/azure-static-web-apps.yml b/templates/azure-functions/github-actions/azure-static-web-apps.yml index 3c5b1a3f05b..62783006770 100644 --- a/templates/azure-functions/github-actions/azure-static-web-apps.yml +++ b/templates/azure-functions/github-actions/azure-static-web-apps.yml @@ -21,8 +21,6 @@ jobs: - name: Build And Deploy id: builddeploy uses: Azure/static-web-apps-deploy@v1 - env: - REMIX_TOKEN: ${{ secrets.REMIX_TOKEN }} with: azure_static_web_apps_api_token: ${{ secrets.AZURE_STATIC_WEB_APPS_TOKEN }} repo_token: ${{ secrets.GITHUB_TOKEN }} # Used for Github integrations (i.e. PR comments) @@ -32,7 +30,6 @@ jobs: app_location: "/" # App source code path api_location: "/" # Api source code path - optional output_location: "public" # Built app content directory - optional - app_build_command: "npm run build" ###### End of Repository/Build Configurations ###### close_pull_request_job: diff --git a/templates/azure-functions/public/staticwebapp.config.json b/templates/azure-functions/public/staticwebapp.config.json index bb87234a918..54ca177c6e9 100644 --- a/templates/azure-functions/public/staticwebapp.config.json +++ b/templates/azure-functions/public/staticwebapp.config.json @@ -11,5 +11,8 @@ ], "navigationFallback": { "rewrite": "/api/azure" + }, + "platform": { + "apiRuntime": "node:16" } -} +} \ No newline at end of file From 8373aabe9559fc04221ae62ab1b65f908c9326fe Mon Sep 17 00:00:00 2001 From: Aaron Powell Date: Thu, 31 Mar 2022 23:21:18 +0000 Subject: [PATCH 59/68] chore: alphabetising the order --- docs/other-api/adapter.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/other-api/adapter.md b/docs/other-api/adapter.md index 2b89b4e0a06..8b848a7224f 100644 --- a/docs/other-api/adapter.md +++ b/docs/other-api/adapter.md @@ -8,12 +8,12 @@ order: 2 Idiomatic Remix apps can generally be deployed anywhere because Remix adapt's the server's request/response to the [Web Fetch API][web-fetch-api]. It does this through adapters. We maintain a few adapters: - `@remix-run/architect` +- `@remix-run/azure-functions` - `@remix-run/cloudflare-pages` - `@remix-run/cloudflare-workers` - `@remix-run/express` - `@remix-run/netlify` - `@remix-run/vercel` -- `@remix-run/azure-functions` These adapters are imported into your server's entry and is not used inside of your Remix app itself. From 86edd6bd59fb79014f86bbd3a90c8f20080799af Mon Sep 17 00:00:00 2001 From: Aaron Powell Date: Wed, 4 May 2022 01:18:32 +0000 Subject: [PATCH 60/68] fix: missing jest setup --- packages/remix-azure-functions/package.json | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/packages/remix-azure-functions/package.json b/packages/remix-azure-functions/package.json index 1efa6dee109..7f759865fa9 100644 --- a/packages/remix-azure-functions/package.json +++ b/packages/remix-azure-functions/package.json @@ -2,7 +2,14 @@ "name": "@remix-run/azure-functions", "description": "Azure Functions server request handler for Remix", "version": "1.3.3", - "repository": "https://github.com/remix-run/packages", + "repository": { + "type": "git", + "url": "https://github.com/remix-run/remix", + "directory": "packages/remix-azure-functions" + }, + "bugs": { + "url": "https://github.com/remix-run/remix/issues" + }, "dependencies": { "@remix-run/node": "1.3.3" }, @@ -15,4 +22,4 @@ "node-mocks-http": "^1.10.1", "supertest": "^6.0.1" } -} +} \ No newline at end of file From 408cdea9aa30f65efbde601ce76c8dd76852431b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C3=ABl=20De=20Boey?= Date: Wed, 8 Jun 2022 19:34:30 +0200 Subject: [PATCH 61/68] chore: update `yarn.lock` --- packages/remix-azure-functions/package.json | 11 +- yarn.lock | 188 ++++++++++++++++++-- 2 files changed, 179 insertions(+), 20 deletions(-) diff --git a/packages/remix-azure-functions/package.json b/packages/remix-azure-functions/package.json index 7f759865fa9..e6959855848 100644 --- a/packages/remix-azure-functions/package.json +++ b/packages/remix-azure-functions/package.json @@ -1,7 +1,8 @@ { "name": "@remix-run/azure-functions", "description": "Azure Functions server request handler for Remix", - "version": "1.3.3", + "version": "1.4.3", + "license": "MIT", "repository": { "type": "git", "url": "https://github.com/remix-run/remix", @@ -11,15 +12,15 @@ "url": "https://github.com/remix-run/remix/issues" }, "dependencies": { - "@remix-run/node": "1.3.3" + "@remix-run/node": "1.4.3" }, "peerDependencies": { "@azure/functions": "^1.2.3" }, "devDependencies": { "@azure/functions": "^1.2.3", - "@types/supertest": "^2.0.10", - "node-mocks-http": "^1.10.1", - "supertest": "^6.0.1" + "@types/supertest": "^2.0.12", + "node-mocks-http": "^1.11.0", + "supertest": "^6.2.3" } } \ No newline at end of file diff --git a/yarn.lock b/yarn.lock index 8083c0f4684..8af3f97cd17 100644 --- a/yarn.lock +++ b/yarn.lock @@ -22,6 +22,11 @@ run-waterfall "^1.1.7" uid-safe "^2.1.5" +"@azure/functions@^1.2.3": + version "1.2.3" + resolved "https://registry.yarnpkg.com/@azure/functions/-/functions-1.2.3.tgz#65765837e7319eedffbf8a971cb2f78d4e043d54" + integrity sha512-dZITbYPNg6ay6ngcCOjRUh1wDhlFITS0zIkqplyH5KfKEAVPooaoaye5mUFnR+WP9WdGRjlNXyl/y2tgWKHcRg== + "@babel/code-frame@7.16.7", "@babel/code-frame@^7.0.0", "@babel/code-frame@^7.10.4", "@babel/code-frame@^7.12.13", "@babel/code-frame@^7.16.7": version "7.16.7" resolved "https://registry.npmjs.org/@babel/code-frame/-/code-frame-7.16.7.tgz" @@ -2594,6 +2599,13 @@ "@types/connect" "*" "@types/node" "*" +"@types/busboy@^0.3.1": + version "0.3.2" + resolved "https://registry.yarnpkg.com/@types/busboy/-/busboy-0.3.2.tgz#2f29b017513415399c42632ae6a7cfcb1409b79c" + integrity sha512-iEvdm9Z9KdSs/ozuh1Z7ZsXrOl8F4M/CLMXPZHr3QuJ4d6Bjn+HBMC5EMKpwpAo8oi8iK9GZfFoHaIMrrZgwVw== + dependencies: + "@types/node" "*" + "@types/cacache@^15.0.0": version "15.0.1" resolved "https://registry.npmjs.org/@types/cacache/-/cacache-15.0.1.tgz" @@ -2908,6 +2920,14 @@ resolved "https://registry.npmjs.org/@types/ms/-/ms-0.7.31.tgz" integrity sha512-iiUgKzV9AuaEkZqkOLDIvlQiL6ltuZd9tGcW3gwpnX8JbuiuhFlEGmmFXEXkN50Cvq7Os88IY2v0dkDqXYWVgA== +"@types/node-fetch@^2.5.12": + version "2.6.2" + resolved "https://registry.yarnpkg.com/@types/node-fetch/-/node-fetch-2.6.2.tgz#d1a9c5fd049d9415dce61571557104dec3ec81da" + integrity sha512-DHqhlq5jeESLy19TYhLakJ07kNumXWjcDdxXsLUMJZ6ue8VZJj4kLPQVE/2mdHh3xZziNF1xppu5lwmS53HR+A== + dependencies: + "@types/node" "*" + form-data "^3.0.0" + "@types/node-fetch@^2.5.7": version "2.5.12" resolved "https://registry.npmjs.org/@types/node-fetch/-/node-fetch-2.5.12.tgz" @@ -3094,6 +3114,13 @@ dependencies: "@types/superagent" "*" +"@types/supertest@^2.0.12": + version "2.0.12" + resolved "https://registry.yarnpkg.com/@types/supertest/-/supertest-2.0.12.tgz#ddb4a0568597c9aadff8dbec5b2e8fddbe8692fc" + integrity sha512-X3HPWTwXRerBZS7Mo1k6vMVR1Z6zmJcDVn5O/31whe0tnjE4te6ZJSJGq1RiqHPjzPdMTfjCFogDJmwng9xHaQ== + dependencies: + "@types/superagent" "*" + "@types/tar-fs@^2.0.1": version "2.0.1" resolved "https://registry.npmjs.org/@types/tar-fs/-/tar-fs-2.0.1.tgz" @@ -3269,6 +3296,28 @@ json-schema-to-ts "1.6.4" ts-morph "12.0.0" +"@web-std/blob@^3.0.3": + version "3.0.4" + resolved "https://registry.yarnpkg.com/@web-std/blob/-/blob-3.0.4.tgz#dd67a685547331915428d69e723c7da2015c3fc5" + integrity sha512-+dibyiw+uHYK4dX5cJ7HA+gtDAaUUe6JsOryp2ZpAC7h4ICsh49E34JwHoEKPlPvP0llCrNzz45vvD+xX5QDBg== + dependencies: + "@web-std/stream" "1.0.0" + web-encoding "1.1.5" + +"@web-std/file@^3.0.0": + version "3.0.2" + resolved "https://registry.yarnpkg.com/@web-std/file/-/file-3.0.2.tgz#b84cc9ed754608b18dcf78ac62c40dbcc6a94692" + integrity sha512-pIH0uuZsmY8YFvSHP1NsBIiMT/1ce0suPrX74fEeO3Wbr1+rW0fUGEe4d0R99iLwXtyCwyserqCFI4BJkJlkRA== + dependencies: + "@web-std/blob" "^3.0.3" + +"@web-std/stream@1.0.0": + version "1.0.0" + resolved "https://registry.yarnpkg.com/@web-std/stream/-/stream-1.0.0.tgz#01066f40f536e4329d9b696dc29872f3a14b93c1" + integrity sha512-jyIbdVl+0ZJyKGTV0Ohb9E6UnxP+t7ZzX4Do3AHjZKxUXKMs9EmqnBDQgHF7bEw0EzbQygOjtt/7gvtmi//iCQ== + dependencies: + web-streams-polyfill "^3.1.1" + "@web3-storage/multipart-parser@^1.0.0": version "1.0.0" resolved "https://registry.npmjs.org/@web3-storage/multipart-parser/-/multipart-parser-1.0.0.tgz" @@ -3779,6 +3828,11 @@ arrify@^1.0.1: resolved "https://registry.yarnpkg.com/arrify/-/arrify-1.0.1.tgz#898508da2226f380df904728456849c1501a4b0d" integrity sha512-3CYzex9M9FGQjCGMGyi6/31c8GJbgb0qGyrx5HWxPd0aCwh4cB2YjMb2Xf9UuoogrMrlO9cTqnB5rI5GHZTcUA== +asap@^2.0.0: + version "2.0.6" + resolved "https://registry.yarnpkg.com/asap/-/asap-2.0.6.tgz#e50347611d7e690943208bbdafebcbc2fb866d46" + integrity sha512-BSHWgDSAiKs50o2Re8ppvp3seVHXSRM44cdSsT9FfNEUUZLOGWVCsiWaRPWM1Znn+mqZ1OfVZ3z3DWEzSp7hRA== + asn1@~0.2.3: version "0.2.6" resolved "https://registry.npmjs.org/asn1/-/asn1-0.2.6.tgz" @@ -4060,11 +4114,23 @@ bl@^4.0.3, bl@^4.1.0: inherits "^2.0.4" readable-stream "^3.4.0" +blob-stream@^0.1.3: + version "0.1.3" + resolved "https://registry.yarnpkg.com/blob-stream/-/blob-stream-0.1.3.tgz#98d668af6996e0f32ef666d06e215ccc7d77686c" + integrity sha512-xXwyhgVmPsFVFFvtM5P0syI17/oae+MIjLn5jGhuD86mmSJ61EWMWmbPrV/0+bdcH9jQ2CzIhmTQKNUJL7IPog== + dependencies: + blob "0.0.4" + blob-util@^2.0.2: version "2.0.2" resolved "https://registry.npmjs.org/blob-util/-/blob-util-2.0.2.tgz" integrity sha512-T7JQa+zsXXEa6/8ZhHcQEW1UFfVM49Ts65uBkFL6fz2QmrElqmbajIDJvuA0tEhRe5eIjpV9ZF+0RfZR9voJFQ== +blob@0.0.4: + version "0.0.4" + resolved "https://registry.yarnpkg.com/blob/-/blob-0.0.4.tgz#bcf13052ca54463f30f9fc7e95b9a47630a94921" + integrity sha512-YRc9zvVz4wNaxcXmiSgb9LAg7YYwqQ2xd0Sj6osfA7k/PKmIGVlnOYs3wOFdkRC9/JpQu8sGt/zHgJV7xzerfg== + bluebird@^3.7.2: version "3.7.2" resolved "https://registry.npmjs.org/bluebird/-/bluebird-3.7.2.tgz" @@ -4198,6 +4264,13 @@ builtin-modules@^3.1.0: resolved "https://registry.yarnpkg.com/builtin-modules/-/builtin-modules-3.3.0.tgz#cae62812b89801e9656336e46223e030386be7b6" integrity sha512-zhaCDicdLuWN5UbN5IMnFqNMhNfo919sH85y2/ea+5Yg9TsTkeZxpL+JLbp6cgYFS4sRLp3YV4S6yDuqVWHYOw== +busboy@^0.3.1: + version "0.3.1" + resolved "https://registry.yarnpkg.com/busboy/-/busboy-0.3.1.tgz#170899274c5bf38aae27d5c62b71268cd585fd1b" + integrity sha512-y7tTxhGKXcyBxRKAni+awqx8uqaJKrSFSNFSeRG5CsWNdmy2BIK+6VGWEW7TZnIO/533mtMEA4rOevQV815YJw== + dependencies: + dicer "0.3.0" + bytes@3.0.0: version "3.0.0" resolved "https://registry.npmjs.org/bytes/-/bytes-3.0.0.tgz" @@ -4753,6 +4826,11 @@ cookiejar@^2.1.2: resolved "https://registry.npmjs.org/cookiejar/-/cookiejar-2.1.2.tgz" integrity sha512-Mw+adcfzPxcPeI+0WlvRrr/3lGVO0bD75SxX6811cxSh1Wbxx7xZBGK1eVtDf6si8rg2lhnUjsVLMFMfbRIuwA== +cookiejar@^2.1.3: + version "2.1.3" + resolved "https://registry.yarnpkg.com/cookiejar/-/cookiejar-2.1.3.tgz#fc7a6216e408e74414b90230050842dacda75acc" + integrity sha512-JxbCBUdrfr6AQjOXrxoTvAMJO4HBTUIlBzslcJPAz+/KT8yk53fXun51u+RenNYvad/+Vc2DIz5o9UxlCDymFQ== + copy-descriptor@^0.1.0: version "0.1.1" resolved "https://registry.npmjs.org/copy-descriptor/-/copy-descriptor-0.1.1.tgz" @@ -5009,6 +5087,13 @@ debug@^3.0.1, debug@^3.1.0, debug@^3.2.7: dependencies: ms "^2.1.1" +debug@^4.3.4: + version "4.3.4" + resolved "https://registry.yarnpkg.com/debug/-/debug-4.3.4.tgz#1319f6579357f2338d3337d2cdd4914bb5dcc865" + integrity sha512-PRWFHuSU3eDtQJPvnNY7Jcket1j0t5OuOsFzPPzsekD52Zl8qUfFIPEiswXqIvHWGVHOgX+7G/vCNNhehwxfkQ== + dependencies: + ms "2.1.2" + decamelize-keys@^1.1.0: version "1.1.0" resolved "https://registry.yarnpkg.com/decamelize-keys/-/decamelize-keys-1.1.0.tgz#d171a87933252807eb3cb61dc1c1445d078df2d9" @@ -5148,6 +5233,21 @@ detect-newline@3.1.0, detect-newline@^3.0.0: resolved "https://registry.npmjs.org/detect-newline/-/detect-newline-3.1.0.tgz" integrity sha512-TLz+x/vEXm/Y7P7wn1EJFNLxYpUD4TgMosxY6fAVJUnJMbupHBOncxyWUG9OpTaH9EBD7uFI5LfEgmMOc54DsA== +dezalgo@1.0.3: + version "1.0.3" + resolved "https://registry.yarnpkg.com/dezalgo/-/dezalgo-1.0.3.tgz#7f742de066fc748bc8db820569dddce49bf0d456" + integrity sha512-K7i4zNfT2kgQz3GylDw40ot9GAE47sFZ9EXHFSPP6zONLgH6kWXE0KWJchkbQJLBkRazq4APwZ4OwiFFlT95OQ== + dependencies: + asap "^2.0.0" + wrappy "1" + +dicer@0.3.0: + version "0.3.0" + resolved "https://registry.yarnpkg.com/dicer/-/dicer-0.3.0.tgz#eacd98b3bfbf92e8ab5c2fdb71aaac44bb06b872" + integrity sha512-MdceRRWqltEG2dZqO769g27N/3PXfcKl04VhYnBlo2YhH7zPi88VebsjTKclaOyiuMaGU72hTfw3VkUitGcVCA== + dependencies: + streamsearch "0.1.2" + diff-sequences@^27.5.1: version "27.5.1" resolved "https://registry.npmjs.org/diff-sequences/-/diff-sequences-27.5.1.tgz" @@ -6276,7 +6376,7 @@ fast-levenshtein@^2.0.6, fast-levenshtein@~2.0.6: resolved "https://registry.npmjs.org/fast-levenshtein/-/fast-levenshtein-2.0.6.tgz" integrity sha1-PYpcZog6FqMMqGQ+hR8Zuqd5eRc= -fast-safe-stringify@^2.0.7: +fast-safe-stringify@^2.0.7, fast-safe-stringify@^2.1.1: version "2.1.1" resolved "https://registry.npmjs.org/fast-safe-stringify/-/fast-safe-stringify-2.1.1.tgz" integrity sha512-W+KJc2dmILlPplD/H4K9l9LcAHAfPtP6BY84uVLXQ6Evcz9Lcg33Y2z1IVblT6xdY54PXYVHEv+0Wpq8Io6zkA== @@ -6459,6 +6559,15 @@ form-data@^3.0.0: combined-stream "^1.0.8" mime-types "^2.1.12" +form-data@^4.0.0: + version "4.0.0" + resolved "https://registry.yarnpkg.com/form-data/-/form-data-4.0.0.tgz#93919daeaf361ee529584b9b31664dc12c9fa452" + integrity sha512-ETEklSGi5t0QMZuiXoA/Q6vcnxcLQP5vdugSpuAyi6SVGi2clPPp+xgEhuMaHC+zGgn31Kd235W35f7Hykkaww== + dependencies: + asynckit "^0.4.0" + combined-stream "^1.0.8" + mime-types "^2.1.12" + form-data@~2.3.2: version "2.3.3" resolved "https://registry.npmjs.org/form-data/-/form-data-2.3.3.tgz" @@ -6478,6 +6587,16 @@ formidable@^1.2.2: resolved "https://registry.npmjs.org/formidable/-/formidable-1.2.2.tgz" integrity sha512-V8gLm+41I/8kguQ4/o1D3RIHRmhYFG4pnNyonvua+40rqcEmT4+V71yaZ3B457xbbgCsCfjSPi65u/W6vK1U5Q== +formidable@^2.0.1: + version "2.0.1" + resolved "https://registry.yarnpkg.com/formidable/-/formidable-2.0.1.tgz#4310bc7965d185536f9565184dee74fbb75557ff" + integrity sha512-rjTMNbp2BpfQShhFbR3Ruk3qk2y9jKpvMW78nJgx8QKtxjDVrwbZG+wvDOmVbifHyOUOQJXxqEy6r0faRrPzTQ== + dependencies: + dezalgo "1.0.3" + hexoid "1.0.0" + once "1.4.0" + qs "6.9.3" + forwarded@0.2.0: version "0.2.0" resolved "https://registry.npmjs.org/forwarded/-/forwarded-0.2.0.tgz" @@ -6914,6 +7033,11 @@ headers-polyfill@^3.0.4: resolved "https://registry.npmjs.org/headers-polyfill/-/headers-polyfill-3.0.7.tgz" integrity sha512-JoLCAdCEab58+2/yEmSnOlficyHFpIl0XJqwu3l+Unkm1gXpFUYsThz6Yha3D6tNhocWkCPfyW0YVIGWFqTi7w== +hexoid@1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/hexoid/-/hexoid-1.0.0.tgz#ad10c6573fb907de23d9ec63a711267d9dc9bc18" + integrity sha512-QFLV0taWQOZtvIRIAdBChesmogZrtuXvVWsFHZTk2SU+anspqZ2vMnoLg7IE1+Uk16N19APic1BuF8bC8c2m5g== + history@^5.2.0, history@^5.3.0: version "5.3.0" resolved "https://registry.npmjs.org/history/-/history-5.3.0.tgz" @@ -8180,7 +8304,7 @@ jsdom@^16.6.0: ws "^7.4.6" xml-name-validator "^3.0.0" -jsesc@3.0.2: +jsesc@3.0.2, jsesc@^3.0.1: version "3.0.2" resolved "https://registry.npmjs.org/jsesc/-/jsesc-3.0.2.tgz" integrity sha512-xKqzzWXDttJuOcawBt4KnKHHIf5oQ/Cxax+0PWFG+DFDgHNAdi+TXECADI+RYiFUMmx8792xsMbbgXj4CwnP4g== @@ -9334,6 +9458,11 @@ mime@1.6.0, mime@^1.3.4: resolved "https://registry.npmjs.org/mime/-/mime-1.6.0.tgz" integrity sha512-x0Vn8spI+wuJ1O6S7gnbaQg8Pxh4NNHb7KSINmEWKiPE4RKOplvijn+NkmYmmRgP68mc70j2EbeTFRsrswaQeg== +mime@2.6.0: + version "2.6.0" + resolved "https://registry.yarnpkg.com/mime/-/mime-2.6.0.tgz#a2a682a95cd4d0cb1d6257e28f83da7e35800367" + integrity sha512-USPkMeET31rOMiarsBNIHZKLGgvKc/LrjofAnBlOttf5ajRvqiRA8QsenbcooctK6d6Ts6aqZXBA+XbkKthiQg== + mime@3.0.0, mime@^3.0.0: version "3.0.0" resolved "https://registry.npmjs.org/mime/-/mime-3.0.0.tgz" @@ -9584,7 +9713,7 @@ node-fetch@2.6.1: resolved "https://registry.npmjs.org/node-fetch/-/node-fetch-2.6.1.tgz#045bd323631f76ed2e2b55573394416b639a0052" integrity sha512-V4aYg89jEoVRxRb2fJdAg8FHvI7cEyYdVAh94HH0UIK8oJxUfkjlDQN9RbMx+bEjP7+ggMiFRprSti032Oipxw== -node-fetch@^2.5.0, node-fetch@^2.6.7: +node-fetch@^2.5.0, node-fetch@^2.6.1, node-fetch@^2.6.7: version "2.6.7" resolved "https://registry.yarnpkg.com/node-fetch/-/node-fetch-2.6.7.tgz#24de9fba827e3b4ae44dc8b20256a379160052ad" integrity sha512-ZjMPFEfVx5j+y2yF35Kzx5sF7kDzxuDj6ziH4FFbOp87zKDZNx8yExJIb05OGF4Nlt9IHFIMBkRl41VdvcNdbQ== @@ -9596,7 +9725,7 @@ node-int64@^0.4.0: resolved "https://registry.npmjs.org/node-int64/-/node-int64-0.4.0.tgz" integrity sha1-h6kGXNs1XTGC2PlM4RGIuCXGijs= -node-mocks-http@^1.10.1: +node-mocks-http@^1.10.1, node-mocks-http@^1.11.0: version "1.11.0" resolved "https://registry.npmjs.org/node-mocks-http/-/node-mocks-http-1.11.0.tgz" integrity sha512-jS/WzSOcKbOeGrcgKbenZeNhxUNnP36Yw11+hL4TTxQXErGfqYZ+MaYNNvhaTiGIJlzNSqgQkk9j8dSu1YWSuw== @@ -9776,7 +9905,7 @@ on-headers@~1.0.2: resolved "https://registry.npmjs.org/on-headers/-/on-headers-1.0.2.tgz" integrity sha512-pZAE+FJLoyITytdqK0U5s+FIpjN0JP3OzFi/u8Rx+EV5/W+JTWGXG8xFzevE7AjBfDqHv/8vL8qQsIhHnqRkrA== -once@^1.3.0, once@^1.3.1, once@^1.4.0: +once@1.4.0, once@^1.3.0, once@^1.3.1, once@^1.4.0: version "1.4.0" resolved "https://registry.npmjs.org/once/-/once-1.4.0.tgz" integrity sha1-WDsap3WWHUsROsF9nFC6753Xa9E= @@ -10441,11 +10570,23 @@ punycode@^2.1.0, punycode@^2.1.1: resolved "https://registry.npmjs.org/punycode/-/punycode-2.1.1.tgz" integrity sha512-XRsRjdf+j5ml+y/6GKHPZbrF/8p2Yga0JPtdqTIY2Xe5ohJPD9saDJJLPvp9+NSBprVvevdXZybnj2cv8OEd0A== +qs@6.9.3: + version "6.9.3" + resolved "https://registry.yarnpkg.com/qs/-/qs-6.9.3.tgz#bfadcd296c2d549f1dffa560619132c977f5008e" + integrity sha512-EbZYNarm6138UKKq46tdx08Yo/q9ZhFoAXAI1meAFd2GtbRDhbZY2WQSICskT0c5q99aFzLG1D4nvTk9tqfXIw== + qs@6.9.7, qs@^6.9.4: version "6.9.7" resolved "https://registry.npmjs.org/qs/-/qs-6.9.7.tgz" integrity sha512-IhMFgUmuNpyRfxA90umL7ByLlgRXu6tIfKPpF5TmcfRLlLCckfP/g3IQmju6jjpu+Hh8rA+2p6A27ZSPOOHdKw== +qs@^6.10.3: + version "6.11.0" + resolved "https://registry.yarnpkg.com/qs/-/qs-6.11.0.tgz#fd0d963446f7a65e1367e01abd85429453f0c37a" + integrity sha512-MvjoMCJwEarSbUYk5O+nmoSzSutSsTwF85zcHPQ9OrlFoZOYIjaqBAJIqIXjptyD5vThxGq52Xu/MaJzRkIk4Q== + dependencies: + side-channel "^1.0.4" + qs@~6.5.2: version "6.5.3" resolved "https://registry.npmjs.org/qs/-/qs-6.5.3.tgz" @@ -11139,11 +11280,6 @@ set-blocking@^2.0.0: integrity sha512-KiKBS8AnWGEyLzofFfmvKwpdPzqiy16LvQfK3yv/fVH7Bj13/wl3JSR1J+rfgRE9q7xUJK4qvgS8raSOeLUehw== set-cookie-parser@^2.4.6, set-cookie-parser@^2.4.8: - version "2.4.8" - resolved "https://registry.npmjs.org/set-cookie-parser/-/set-cookie-parser-2.4.8.tgz" - integrity sha512-edRH8mBKEWNVIVMKejNnuJxleqYE/ZSdcT8/Nem9/mmosx12pctd80s2Oy00KNZzrogMZS5mauK2/ymL1bvlvg== - -set-cookie-parser@^2.4.8: version "2.4.8" resolved "https://registry.yarnpkg.com/set-cookie-parser/-/set-cookie-parser-2.4.8.tgz#d0da0ed388bc8f24e706a391f9c9e252a13c58b2" integrity sha512-edRH8mBKEWNVIVMKejNnuJxleqYE/ZSdcT8/Nem9/mmosx12pctd80s2Oy00KNZzrogMZS5mauK2/ymL1bvlvg== @@ -11542,6 +11678,11 @@ stream-transform@^2.1.3: dependencies: mixme "^0.5.1" +streamsearch@0.1.2: + version "0.1.2" + resolved "https://registry.yarnpkg.com/streamsearch/-/streamsearch-0.1.2.tgz#808b9d0e56fc273d809ba57338e929919a1a9f1a" + integrity sha512-jos8u++JKm0ARcSUTAZXOVC0mSox7Bhn6sBgty73P1f3JGf7yG2clTbBNHUdde/kdvP2FESam+vM6l8jBrNxHA== + strict-event-emitter@^0.2.0: version "0.2.0" resolved "https://registry.npmjs.org/strict-event-emitter/-/strict-event-emitter-0.2.0.tgz" @@ -11721,13 +11862,22 @@ superagent@^6.1.0: readable-stream "^3.6.0" semver "^7.3.2" -supertest@^6.1.5: - version "6.1.6" - resolved "https://registry.npmjs.org/supertest/-/supertest-6.1.6.tgz" - integrity sha512-0hACYGNJ8OHRg8CRITeZOdbjur7NLuNs0mBjVhdpxi7hP6t3QIbOzLON5RTUmZcy2I9riuII3+Pr2C7yztrIIg== +superagent@^8.0.0: + version "8.0.0" + resolved "https://registry.yarnpkg.com/superagent/-/superagent-8.0.0.tgz#2ea4587df4b81ef023ec01ebc6e1bcb9e2344cb6" + integrity sha512-iudipXEel+SzlP9y29UBWGDjB+Zzag+eeA1iLosaR2YHBRr1Q1kC29iBrF2zIVD9fqVbpZnXkN/VJmwFMVyNWg== dependencies: + component-emitter "^1.3.0" + cookiejar "^2.1.3" + debug "^4.3.4" + fast-safe-stringify "^2.1.1" + form-data "^4.0.0" + formidable "^2.0.1" methods "^1.1.2" - superagent "^6.1.0" + mime "2.6.0" + qs "^6.10.3" + readable-stream "^3.6.0" + semver "^7.3.7" supertest@^6.1.5: version "6.1.5" @@ -11737,6 +11887,14 @@ supertest@^6.1.5: methods "^1.1.2" superagent "^6.1.0" +supertest@^6.2.3: + version "6.2.4" + resolved "https://registry.yarnpkg.com/supertest/-/supertest-6.2.4.tgz#3dcebe42f7fd6f28dd7ac74c6cba881f7101b2f0" + integrity sha512-M8xVnCNv+q2T2WXVzxDECvL2695Uv2uUj2O0utxsld/HRyJvOU8W9f1gvsYxSNU4wmIe0/L/ItnpU4iKq0emDA== + dependencies: + methods "^1.1.2" + superagent "^8.0.0" + supports-color@^5.3.0: version "5.5.0" resolved "https://registry.npmjs.org/supports-color/-/supports-color-5.5.0.tgz" From cb539af1240f8f6b5e39d7ebfb579b6e761ab7f6 Mon Sep 17 00:00:00 2001 From: Aaron Powell Date: Mon, 23 May 2022 10:05:04 +1000 Subject: [PATCH 62/68] Apply suggestions from code review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Michaël De Boey --- packages/remix-azure-functions/package.json | 4 ++-- packages/remix-azure-functions/server.ts | 2 +- templates/azure-functions/package.json | 10 +++++----- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/packages/remix-azure-functions/package.json b/packages/remix-azure-functions/package.json index e6959855848..9dee24ad79b 100644 --- a/packages/remix-azure-functions/package.json +++ b/packages/remix-azure-functions/package.json @@ -15,10 +15,10 @@ "@remix-run/node": "1.4.3" }, "peerDependencies": { - "@azure/functions": "^1.2.3" + "@azure/functions": "^3.0.0" }, "devDependencies": { - "@azure/functions": "^1.2.3", + "@azure/functions": "^3.0.0", "@types/supertest": "^2.0.12", "node-mocks-http": "^1.11.0", "supertest": "^6.2.3" diff --git a/packages/remix-azure-functions/server.ts b/packages/remix-azure-functions/server.ts index 0f8e9561156..a6abc6f7a81 100644 --- a/packages/remix-azure-functions/server.ts +++ b/packages/remix-azure-functions/server.ts @@ -77,7 +77,7 @@ export function createRemixRequest(req: HttpRequest): NodeRequest { headers: createRemixHeaders(req.headers), }; - if (req.body && req.method !== "GET" && req.method !== "HEAD") { + if (req.body && !["HEAD", "GET"].includes(req.method)) { init.body = req.body; } diff --git a/templates/azure-functions/package.json b/templates/azure-functions/package.json index ea916d2e918..e7e8d694055 100644 --- a/templates/azure-functions/package.json +++ b/templates/azure-functions/package.json @@ -17,10 +17,10 @@ "@remix-run/dev": "*", "@remix-run/eslint-config": "*", "@remix-run/serve": "*", - "@types/react": "^17.0.24", - "@types/react-dom": "^17.0.9", - "azure-functions-core-tools": "4.0.3971", - "eslint": "^8.11.0", - "typescript": "4.6.3" + "@types/react": "^17.0.45", + "@types/react-dom": "^17.0.17", + "azure-functions-core-tools": "^4.0.4483", + "eslint": "^8.15.0", + "typescript": "^4.6.4" } } From 58be8256a02ebf797302f54c348da488d15cc76b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C3=ABl=20De=20Boey?= Date: Wed, 8 Jun 2022 19:34:30 +0200 Subject: [PATCH 63/68] chore(remix-azure-functions): run `sort-package-json` --- packages/remix-azure-functions/package.json | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/packages/remix-azure-functions/package.json b/packages/remix-azure-functions/package.json index 9dee24ad79b..f75a8d51560 100644 --- a/packages/remix-azure-functions/package.json +++ b/packages/remix-azure-functions/package.json @@ -1,26 +1,26 @@ { "name": "@remix-run/azure-functions", - "description": "Azure Functions server request handler for Remix", "version": "1.4.3", - "license": "MIT", + "description": "Azure Functions server request handler for Remix", + "bugs": { + "url": "https://github.com/remix-run/remix/issues" + }, "repository": { "type": "git", "url": "https://github.com/remix-run/remix", "directory": "packages/remix-azure-functions" }, - "bugs": { - "url": "https://github.com/remix-run/remix/issues" - }, + "license": "MIT", "dependencies": { "@remix-run/node": "1.4.3" }, - "peerDependencies": { - "@azure/functions": "^3.0.0" - }, "devDependencies": { "@azure/functions": "^3.0.0", "@types/supertest": "^2.0.12", "node-mocks-http": "^1.11.0", "supertest": "^6.2.3" + }, + "peerDependencies": { + "@azure/functions": "^3.0.0" } } \ No newline at end of file From 63783db9835e60662ccfdce4f9f3b85a05db8707 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C3=ABl=20De=20Boey?= Date: Wed, 8 Jun 2022 19:35:38 +0200 Subject: [PATCH 64/68] chore(remix-azure-functions): update dependencies --- packages/remix-azure-functions/package.json | 8 +- yarn.lock | 82 ++------------------- 2 files changed, 11 insertions(+), 79 deletions(-) diff --git a/packages/remix-azure-functions/package.json b/packages/remix-azure-functions/package.json index f75a8d51560..a67b7d1527a 100644 --- a/packages/remix-azure-functions/package.json +++ b/packages/remix-azure-functions/package.json @@ -1,6 +1,6 @@ { "name": "@remix-run/azure-functions", - "version": "1.4.3", + "version": "1.6.8", "description": "Azure Functions server request handler for Remix", "bugs": { "url": "https://github.com/remix-run/remix/issues" @@ -12,13 +12,13 @@ }, "license": "MIT", "dependencies": { - "@remix-run/node": "1.4.3" + "@remix-run/node": "1.6.8" }, "devDependencies": { - "@azure/functions": "^3.0.0", + "@azure/functions": "^3.2.0", "@types/supertest": "^2.0.12", "node-mocks-http": "^1.11.0", - "supertest": "^6.2.3" + "supertest": "^6.2.4" }, "peerDependencies": { "@azure/functions": "^3.0.0" diff --git a/yarn.lock b/yarn.lock index 8af3f97cd17..b9b21beee66 100644 --- a/yarn.lock +++ b/yarn.lock @@ -22,10 +22,10 @@ run-waterfall "^1.1.7" uid-safe "^2.1.5" -"@azure/functions@^1.2.3": - version "1.2.3" - resolved "https://registry.yarnpkg.com/@azure/functions/-/functions-1.2.3.tgz#65765837e7319eedffbf8a971cb2f78d4e043d54" - integrity sha512-dZITbYPNg6ay6ngcCOjRUh1wDhlFITS0zIkqplyH5KfKEAVPooaoaye5mUFnR+WP9WdGRjlNXyl/y2tgWKHcRg== +"@azure/functions@^3.2.0": + version "3.2.0" + resolved "https://registry.yarnpkg.com/@azure/functions/-/functions-3.2.0.tgz#c73003db8bd93be186824db29e98e00879bf0f91" + integrity sha512-HbE7iORnYcjLzKNf5mIQRJQDTsVxhoXHRWEZ6KWdGh4e7+F9xTloiBicavbSoVmlAYivenIVpryHanVwsQaHUw== "@babel/code-frame@7.16.7", "@babel/code-frame@^7.0.0", "@babel/code-frame@^7.10.4", "@babel/code-frame@^7.12.13", "@babel/code-frame@^7.16.7": version "7.16.7" @@ -2599,13 +2599,6 @@ "@types/connect" "*" "@types/node" "*" -"@types/busboy@^0.3.1": - version "0.3.2" - resolved "https://registry.yarnpkg.com/@types/busboy/-/busboy-0.3.2.tgz#2f29b017513415399c42632ae6a7cfcb1409b79c" - integrity sha512-iEvdm9Z9KdSs/ozuh1Z7ZsXrOl8F4M/CLMXPZHr3QuJ4d6Bjn+HBMC5EMKpwpAo8oi8iK9GZfFoHaIMrrZgwVw== - dependencies: - "@types/node" "*" - "@types/cacache@^15.0.0": version "15.0.1" resolved "https://registry.npmjs.org/@types/cacache/-/cacache-15.0.1.tgz" @@ -2920,14 +2913,6 @@ resolved "https://registry.npmjs.org/@types/ms/-/ms-0.7.31.tgz" integrity sha512-iiUgKzV9AuaEkZqkOLDIvlQiL6ltuZd9tGcW3gwpnX8JbuiuhFlEGmmFXEXkN50Cvq7Os88IY2v0dkDqXYWVgA== -"@types/node-fetch@^2.5.12": - version "2.6.2" - resolved "https://registry.yarnpkg.com/@types/node-fetch/-/node-fetch-2.6.2.tgz#d1a9c5fd049d9415dce61571557104dec3ec81da" - integrity sha512-DHqhlq5jeESLy19TYhLakJ07kNumXWjcDdxXsLUMJZ6ue8VZJj4kLPQVE/2mdHh3xZziNF1xppu5lwmS53HR+A== - dependencies: - "@types/node" "*" - form-data "^3.0.0" - "@types/node-fetch@^2.5.7": version "2.5.12" resolved "https://registry.npmjs.org/@types/node-fetch/-/node-fetch-2.5.12.tgz" @@ -3296,28 +3281,6 @@ json-schema-to-ts "1.6.4" ts-morph "12.0.0" -"@web-std/blob@^3.0.3": - version "3.0.4" - resolved "https://registry.yarnpkg.com/@web-std/blob/-/blob-3.0.4.tgz#dd67a685547331915428d69e723c7da2015c3fc5" - integrity sha512-+dibyiw+uHYK4dX5cJ7HA+gtDAaUUe6JsOryp2ZpAC7h4ICsh49E34JwHoEKPlPvP0llCrNzz45vvD+xX5QDBg== - dependencies: - "@web-std/stream" "1.0.0" - web-encoding "1.1.5" - -"@web-std/file@^3.0.0": - version "3.0.2" - resolved "https://registry.yarnpkg.com/@web-std/file/-/file-3.0.2.tgz#b84cc9ed754608b18dcf78ac62c40dbcc6a94692" - integrity sha512-pIH0uuZsmY8YFvSHP1NsBIiMT/1ce0suPrX74fEeO3Wbr1+rW0fUGEe4d0R99iLwXtyCwyserqCFI4BJkJlkRA== - dependencies: - "@web-std/blob" "^3.0.3" - -"@web-std/stream@1.0.0": - version "1.0.0" - resolved "https://registry.yarnpkg.com/@web-std/stream/-/stream-1.0.0.tgz#01066f40f536e4329d9b696dc29872f3a14b93c1" - integrity sha512-jyIbdVl+0ZJyKGTV0Ohb9E6UnxP+t7ZzX4Do3AHjZKxUXKMs9EmqnBDQgHF7bEw0EzbQygOjtt/7gvtmi//iCQ== - dependencies: - web-streams-polyfill "^3.1.1" - "@web3-storage/multipart-parser@^1.0.0": version "1.0.0" resolved "https://registry.npmjs.org/@web3-storage/multipart-parser/-/multipart-parser-1.0.0.tgz" @@ -4114,23 +4077,11 @@ bl@^4.0.3, bl@^4.1.0: inherits "^2.0.4" readable-stream "^3.4.0" -blob-stream@^0.1.3: - version "0.1.3" - resolved "https://registry.yarnpkg.com/blob-stream/-/blob-stream-0.1.3.tgz#98d668af6996e0f32ef666d06e215ccc7d77686c" - integrity sha512-xXwyhgVmPsFVFFvtM5P0syI17/oae+MIjLn5jGhuD86mmSJ61EWMWmbPrV/0+bdcH9jQ2CzIhmTQKNUJL7IPog== - dependencies: - blob "0.0.4" - blob-util@^2.0.2: version "2.0.2" resolved "https://registry.npmjs.org/blob-util/-/blob-util-2.0.2.tgz" integrity sha512-T7JQa+zsXXEa6/8ZhHcQEW1UFfVM49Ts65uBkFL6fz2QmrElqmbajIDJvuA0tEhRe5eIjpV9ZF+0RfZR9voJFQ== -blob@0.0.4: - version "0.0.4" - resolved "https://registry.yarnpkg.com/blob/-/blob-0.0.4.tgz#bcf13052ca54463f30f9fc7e95b9a47630a94921" - integrity sha512-YRc9zvVz4wNaxcXmiSgb9LAg7YYwqQ2xd0Sj6osfA7k/PKmIGVlnOYs3wOFdkRC9/JpQu8sGt/zHgJV7xzerfg== - bluebird@^3.7.2: version "3.7.2" resolved "https://registry.npmjs.org/bluebird/-/bluebird-3.7.2.tgz" @@ -4264,13 +4215,6 @@ builtin-modules@^3.1.0: resolved "https://registry.yarnpkg.com/builtin-modules/-/builtin-modules-3.3.0.tgz#cae62812b89801e9656336e46223e030386be7b6" integrity sha512-zhaCDicdLuWN5UbN5IMnFqNMhNfo919sH85y2/ea+5Yg9TsTkeZxpL+JLbp6cgYFS4sRLp3YV4S6yDuqVWHYOw== -busboy@^0.3.1: - version "0.3.1" - resolved "https://registry.yarnpkg.com/busboy/-/busboy-0.3.1.tgz#170899274c5bf38aae27d5c62b71268cd585fd1b" - integrity sha512-y7tTxhGKXcyBxRKAni+awqx8uqaJKrSFSNFSeRG5CsWNdmy2BIK+6VGWEW7TZnIO/533mtMEA4rOevQV815YJw== - dependencies: - dicer "0.3.0" - bytes@3.0.0: version "3.0.0" resolved "https://registry.npmjs.org/bytes/-/bytes-3.0.0.tgz" @@ -5241,13 +5185,6 @@ dezalgo@1.0.3: asap "^2.0.0" wrappy "1" -dicer@0.3.0: - version "0.3.0" - resolved "https://registry.yarnpkg.com/dicer/-/dicer-0.3.0.tgz#eacd98b3bfbf92e8ab5c2fdb71aaac44bb06b872" - integrity sha512-MdceRRWqltEG2dZqO769g27N/3PXfcKl04VhYnBlo2YhH7zPi88VebsjTKclaOyiuMaGU72hTfw3VkUitGcVCA== - dependencies: - streamsearch "0.1.2" - diff-sequences@^27.5.1: version "27.5.1" resolved "https://registry.npmjs.org/diff-sequences/-/diff-sequences-27.5.1.tgz" @@ -8304,7 +8241,7 @@ jsdom@^16.6.0: ws "^7.4.6" xml-name-validator "^3.0.0" -jsesc@3.0.2, jsesc@^3.0.1: +jsesc@3.0.2: version "3.0.2" resolved "https://registry.npmjs.org/jsesc/-/jsesc-3.0.2.tgz" integrity sha512-xKqzzWXDttJuOcawBt4KnKHHIf5oQ/Cxax+0PWFG+DFDgHNAdi+TXECADI+RYiFUMmx8792xsMbbgXj4CwnP4g== @@ -9713,7 +9650,7 @@ node-fetch@2.6.1: resolved "https://registry.npmjs.org/node-fetch/-/node-fetch-2.6.1.tgz#045bd323631f76ed2e2b55573394416b639a0052" integrity sha512-V4aYg89jEoVRxRb2fJdAg8FHvI7cEyYdVAh94HH0UIK8oJxUfkjlDQN9RbMx+bEjP7+ggMiFRprSti032Oipxw== -node-fetch@^2.5.0, node-fetch@^2.6.1, node-fetch@^2.6.7: +node-fetch@^2.5.0, node-fetch@^2.6.7: version "2.6.7" resolved "https://registry.yarnpkg.com/node-fetch/-/node-fetch-2.6.7.tgz#24de9fba827e3b4ae44dc8b20256a379160052ad" integrity sha512-ZjMPFEfVx5j+y2yF35Kzx5sF7kDzxuDj6ziH4FFbOp87zKDZNx8yExJIb05OGF4Nlt9IHFIMBkRl41VdvcNdbQ== @@ -11678,11 +11615,6 @@ stream-transform@^2.1.3: dependencies: mixme "^0.5.1" -streamsearch@0.1.2: - version "0.1.2" - resolved "https://registry.yarnpkg.com/streamsearch/-/streamsearch-0.1.2.tgz#808b9d0e56fc273d809ba57338e929919a1a9f1a" - integrity sha512-jos8u++JKm0ARcSUTAZXOVC0mSox7Bhn6sBgty73P1f3JGf7yG2clTbBNHUdde/kdvP2FESam+vM6l8jBrNxHA== - strict-event-emitter@^0.2.0: version "0.2.0" resolved "https://registry.npmjs.org/strict-event-emitter/-/strict-event-emitter-0.2.0.tgz" @@ -11887,7 +11819,7 @@ supertest@^6.1.5: methods "^1.1.2" superagent "^6.1.0" -supertest@^6.2.3: +supertest@^6.2.4: version "6.2.4" resolved "https://registry.yarnpkg.com/supertest/-/supertest-6.2.4.tgz#3dcebe42f7fd6f28dd7ac74c6cba881f7101b2f0" integrity sha512-M8xVnCNv+q2T2WXVzxDECvL2695Uv2uUj2O0utxsld/HRyJvOU8W9f1gvsYxSNU4wmIe0/L/ItnpU4iKq0emDA== From a2ffdf06fc78863739c0ec6f0ec22ef630478e6a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C3=ABl=20De=20Boey?= Date: Wed, 8 Jun 2022 19:36:04 +0200 Subject: [PATCH 65/68] chore(remix-azure-functions): add `engines` field to `package.json` --- packages/remix-azure-functions/package.json | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/packages/remix-azure-functions/package.json b/packages/remix-azure-functions/package.json index a67b7d1527a..9587d000e6e 100644 --- a/packages/remix-azure-functions/package.json +++ b/packages/remix-azure-functions/package.json @@ -22,5 +22,8 @@ }, "peerDependencies": { "@azure/functions": "^3.0.0" + }, + "engines": { + "node": ">=14" } -} \ No newline at end of file +} From 8e94a446bfe6150e977f77c31036003b6294a032 Mon Sep 17 00:00:00 2001 From: Aaron Powell Date: Thu, 16 Jun 2022 10:33:46 +1000 Subject: [PATCH 66/68] Apply suggestions from code review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Michaël De Boey Co-authored-by: Christian Köberl --- packages/remix-azure-functions/server.ts | 2 +- templates/azure-functions/.nvmrc | 2 +- templates/azure-functions/package.json | 5 ++--- templates/azure-functions/public/staticwebapp.config.json | 8 +++++--- 4 files changed, 9 insertions(+), 8 deletions(-) diff --git a/packages/remix-azure-functions/server.ts b/packages/remix-azure-functions/server.ts index a6abc6f7a81..8053796b222 100644 --- a/packages/remix-azure-functions/server.ts +++ b/packages/remix-azure-functions/server.ts @@ -41,7 +41,7 @@ export function createRequestHandler({ return async (_context: Context, req: HttpRequest) => { let request = createRemixRequest(req); - let loadContext = getLoadContext ? getLoadContext(req) : undefined; + let loadContext = getLoadContext?.(req); let response = (await handleRequest( request as unknown as Request, diff --git a/templates/azure-functions/.nvmrc b/templates/azure-functions/.nvmrc index b6a7d89c68e..8351c19397f 100644 --- a/templates/azure-functions/.nvmrc +++ b/templates/azure-functions/.nvmrc @@ -1 +1 @@ -16 +14 diff --git a/templates/azure-functions/package.json b/templates/azure-functions/package.json index e7e8d694055..94d0940d38d 100644 --- a/templates/azure-functions/package.json +++ b/templates/azure-functions/package.json @@ -2,14 +2,13 @@ "scripts": { "build": "remix build", "dev": "swa start ./public --run \"remix dev\" --api-location .", - "postinstall": "func init --worker-runtime node --language typescript && remix setup azure-functions" + "postinstall": "func init --worker-runtime node --language typescript" }, "dependencies": { "@remix-run/azure-functions": "*", "@remix-run/react": "*", "react": "^17.0.2", - "react-dom": "^17.0.2", - "remix": "*" + "react-dom": "^17.0.2" }, "devDependencies": { "@azure/functions": "^3.0.0", diff --git a/templates/azure-functions/public/staticwebapp.config.json b/templates/azure-functions/public/staticwebapp.config.json index 54ca177c6e9..dd13d60f64e 100644 --- a/templates/azure-functions/public/staticwebapp.config.json +++ b/templates/azure-functions/public/staticwebapp.config.json @@ -1,11 +1,13 @@ { "routes": [ { - "route": "/", - "rewrite": "/api/azure" + "route": "/build/*" + }, + { + "route": "/favicon.ico" }, { - "route": "/index.html", + "route": "/*", "rewrite": "/api/azure" } ], From ecaaeef811ca2a2728b503c5dab274b095a91139 Mon Sep 17 00:00:00 2001 From: Aaron Powell Date: Fri, 30 Sep 2022 08:58:27 +1000 Subject: [PATCH 67/68] Update templates/azure-functions/app/entry.client.tsx --- templates/azure-functions/app/entry.client.tsx | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/templates/azure-functions/app/entry.client.tsx b/templates/azure-functions/app/entry.client.tsx index a19979b2527..ffef95f66db 100644 --- a/templates/azure-functions/app/entry.client.tsx +++ b/templates/azure-functions/app/entry.client.tsx @@ -1,4 +1,4 @@ -import { hydrate } from "react-dom"; -import { RemixBrowser } from "remix"; +import { RemixBrowser } from "@remix-run/react"; +import { hydrateRoot } from "react-dom/client"; -hydrate(, document); +hydrateRoot(document, ); From f9b65ff6584ba91f4b62ecf955ae75b4a68fc218 Mon Sep 17 00:00:00 2001 From: Aaron Powell Date: Fri, 30 Sep 2022 10:01:34 +1000 Subject: [PATCH 68/68] Apply suggestions from code review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Michaël De Boey --- packages/remix-azure-functions/package.json | 4 +- .../azure-functions/app/entry.server.tsx | 47 +++++++++++++++---- templates/azure-functions/app/root.tsx | 4 +- .../github-actions/azure-static-web-apps.yml | 2 +- templates/azure-functions/package.json | 19 ++++---- .../public/staticwebapp.config.json | 2 +- templates/azure-functions/tsconfig.json | 2 + 7 files changed, 55 insertions(+), 25 deletions(-) diff --git a/packages/remix-azure-functions/package.json b/packages/remix-azure-functions/package.json index 9587d000e6e..1f0168a5612 100644 --- a/packages/remix-azure-functions/package.json +++ b/packages/remix-azure-functions/package.json @@ -1,6 +1,6 @@ { "name": "@remix-run/azure-functions", - "version": "1.6.8", + "version": "1.7.2", "description": "Azure Functions server request handler for Remix", "bugs": { "url": "https://github.com/remix-run/remix/issues" @@ -12,7 +12,7 @@ }, "license": "MIT", "dependencies": { - "@remix-run/node": "1.6.8" + "@remix-run/node": "1.7.2" }, "devDependencies": { "@azure/functions": "^3.2.0", diff --git a/templates/azure-functions/app/entry.server.tsx b/templates/azure-functions/app/entry.server.tsx index cef2e81af71..f339800aabc 100644 --- a/templates/azure-functions/app/entry.server.tsx +++ b/templates/azure-functions/app/entry.server.tsx @@ -1,6 +1,10 @@ -import { renderToString } from "react-dom/server"; -import { RemixServer } from "remix"; -import type { EntryContext } from "remix"; +import { PassThrough } from "stream"; +import type { EntryContext } from "@remix-run/node"; +import { Response } from "@remix-run/node"; +import { RemixServer } from "@remix-run/react"; +import { renderToPipeableStream } from "react-dom/server"; + +const ABORT_DELAY = 5000; export default function handleRequest( request: Request, @@ -8,14 +12,37 @@ export default function handleRequest( responseHeaders: Headers, remixContext: EntryContext ) { - let markup = renderToString( - - ); + return new Promise((resolve, reject) => { + let didError = false; + + const { pipe, abort } = renderToPipeableStream( + , + { + onShellReady: () => { + const body = new PassThrough(); + + responseHeaders.set("Content-Type", "text/html"); + + resolve( + new Response(body, { + headers: responseHeaders, + status: didError ? 500 : responseStatusCode, + }) + ); + + pipe(body); + }, + onShellError: (err) => { + reject(err); + }, + onError: (error) => { + didError = true; - responseHeaders.set("Content-Type", "text/html"); + console.error(error); + }, + } + ); - return new Response("" + markup, { - status: responseStatusCode, - headers: responseHeaders, + setTimeout(abort, ABORT_DELAY); }); } diff --git a/templates/azure-functions/app/root.tsx b/templates/azure-functions/app/root.tsx index 471e0ac0d57..927a0f745df 100644 --- a/templates/azure-functions/app/root.tsx +++ b/templates/azure-functions/app/root.tsx @@ -1,3 +1,4 @@ +import type { MetaFunction } from "@remix-run/node"; import { Links, LiveReload, @@ -5,8 +6,7 @@ import { Outlet, Scripts, ScrollRestoration, -} from "remix"; -import type { MetaFunction } from "remix"; +} from "@remix-run/react"; export const meta: MetaFunction = () => ({ charset: "utf-8", diff --git a/templates/azure-functions/github-actions/azure-static-web-apps.yml b/templates/azure-functions/github-actions/azure-static-web-apps.yml index 62783006770..85a4edd6770 100644 --- a/templates/azure-functions/github-actions/azure-static-web-apps.yml +++ b/templates/azure-functions/github-actions/azure-static-web-apps.yml @@ -15,7 +15,7 @@ jobs: runs-on: ubuntu-latest name: Build and Deploy Job steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 with: submodules: true - name: Build And Deploy diff --git a/templates/azure-functions/package.json b/templates/azure-functions/package.json index 94d0940d38d..a182f21d2e3 100644 --- a/templates/azure-functions/package.json +++ b/templates/azure-functions/package.json @@ -6,20 +6,21 @@ }, "dependencies": { "@remix-run/azure-functions": "*", + "@remix-run/node": "*", "@remix-run/react": "*", - "react": "^17.0.2", - "react-dom": "^17.0.2" + "react": "^18.2.0", + "react-dom": "^18.2.0" }, "devDependencies": { - "@azure/functions": "^3.0.0", - "@azure/static-web-apps-cli": "^0.8.3", + "@azure/functions": "^3.2.0", + "@azure/static-web-apps-cli": "^1.0.2", "@remix-run/dev": "*", "@remix-run/eslint-config": "*", "@remix-run/serve": "*", - "@types/react": "^17.0.45", - "@types/react-dom": "^17.0.17", - "azure-functions-core-tools": "^4.0.4483", - "eslint": "^8.15.0", - "typescript": "^4.6.4" + "@types/react": "^18.0.15", + "@types/react-dom": "^18.0.6", + "azure-functions-core-tools": "^4.0.4785", + "eslint": "^8.23.1", + "typescript": "^4.7.4" } } diff --git a/templates/azure-functions/public/staticwebapp.config.json b/templates/azure-functions/public/staticwebapp.config.json index dd13d60f64e..e881715ad4a 100644 --- a/templates/azure-functions/public/staticwebapp.config.json +++ b/templates/azure-functions/public/staticwebapp.config.json @@ -15,6 +15,6 @@ "rewrite": "/api/azure" }, "platform": { - "apiRuntime": "node:16" + "apiRuntime": "node:14" } } \ No newline at end of file diff --git a/templates/azure-functions/tsconfig.json b/templates/azure-functions/tsconfig.json index 749e4b959e8..20f8a386a6c 100644 --- a/templates/azure-functions/tsconfig.json +++ b/templates/azure-functions/tsconfig.json @@ -9,6 +9,8 @@ "resolveJsonModule": true, "target": "ES2019", "strict": true, + "allowJs": true, + "forceConsistentCasingInFileNames": true, "baseUrl": ".", "paths": { "~/*": ["./app/*"]