-
Notifications
You must be signed in to change notification settings - Fork 81
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
032c422
commit e7b5474
Showing
9 changed files
with
5,304 additions
and
373 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
.publish-id | ||
/bin | ||
/pkg | ||
/static-publisher |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
# Forma36 CDN | ||
|
||
The `public` folder is hosted at `cdn.f36.contentful.com`. | ||
|
||
## Development | ||
|
||
Run `npm run serve` to start the server locally |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
# This file describes a Fastly Compute package. To learn more visit: | ||
# https://developer.fastly.com/reference/fastly-toml/ | ||
|
||
description = "Forma 36 CDN" | ||
language = "javascript" | ||
manifest_version = 2 | ||
name = "@contentful/f36-cdn" | ||
|
||
[scripts] | ||
build = "npm run build" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
{ | ||
"name": "@contentful/f36-cdn", | ||
"version": "1.0.0", | ||
"private": true, | ||
"description": "Forma 36 CDN", | ||
"type": "module", | ||
"dependencies": { | ||
"@fastly/js-compute": "3.0.0" | ||
}, | ||
"devDependencies": { | ||
"@fastly/cli": "10.14.0", | ||
"@fastly/compute-js-static-publish": "6.1.0" | ||
}, | ||
"engines": { | ||
"node": ">=20.0.0" | ||
}, | ||
"scripts": { | ||
"deploy": "fastly compute deploy", | ||
"prebuild": "npx compute-js-static-publish --build-static", | ||
"build": "js-compute-runtime ./src/index.js ./bin/main.wasm", | ||
"serve": "fastly compute serve" | ||
} | ||
} |
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
/// <reference types="@fastly/js-compute" /> | ||
import { getServer } from '../static-publisher/statics.js'; | ||
const staticContentServer = getServer(); | ||
|
||
// eslint-disable-next-line no-restricted-globals | ||
addEventListener('fetch', (event) => event.respondWith(handleRequest(event))); | ||
async function handleRequest(event) { | ||
const response = await staticContentServer.serveRequest(event.request); | ||
if (response != null) { | ||
return response; | ||
} | ||
|
||
// Do custom things here! | ||
// Handle API requests, serve non-static responses, etc. | ||
|
||
return new Response('Not found', { status: 404 }); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
/** @type {import('@fastly/compute-js-static-publish').StaticPublisherConfig} */ | ||
const config = { | ||
rootDir: './public', | ||
staticContentRootDir: './static-publisher', | ||
server: { | ||
staticItems: ['/fonts/*'], | ||
}, | ||
}; | ||
|
||
// eslint-disable-next-line import/no-default-export | ||
export default config; |