From 7832c4a850f7631364db63a7a0bf9c4418c7e4c8 Mon Sep 17 00:00:00 2001 From: ematipico Date: Mon, 17 Jul 2023 14:56:14 +0000 Subject: [PATCH] [ci] format --- packages/integrations/netlify/README.md | 8 +++----- .../integrations/netlify/src/integration-functions.ts | 4 ++-- packages/integrations/netlify/src/middleware.ts | 4 ++-- packages/integrations/netlify/src/shared.ts | 4 ++-- 4 files changed, 9 insertions(+), 11 deletions(-) diff --git a/packages/integrations/netlify/README.md b/packages/integrations/netlify/README.md index 31337b97d0..f20c535024 100644 --- a/packages/integrations/netlify/README.md +++ b/packages/integrations/netlify/README.md @@ -115,7 +115,6 @@ Once you run `astro build` there will be a `dist/_redirects` file. Netlify will > **Note** > You can still include a `public/_redirects` file for manual redirects. Any redirects you specify in the redirects config are appended to the end of your own. - ### Edge Middleware with Astro middleware The `@astrojs/netlify/functions` adapter can automatically create an edge function that will act as "Edge Middleware", from an Astro middleware in your code base. @@ -140,14 +139,14 @@ Optionally, you can create a file recognized by the adapter named `netlify-edge- Typings require the [`https://edge.netlify.com`](https://docs.netlify.com/edge-functions/api/#reference) types. > Netlify edge functions run in a Deno environment, so you would need to import types using URLs. -> +> > You can find more in the [Netlify documentation page](https://docs.netlify.com/edge-functions/api/#runtime-environment) ```ts // src/netlify-edge-middleware.ts -import type { Context } from "https://edge.netlify.com"; +import type { Context } from 'https://edge.netlify.com'; -export default function ({ request, context }: { request: Request, context: Context }): object { +export default function ({ request, context }: { request: Request; context: Context }): object { // do something with request and context return { title: "Spider-man's blog", @@ -173,7 +172,6 @@ When you opt-in to this feature, there are a few constraints to note: - Only `request` and `context` may be used to produce an `Astro.locals` object. Operations like redirects, etc. should be delegated to Astro middleware. - `Astro.locals` **must be serializable**. Failing to do so will result in a **runtime error**. This means that you **cannot** store complex types like `Map`, `function`, `Set`, etc. - ## Usage [Read the full deployment guide here.](https://docs.astro.build/en/guides/deploy/netlify/) diff --git a/packages/integrations/netlify/src/integration-functions.ts b/packages/integrations/netlify/src/integration-functions.ts index 64bdbb2037..f8b9171af9 100644 --- a/packages/integrations/netlify/src/integration-functions.ts +++ b/packages/integrations/netlify/src/integration-functions.ts @@ -1,9 +1,9 @@ import type { AstroAdapter, AstroConfig, AstroIntegration, RouteData } from 'astro'; import { extname } from 'node:path'; -import type { Args } from './netlify-functions.js'; -import { createRedirects } from './shared.js'; import { fileURLToPath } from 'node:url'; import { generateEdgeMiddleware } from './middleware.js'; +import type { Args } from './netlify-functions.js'; +import { createRedirects } from './shared.js'; export const NETLIFY_EDGE_MIDDLEWARE_FILE = 'netlify-edge-middleware'; export const ASTRO_LOCALS_HEADER = 'x-astro-locals'; diff --git a/packages/integrations/netlify/src/middleware.ts b/packages/integrations/netlify/src/middleware.ts index a53d4fbde3..3c2f4f6974 100644 --- a/packages/integrations/netlify/src/middleware.ts +++ b/packages/integrations/netlify/src/middleware.ts @@ -1,6 +1,6 @@ -import { fileURLToPath, pathToFileURL } from 'node:url'; -import { join } from 'node:path'; import { existsSync } from 'node:fs'; +import { join } from 'node:path'; +import { fileURLToPath, pathToFileURL } from 'node:url'; import { ASTRO_LOCALS_HEADER } from './integration-functions.js'; import { DENO_SHIM } from './shared.js'; diff --git a/packages/integrations/netlify/src/shared.ts b/packages/integrations/netlify/src/shared.ts index c0ed9ec17a..91ce49ef6e 100644 --- a/packages/integrations/netlify/src/shared.ts +++ b/packages/integrations/netlify/src/shared.ts @@ -1,9 +1,9 @@ import { createRedirectsFromAstroRoutes } from '@astrojs/underscore-redirects'; import type { AstroConfig, RouteData } from 'astro'; -import fs from 'node:fs'; -import { fileURLToPath } from 'url'; import esbuild from 'esbuild'; +import fs from 'node:fs'; import npath from 'path'; +import { fileURLToPath } from 'url'; export const DENO_SHIM = `globalThis.process = { argv: [],