Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/pomdtr/smallweb-preview-demo
https://github.com/pomdtr/smallweb-preview-demo
Last synced: about 2 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/pomdtr/smallweb-preview-demo
- Owner: pomdtr
- Created: 2024-07-18T12:39:51.000Z (6 months ago)
- Default Branch: main
- Last Pushed: 2024-07-18T13:15:40.000Z (6 months ago)
- Last Synced: 2024-07-19T17:43:57.238Z (6 months ago)
- Language: TypeScript
- Size: 3.91 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Preview URLs with Smallweb
All commit in this repository can be referenced by a preview URL.
Ex:
- main branch:
- 1st commit:
- PR branch:## How does it work ?
```jsonc
// ~/.config/smallweb/config.json
{
"domains": {
"preview-demo-*.smallweb.run": "~/smallweb.run/preview-demo"
}
}
``````ts
// ~/smallweb.run/preview-demo/main.tsconst repo = "pomdtr/smallweb-preview-url-demo";
export default {
async fetch(req: Request) {
const { hostname } = new URL(req.url);
const [subdomain] = hostname.split(".");
const ref = subdomain.split("-").pop();
const { default: handler } = await import(
`https://raw.githubusercontent.com/${repo}/${ref}/main.ts`
);return handler.fetch(req);
},
};
```