mirror of
https://github.com/HeyPuter/puter.git
synced 2026-07-09 00:31:53 +00:00
More workers docs improvement (#3218)
* More workers docs improvement * Add mention of workers alongside mention of user scope
This commit is contained in:
committed by
GitHub
parent
c52eb1b903
commit
98a21c4ac0
@@ -9,6 +9,8 @@ It comes with a comprehensive but familiar file system operations including writ
|
||||
|
||||
With Puter.js, you don't need to worry about setting up storage infrastructure such as configuring buckets, managing CDNs, or ensuring availability, since everything is handled for you. Additionally, with the [User-Pays Model](/user-pays-model/), you don't have to worry about storage or bandwidth costs, as users of your application cover their own usage.
|
||||
|
||||
<div class="info"><strong>Need to share data across users?</strong> Each user's files live in their own account, so one user can't read another's data. To keep centralized files that every user reads from and writes to, use a <a href="/Workers/">Serverless Worker</a> — its code can act on the worker owner's resources, giving all users one shared backend.</div>
|
||||
|
||||
## Features
|
||||
|
||||
<div style="overflow:hidden; margin-bottom: 30px;">
|
||||
|
||||
@@ -9,6 +9,8 @@ It supports various operations such as set, get, delete, list keys, increment an
|
||||
|
||||
Puter.js handles all the infrastructure for you, so you don't need to set up servers, handle scaling, or manage backups. And thanks to the [User-Pays Model](/user-pays-model/), you don't have to worry about storage, read, or write costs, as users of your application cover their own usage.
|
||||
|
||||
<div class="info"><strong>Need to share data across users?</strong> Each user's key-value store lives in their own account, so one user can't read another's data. To keep a single, centralized store that every user reads from and writes to, use a <a href="/Workers/">Serverless Worker</a> — its code can act on the worker owner's resources, giving all users one shared backend.</div>
|
||||
|
||||
## Features
|
||||
|
||||
<div style="overflow:hidden; margin-bottom: 30px;">
|
||||
|
||||
@@ -5,9 +5,11 @@ 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.
|
||||
|
||||
## Router
|
||||
|
||||
Workers use a router-based system to handle HTTP requests and can integrate with Puter's cloud services like file storage, key-value databases, and AI APIs. Workers are perfect for building backend services, REST APIs, webhooks, and data processing pipelines.
|
||||
Workers use a router-based system to handle HTTP requests and can integrate with Puter's cloud services like file storage, key-value databases, and AI APIs. Workers are perfect for building backend services, REST APIs, webhooks, shared data stores, and data processing pipelines.
|
||||
|
||||
### Examples
|
||||
|
||||
|
||||
@@ -99,7 +99,7 @@ router.options("/*path", async () => {
|
||||
headers: {
|
||||
"Access-Control-Allow-Origin": "*",
|
||||
"Access-Control-Allow-Methods": "GET, POST, PUT, DELETE, OPTIONS",
|
||||
"Access-Control-Allow-Headers": "Content-Type, Authorization",
|
||||
"Access-Control-Allow-Headers": "Content-Type, Authorization, puter-auth",
|
||||
},
|
||||
});
|
||||
});
|
||||
@@ -107,6 +107,8 @@ router.options("/*path", async () => {
|
||||
|
||||
This answers the preflight for any path with the CORS headers the browser expects, so your other routes work cross-origin.
|
||||
|
||||
<div class="info">The <code>puter-auth</code> header is important: when you call your worker with <a href="/Workers/exec/"><code>puter.workers.exec()</code></a>, it attaches the user's Puter token in a <code>puter-auth</code> header so the worker can act on the calling user's behalf (this is what populates <code>user.puter</code>). Because that's a custom header, the browser runs a preflight first — so <code>puter-auth</code> must be listed in <code>Access-Control-Allow-Headers</code>, otherwise the preflight fails and the request never reaches your worker.</div>
|
||||
|
||||
If you need different CORS rules per endpoint — for example, restricting the allowed methods or headers on a specific route — define an `OPTIONS` handler on that individual path instead of using the wildcard.
|
||||
|
||||
## Examples
|
||||
|
||||
@@ -28,6 +28,8 @@ Once the user has been authenticated, your app will get a few things by default:
|
||||
|
||||
<div class="info"><strong>Apps are sandboxed by default!</strong> Apps are not able to access any files, directories, or data outside of their own directory and key-value store within a user's account. This is to ensure that apps can't access any data or resources that they shouldn't have access to.</div>
|
||||
|
||||
<div class="info"><strong>Need to share data across users?</strong> Because each user's storage lives in their own account, one user can't see another's data. To keep a single, centralized store that every user reads from and writes to, use a <a href="/Workers/">Serverless Worker</a> — its code can act on the worker owner's resources, giving all users one shared backend.</div>
|
||||
|
||||
Your app will also be able to use the following services by default:
|
||||
|
||||
- **AI**: Your app will be able to use the AI services provided by Puter.com. This includes chat, txt2img, img2txt, and more.
|
||||
|
||||
Reference in New Issue
Block a user