Skip to content

Commit

Permalink
feat: update edge functions bootstrap (#5672)
Browse files Browse the repository at this point in the history
  • Loading branch information
eduardoboucas authored May 3, 2023
1 parent be998a0 commit 01570e9
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 16 deletions.
2 changes: 1 addition & 1 deletion src/lib/edge-functions/bootstrap.mjs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { env } from 'process'

const latestBootstrapURL = 'https://643581608391e3000851cc94--edge.netlify.com/bootstrap/index-combined.ts'
const latestBootstrapURL = 'https://64523ab4e7865600087fc3df--edge.netlify.com/bootstrap/index-combined.ts'

export const getBootstrapURL = () => env.NETLIFY_EDGE_BOOTSTRAP || latestBootstrapURL
41 changes: 26 additions & 15 deletions tests/integration/100.command.dev.test.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -1015,8 +1015,14 @@ test('should have only allowed environment variables set', async (t) => {
},
})
.withEdgeFunction({
// eslint-disable-next-line no-undef
handler: () => new Response(`${JSON.stringify(Deno.env.toObject())}`),
handler: () => {
// eslint-disable-next-line no-undef
const fromDenoGlobal = Deno.env.toObject()
// eslint-disable-next-line no-undef
const fromNetlifyGlobal = Netlify.env.toObject()

return new Response(`${JSON.stringify({ fromDenoGlobal, fromNetlifyGlobal })}`)
},
name: 'env',
})
.withContentFile({
Expand All @@ -1041,24 +1047,29 @@ test('should have only allowed environment variables set', async (t) => {
const response = await got(`http://localhost:${port}/env`).then((edgeResponse) =>
JSON.parse(edgeResponse.body),
)
const envKeys = Object.keys(response)
const buckets = Object.values(response)
t.is(buckets.length, 2)

buckets.forEach((bucket) => {
const bucketKeys = Object.keys(bucket)

t.true(envKeys.includes('DENO_REGION'))
t.is(response.DENO_REGION, 'local')
t.true(bucketKeys.includes('DENO_REGION'))
t.is(bucket.DENO_REGION, 'local')

t.true(envKeys.includes('NETLIFY_DEV'))
t.is(response.NETLIFY_DEV, 'true')
t.true(bucketKeys.includes('NETLIFY_DEV'))
t.is(bucket.NETLIFY_DEV, 'true')

t.true(envKeys.includes('SECRET_ENV'))
t.is(response.SECRET_ENV, 'true')
t.true(bucketKeys.includes('SECRET_ENV'))
t.is(bucket.SECRET_ENV, 'true')

t.true(envKeys.includes('FROM_ENV'))
t.is(response.FROM_ENV, 'YAS')
t.true(bucketKeys.includes('FROM_ENV'))
t.is(bucket.FROM_ENV, 'YAS')

t.false(envKeys.includes('DENO_DEPLOYMENT_ID'))
t.false(envKeys.includes('NODE_ENV'))
t.false(envKeys.includes('DEPLOY_URL'))
t.false(envKeys.includes('URL'))
t.false(bucketKeys.includes('DENO_DEPLOYMENT_ID'))
t.false(bucketKeys.includes('NODE_ENV'))
t.false(bucketKeys.includes('DEPLOY_URL'))
t.false(bucketKeys.includes('URL'))
})
},
)
})
Expand Down

1 comment on commit 01570e9

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

📊 Benchmark results

  • Package size: 238 MB

Please sign in to comment.