mirror of
https://github.com/HeyPuter/puter.git
synced 2026-07-08 16:21:40 +00:00
Add docs fixes for deployment and workers pages (#3223)
* Add docs fixes for deployment and workers pages * Potential fix for pull request finding Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com> * handle router edge case * explicit info about wildcard requiring name --------- Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
This commit is contained in:
committed by
GitHub
parent
15134c99bf
commit
f127b2509d
@@ -5,7 +5,7 @@ description: Run and manage serverless JavaScript funcitons in the cloud.
|
||||
|
||||
Serverless Workers are serverless functions that run JavaScript code in the cloud.
|
||||
|
||||
Workers run server-side, which makes them a good fit for centralized application data and backend logic. See [Integration with Puter.js](/Workers/router/#integration-with-puterjs) for how worker code accesses Puter resources.
|
||||
Workers run server-side, which makes them a good fit for centralized application data and backend logic. See [Integration with Puter.js](/Workers/router/#integration-with-puter-js) for how worker code accesses Puter resources.
|
||||
|
||||
## Router
|
||||
|
||||
|
||||
@@ -6,13 +6,9 @@ platforms: [websites, apps, nodejs, workers]
|
||||
|
||||
Creates and deploys a new worker from a JavaScript file containing [router](../router) code.
|
||||
|
||||
<div class="info">To create a worker, you'll need a <a href="https://puter.com/">Puter account</a> with a verified email address.</div>
|
||||
|
||||
<div class="info">After a worker is created or updated, full propagation may take between 5 to 30 seconds to fully take effect across all edge servers. </div>
|
||||
|
||||
<div class="info">A worker is tied to its <strong>name</strong> — you create it <strong>once</strong> and keep that name. To deploy changes, don't call <code>create()</code> again with a new name; instead overwrite the worker's source file (see <a href="#updating-a-worker">Updating a worker</a> below). Recreating under a different name leaves the old worker live at its old URL while your callers end up pointing at an orphaned one.</div>
|
||||
|
||||
A worker is tied to its **name**: you create it **once** and keep that name. To deploy changes, don't call `create()` again with a new name — instead overwrite the worker's source file (see [Updating a worker](#updating-a-worker) below). Recreating under a different name leaves the old worker live at its old URL while your callers end up pointing at an orphaned one.
|
||||
|
||||
<div class="info">To create a worker, you'll need a <a href="https://puter.com/">Puter account</a> with a verified email address. After a worker is created or updated, full propagation may take between 5 and 30 seconds to take effect across all edge servers.</div>
|
||||
|
||||
## Syntax
|
||||
|
||||
|
||||
@@ -82,6 +82,8 @@ router.get("/files/*path", async ({ params }) => {
|
||||
});
|
||||
```
|
||||
|
||||
A wildcard **must be named** — write `*path` (or any name you like), not a bare `*`. A pattern like `/files/*` won't act as a wildcard: with no name after it, the `*` is treated as a literal character, so the route only matches the exact path `/files/*`. The name is what gives the router a key to expose the captured value on `params`.
|
||||
|
||||
A common use is a catch-all route for unmatched paths — define it last so it only runs when nothing else matched (see the [404 Handler](#examples) example below).
|
||||
|
||||
## CORS
|
||||
|
||||
@@ -93,9 +93,28 @@ $(document).on('click', 'a:not(.skip-insta-load):not([target="_blank"])', functi
|
||||
$('#toc-wrapper').html($(data).find('#toc-wrapper').html());
|
||||
|
||||
setTimeout(() => {
|
||||
$('body').animate({
|
||||
scrollTop: 0,
|
||||
}, 100);
|
||||
// If the URL has a hash, scroll to that heading instead of the
|
||||
// top of the page. The browser only does this natively on a full
|
||||
// page load, so the insta-loader has to handle it here.
|
||||
const hash = window.location.hash;
|
||||
let target = null;
|
||||
if ( hash.length > 1 ) {
|
||||
const id = hash.slice(1);
|
||||
try {
|
||||
// Pasted/hand-typed URLs may contain malformed
|
||||
// percent-encoding, which makes decodeURIComponent throw.
|
||||
target = document.getElementById(decodeURIComponent(id));
|
||||
} catch ( e ) {
|
||||
target = document.getElementById(id);
|
||||
}
|
||||
}
|
||||
if ( target ) {
|
||||
target.scrollIntoView();
|
||||
} else {
|
||||
$('body').animate({
|
||||
scrollTop: 0,
|
||||
}, 100);
|
||||
}
|
||||
}, 30);
|
||||
|
||||
//set title of page
|
||||
|
||||
@@ -11,7 +11,7 @@ Puter.js is a regular JavaScript library, so your app deploys like any other web
|
||||
|
||||
Because Puter.js runs entirely in the browser, there's no special backend to provision. Build your app as you normally would and serve the output from any static or web hosting provider, such as <a href="https://vercel.com" rel="nofollow">Vercel</a>, <a href="https://pages.cloudflare.com" rel="nofollow">Cloudflare Pages</a>, <a href="https://www.netlify.com" rel="nofollow">Netlify</a>, or <a href="https://pages.github.com" rel="nofollow">GitHub Pages</a>.
|
||||
|
||||
<div class="info">Your app should be served over HTTPS by a web server, like any of the hosting providers above.</div>
|
||||
<div class="info">Your app should be served by a web server, like any of the hosting providers above.</div>
|
||||
|
||||
No extra configuration is required. Your app keeps talking to Puter's services from the browser, wherever it's hosted.
|
||||
|
||||
|
||||
Reference in New Issue
Block a user