Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/dario-piotrowicz/cf-bindings-cli-idea-poc


https://github.com/dario-piotrowicz/cf-bindings-cli-idea-poc

Last synced: 8 days ago
JSON representation

Awesome Lists containing this project

README

        

# cf-bindings-cli-idea-poc

## To run the applications

Install dependencies with
```
pnpm i
```

then for each app in `/apps`:
```
pnpm dev
```
runs the standard dev server

to build the application using the `poc` library run:
```
pnpm poc_build
```

and to then start it using wrangler:
```
pnpm pages:preview
```

## Env Types

Note that in every application you can see a `worker-configuration.d.ts` file, such files have been
generated by running
```
pnpm wrangler types
```
in the application's directory

The command just read the toml file (the same used in dev mode by the `poc` library) and extended accordingly the `Env` interface which is used by the `poc` library to provide a valid type of the `env` object.

This means that users only need to run `wrangler types` and the `poc` library takes care of everything! 🎉 (PS: they do however need to make sure to have `@cloudflare/workers-types` installed, have it added to their `tsconfig.json` and also make sure that the framework picks up the new `d.ts` file 😢)

> [!warning]
> Note that in the toml files I always needed to provide a value for the `main` field although it doesn't make sense in our setup, that's something we might need to address in wrangler

### QUESTION
`Env` seems pretty generic and I feel that it might sometimes even overlap with other framework types, I would likely prefer something more specific like `CloudflareEnv`, what do you think? If we wanted to go with something like this I think we'd need to get the `wrangler type` command accept a new flag that allows it to use a different name for the interface, something like this:
```
wrangler types --interface-name CloudflareEnv
```