@zarfjs/adapter-cf-worker
v0.0.1
Published
Cloudflare Worker Friends of Zarf
Downloads
1
Maintainers
Readme
@zarfjs/adapter-cf-worker
Cloudflare worker adapter for Zarf. Provide a Zarf
app, and let this adapter adapt the incoming requests and outgoing responses into a format Cloudflare understands.
Usage
Basic
import { Zarf } from '@zarfjs/zarf'
import { createFetchAdapter } from '@zarfjs/adapter-cf-worker'
const app = new Zarf()
app.get("/hello/:user", (ctx, params) => {
return ctx.json({
user: params.user
})
})
export default {
fetch: createFetchAdapter(app)
};
Static
import { Zarf } from '@zarfjs/zarf'
import { createStaticFetchAdapter } from '@zarfjs/adapter-cf-worker/static'
const app = new Zarf()
app.get("/hello/:user", (ctx, params) => {
return ctx.json({
user: params.user
})
})
export default {
fetch: createStaticFetchAdapter(app, {
cors: true, // wanna enable CORS for all assets to all?
})
};
For detailed example refer example
Author
Aftab Alam https://github.com/one-aalam
License
Distributed under the MIT License. See LICENSE for more information.