Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Discord / HTMLRewriter: inject meta from API call #3

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
node_modules
dist
.mf
.mf
.envrc
41 changes: 41 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "Miniflare (npm)",
"type": "node",
"request": "launch",
"runtimeExecutable": "npm",
"runtimeArgs": ["run", "dev"],
"skipFiles": ["<node_internals>/**"]
// Collect a log file by setting trace: true in your launch.json, then upload it here.
// https://microsoft.github.io/vscode-pwa-analyzer/index.html
// via https://stackoverflow.com/questions/64589447/unbound-breakpoint-vs-code-chrome-angular
// "trace": true
},
{
"type": "node",
"name": "vscode-jest-tests",
"request": "launch",
"console": "integratedTerminal",
"internalConsoleOptions": "neverOpen",
"disableOptimisticBPs": true,
"cwd": "${workspaceFolder}",
"runtimeExecutable": "npm",
"args": ["test", "--", "--runInBand", "--watchAll=false"]
},
{
// https://jestjs.io/docs/troubleshooting
// node --inspect-brk --experimental-vm-modules node_modules/jest/bin/jest.js --verbose --runInBand
// https://miniflare.dev/developing/debugger#using-node
// node --experimental-vm-modules --inspect ./node_modules/miniflare/dist/src/cli.js dist/index.mjs --watch --debug
"type": "node",
"request": "attach",
"name": "Attach",
"port": 9229
}
]
}
9 changes: 9 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"jest.jestCommandLine": "npm test --",
"jest.autoRun": {
// https://github.com/jest-community/vscode-jest/blob/master/README.md#autorun
// "watch": true, // comment to disable refreshing on source change
"onSave": "test-file", // always run on test file changed
"onStartup": [] // ["all-tests"],
}
}
9 changes: 9 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
# Miniflare Example Project

> And is it possible to generate these tags for example, from an api response? We would like to use dinamic og title and images, and it is not clear how to implement it.

See:

- https://developers.cloudflare.com/workers/runtime-apis/html-rewriter/#element-handlers
- https://developers.cloudflare.com/workers/examples/rewrite-links/

---

This is an example [Cloudflare Workers](https://workers.cloudflare.com/) project that uses [Miniflare](https://github.com/cloudflare/miniflare) for local development, [TypeScript](https://www.typescriptlang.org/), [esbuild](https://github.com/evanw/esbuild) for bundling, and [Jest](https://jestjs.io/) for testing, with [Miniflare's custom Jest environment](https://v2.miniflare.dev/jest.html).

```shell
Expand Down
Loading