Skip to content

Commit b2edd7e

Browse files
committed
Merge branch 'main' into COMSUP-249_jwt_example
2 parents ead248b + ed73613 commit b2edd7e

File tree

87 files changed

+63125
-8885
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

87 files changed

+63125
-8885
lines changed

.github/workflows/deploy-examples-dev.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ concurrency:
1919

2020
env:
2121
# Node version for all the jobs
22-
NODE_VERSION: 16
22+
NODE_VERSION: 18
2323

2424
# Set env var based on branch name
2525
GIT_REF: ${{ github.ref }}

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,5 @@
22
node_modules/
33
**/node_modules/
44
**/.edgio/**
5+
**/.yalc/**
6+
yalc.lock

examples/v7-astro/package-lock.json

Lines changed: 3118 additions & 2585 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

examples/v7-astro/package.json

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,11 @@
1616
"astro": "^3.2.3"
1717
},
1818
"devDependencies": {
19-
"@edgio/astro": "^7.2.7",
20-
"@edgio/cli": "^7.2.7",
21-
"@edgio/core": "^7.2.7",
22-
"@edgio/devtools": "^7.2.7",
23-
"@edgio/prefetch": "^7.2.7"
19+
"@edgio/astro": "^7.2.8",
20+
"@edgio/cli": "^7.2.8",
21+
"@edgio/core": "^7.2.8",
22+
"@edgio/devtools": "^7.2.8",
23+
"@edgio/prefetch": "^7.2.8"
2424
},
2525
"repository": "[email protected]:edgio-docs/edgio-v7-astro-example.git"
2626
}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"extends": "next/core-web-vitals"
3+
}

examples/v7-edge-functions/.gitignore

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,45 @@
1+
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
2+
3+
# dependencies
4+
/node_modules
5+
/.pnp
6+
.pnp.js
7+
.yarn/install-state.gz
8+
9+
# testing
10+
/coverage
11+
12+
# next.js
13+
/.next/
14+
/out/
15+
16+
# production
17+
/build
18+
19+
# misc
20+
.DS_Store
21+
*.pem
22+
23+
# debug
24+
npm-debug.log*
25+
yarn-debug.log*
26+
yarn-error.log*
27+
28+
# local env files
29+
.env*.local
30+
31+
# vercel
32+
.vercel
33+
34+
# typescript
35+
*.tsbuildinfo
36+
next-env.d.ts
37+
138
# Temporary Edgio files
239
.edgio
340

441
# Node.js modules
542
node_modules
43+
44+
# Edgio generated build directory
45+
.edgio

examples/v7-edge-functions/edgio.config.js

Lines changed: 63 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,65 @@
44
require('dotenv').config();
55

66
module.exports = {
7+
connector: '@edgio/next',
8+
79
// The name of the site in Edgio to which this app should be deployed.
8-
name: 'edgio-functions-examples',
10+
// name: 'my-site-name',
911

10-
// The name of the team in Edgio to which this app should be deployed.
11-
team: 'edge-functions-sandbox',
12+
// The name of the organization in Edgio to which this app should be deployed.
13+
// organization: 'my-organization-name',
1214

1315
// Overrides the default path to the routes file. The path should be relative to the root of your app.
1416
// routes: 'routes.js',
1517

18+
// When set to true or omitted entirely, Edgio includes the deployment number in the cache key,
19+
// effectively purging the cache each time you deploy.
20+
// purgeCacheOnDeploy: false,
21+
22+
next: {
23+
// Output sourcemaps so that stack traces have original source filenames and line numbers when tailing
24+
// the logs in the Edgio developer console.
25+
// This config options replaces the edgioSourceMaps option in next.config.js.
26+
// @default true
27+
// generateSourceMaps: true
28+
//
29+
// Disables the Edgio image optimizer and allows to use the Next's built in image optimizer.
30+
// This config options replaces the disableImageOptimizer option in edgio.config.js root.
31+
// @default false
32+
// disableImageOptimizer: false
33+
//
34+
// Disables the Edgio development tools widget on the site.
35+
// This config options replaces the disableEdgioDevTools option in next.config.js.
36+
// @default false
37+
// disableDevtools: false
38+
//
39+
// Disables the build of the service worker.
40+
// @default false
41+
// disableServiceWorker: false
42+
//
43+
// Forces the @edgio/next connector to use the server build.
44+
// This config option replaces the NEXT_FORCE_SERVER_BUILD env variable.
45+
// @default false
46+
// forceServerBuild: false
47+
//
48+
// Optimizes the server build by bundling all server assets and decreasing the overall startup time.
49+
// This option has no effect on apps with serverless build.
50+
// This option is set to false for Next 13.x apps.
51+
// @default true
52+
// optimizeServerBuild: true
53+
//
54+
// Set this option to false to remove the default rule that proxies all requests to Next.js in serverless.
55+
// This is useful if you want to proxy all unmatched pages to different origin.
56+
// @default true
57+
// proxyToServerlessByDefault: true
58+
//
59+
// Set this option to true to honor Next's internal redirects that either add or remove a trailing slash
60+
// depending on the value of the `trailingSlash` config. When set to false, these internal redirects are not honored,
61+
// so sites that fallback to serving from an origin do not add or remove the trailing slash for origin URLs.
62+
// @default true
63+
// enforceTrailingSlash: true
64+
},
65+
1666
origins: [
1767
{
1868
// The name of the backend origin
@@ -30,6 +80,15 @@ module.exports = {
3080
},
3181
],
3282
},
83+
{
84+
name: 'echo',
85+
override_host_header: 'http-echo.raees.me',
86+
hosts: [
87+
{
88+
location: 'http-echo.raees.me',
89+
},
90+
],
91+
},
3392
{
3493
name: 'planetscale',
3594
override_host_header: 'aws.connect.psdb.cloud',
@@ -63,28 +122,6 @@ module.exports = {
63122
},
64123
],
65124

66-
// Uncomment the following to specify environment specific configs
67-
// environments: {
68-
// production: {
69-
// hostnames: [{ hostname: 'www.mysite.com' }],
70-
// },
71-
// staging: {
72-
// hostnames: [{ hostname: 'staging.mysite.com' }],
73-
// origins: [
74-
// {
75-
// name: 'origin',
76-
// hosts: [{ location: 'staging-origin.mysite.com' }],
77-
// override_host_header: 'staging-origin.mysite.com',
78-
// tls_verify: {
79-
// use_sni: true,
80-
// sni_hint_and_strict_san_check: 'staging-origin.mysite.com',
81-
// },
82-
// shields: { us_east: 'DCD' },
83-
// },
84-
// ],
85-
// },
86-
// },
87-
88125
// Options for hosting serverless functions on Edgio
89126
// serverless: {
90127
// // Set to true to include all packages listed in the dependencies property of package.json when deploying to Edgio.
@@ -100,7 +137,7 @@ module.exports = {
100137
// Defaults to 200, which is the maximum allowed value.
101138
// prerenderConcurrency: 200,
102139

103-
// A list of glob patterns identifying which source files should be uploaded when running edgio deploy --includeSources.
140+
// A list of glob patterns identifying which prerenderConcurrency source files should be uploaded when running edgio deploy --includeSources.
104141
// This option is primarily used to share source code with Edgio support personnel for the purpose of debugging. If omitted,
105142
// edgio deploy --includeSources will result in all files which are not gitignored being uploaded to Edgio.
106143
//

examples/v7-edge-functions/functions/database/upstash/index.js

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import {
44
setCookieToResponse,
55
} from '../../../utils/cookies';
66
import { setEnvFromContext } from '../../../utils/polyfills/process.env';
7+
import '../../../utils/polyfills/URL';
78
import waitingPage from './waiting-room-capacity.html';
89
import landingPage from './waiting-room-landing.html';
910

@@ -59,7 +60,13 @@ function generateId(len = 10) {
5960
* Handle the default response.
6061
*/
6162
async function getDefaultResponse(request, userId) {
62-
const response = new Response(landingPage);
63+
const response = new Response(
64+
landingPage({
65+
domain: getDomainFromRequest(request),
66+
maxUsers: TOTAL_ACTIVE_USERS,
67+
sessionDuration: SESSION_DURATION_SECONDS,
68+
})
69+
);
6370
response.headers.set('content-type', 'text/html;charset=UTF-8');
6471

6572
const cookies = getCookiesFromRequest(request);
@@ -126,7 +133,12 @@ async function setExpiryRecord(key, value, seconds) {
126133
* Response for the waiting room.
127134
*/
128135
async function getWaitingRoomResponse() {
129-
const response = new Response(waitingPage);
136+
const response = new Response(waitingPage());
130137
response.headers.set('content-type', 'text/html;charset=UTF-8');
131138
return response;
132139
}
140+
141+
function getDomainFromRequest(request) {
142+
const url = new URL(request.url);
143+
return url.origin;
144+
}

examples/v7-edge-functions/functions/database/upstash/waiting-room-capacity.html.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
const template = `
1+
const template = () => `
22
<!DOCTYPE html>
33
<html lang="en">
44

examples/v7-edge-functions/functions/database/upstash/waiting-room-landing.html.js

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
const template = `
1+
const template = ({ domain, maxUsers, sessionDuration }) => `
22
<!DOCTYPE html>
33
<html lang="en">
44
@@ -103,11 +103,18 @@ const template = `
103103
<div class='container'>
104104
<h1>Welcome to the Waiting Room Demo</h1>
105105
<p>
106-
This demo showcases an effective way to manage website traffic during high-volume periods. When the site is at full capacity, visitors are temporarily placed in a waiting room, ensuring a smooth user experience.
106+
This demo showcases an effective way to manage website traffic during high-volume periods.
107+
When the site is at full capacity, visitors are temporarily placed in a waiting room, ensuring a smooth user experience.
108+
</p>
109+
<p>
110+
This is configured for a maximum of ${maxUsers} active sessions, with each session lasting ${sessionDuration} seconds.
111+
</p>
112+
<p>
113+
Experience this firsthand by opening <a href="${domain}/example/upstash-database">this link</a> in multiple incognito/private browser sessions.
114+
Once the site is at full capacity (2 active sessions), you will be placed in a waiting room until a spot opens up.
107115
</p>
108-
<p>Experience this firsthand by opening <a href="/example/upstash-database">this link</a> in multiple browser sessions. Once the site is at full capacity (2 active sessions), you will be placed in a waiting room until a spot opens up.</p>
109116
<p>Optionally, issue the <pre>curl</pre> command below to make multiple requests:</p>
110-
<div class="code-block">curl https://edgio-community-examples-v7-edge-functions-live.edgio.link/example/upstash-database</div>
117+
<div class="code-block">curl ${domain}/example/upstash-database</div>
111118
<button class="copy-btn" onclick="copyCodeToClipboard()">Copy Code</button>
112119
<p>Dive into the code to see how it works.</p>
113120
<p><a href="https://github.com/edgio-docs/edgio-v7-edge-functions-example" target="_blank">View the demo code on GitHub</a></p>

0 commit comments

Comments
 (0)