create-acrylblends 0.4.1 → 1.0.0-rc.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +4 -2
- package/dist/index.d.ts +10 -1
- package/dist/index.js +37 -16
- package/dist/index.js.map +1 -1
- package/docs/framework/README.md +5 -3
- package/docs/framework/agents/index.md +1 -1
- package/docs/framework/api/acryl.md +3 -3
- package/docs/framework/api/summary.md +1 -1
- package/docs/framework/concepts/web-standard.md +4 -14
- package/docs/framework/cordis/acryl-in-a-cordis-app.md +13 -8
- package/docs/framework/cordis/migration-from-0-4.md +1 -1
- package/docs/framework/cordis/migration-to-1-0.md +45 -0
- package/docs/framework/cordis/node-server.md +2 -2
- package/docs/framework/getting-started/basic.md +15 -10
- package/docs/framework/getting-started/desktop.md +1 -1
- package/docs/framework/getting-started/other-runtimes.md +10 -14
- package/docs/framework/guides/create-acrylblends.md +4 -2
- package/docs/framework/guides/data.md +1 -1
- package/docs/framework/guides/faq.md +1 -1
- package/docs/framework/guides/production.md +43 -0
- package/docs/framework/helpers/conninfo.md +1 -36
- package/docs/framework/helpers/websocket.md +4 -11
- package/docs/framework/middleware/builtin/ip-restriction.md +1 -1
- package/docs/framework/middleware/builtin/loopback-only.md +1 -1
- package/package.json +2 -2
- package/docs/framework/getting-started/aws-lambda.md +0 -115
- package/docs/framework/getting-started/cloudflare-pages.md +0 -53
- package/docs/framework/getting-started/cloudflare-workers.md +0 -67
- package/docs/framework/getting-started/lambda-edge.md +0 -41
- package/docs/framework/getting-started/netlify.md +0 -25
- package/docs/framework/getting-started/service-worker.md +0 -33
- package/docs/framework/getting-started/vercel.md +0 -28
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
# Service Worker
|
|
2
|
-
|
|
3
|
-
An Acryl app can answer `fetch` events in a Service Worker, and in any environment that uses the Service Worker syntax, such as a Cloudflare Worker written without ES modules. `fire(app)` from `acrylblends/service-worker` registers the app on the `fetch` event, and `handle(app)` returns the listener, if you want to register it yourself.
|
|
4
|
-
|
|
5
|
-
> **Status.** The adapter is the upstream adapter ported with its test suite, and the framework's release check calls it with a fetch event. It has not been run inside a browser's Service Worker by the ACRYL team.
|
|
6
|
-
|
|
7
|
-
```ts
|
|
8
|
-
import { Acryl } from 'acrylblends'
|
|
9
|
-
import { fire } from 'acrylblends/service-worker'
|
|
10
|
-
|
|
11
|
-
const app = new Acryl()
|
|
12
|
-
|
|
13
|
-
app.get('/', (c) => c.text('Hello from a Service Worker'))
|
|
14
|
-
|
|
15
|
-
fire(app)
|
|
16
|
-
```
|
|
17
|
-
|
|
18
|
-
A request the app does not answer (`404`) can be passed on to the network by giving `fetch` as an option, so a Service Worker can serve some routes and leave the others to the origin:
|
|
19
|
-
|
|
20
|
-
```ts lib=webworker
|
|
21
|
-
import { Acryl } from 'acrylblends'
|
|
22
|
-
import { handle } from 'acrylblends/service-worker'
|
|
23
|
-
|
|
24
|
-
declare const self: ServiceWorkerGlobalScope
|
|
25
|
-
|
|
26
|
-
const app = new Acryl()
|
|
27
|
-
|
|
28
|
-
app.get('/offline', (c) => c.text('Served by the Service Worker'))
|
|
29
|
-
|
|
30
|
-
self.addEventListener('fetch', handle(app, { fetch: globalThis.fetch }))
|
|
31
|
-
```
|
|
32
|
-
|
|
33
|
-
The example is type-checked with the TypeScript `WebWorker` library: declare `self` as a `ServiceWorkerGlobalScope` as above. `app.fire()` (a method of the app) is deprecated in favour of `fire()` from this module.
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
# Vercel
|
|
2
|
-
|
|
3
|
-
Vercel runs a function that takes a `Request` and returns a `Response`, which is what `app.fetch` is. `handle(app)` from `acrylblends/vercel` is that function.
|
|
4
|
-
|
|
5
|
-
> **Status.** The adapter is the upstream adapter ported with its test suite, and the framework's release check calls it with a `Request`. It has not been deployed to Vercel by the ACRYL team.
|
|
6
|
-
|
|
7
|
-
## A function
|
|
8
|
-
|
|
9
|
-
Create `api/index.ts`:
|
|
10
|
-
|
|
11
|
-
```ts
|
|
12
|
-
import { Acryl } from 'acrylblends'
|
|
13
|
-
import { handle } from 'acrylblends/vercel'
|
|
14
|
-
|
|
15
|
-
const app = new Acryl().basePath('/api')
|
|
16
|
-
|
|
17
|
-
app.get('/', (c) => c.text('Hello from Vercel'))
|
|
18
|
-
app.get('/hello', (c) => c.json({ hello: 'world' }))
|
|
19
|
-
|
|
20
|
-
export const GET = handle(app)
|
|
21
|
-
export const POST = handle(app)
|
|
22
|
-
```
|
|
23
|
-
|
|
24
|
-
Export one handler per HTTP method the app answers. Run it locally with `vercel dev`, and publish with `vercel deploy`.
|
|
25
|
-
|
|
26
|
-
## The client's address
|
|
27
|
-
|
|
28
|
-
The client's address comes from `getConnInfo` of `acrylblends/vercel`, which reads the `x-real-ip` header Vercel sets; see the [ConnInfo helper](../helpers/conninfo.md).
|