Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create a publishable mizu hono middleware client library #18

Merged
merged 62 commits into from
Jun 6, 2024

Conversation

brettimus
Copy link
Contributor

@brettimus brettimus commented Jun 5, 2024

This PR makes changes to the client library (hono middleware) so that we can publish it and consume it:

npm i @mizu-dev/hono

The name is temporary. I set up the @mizu-dev org under my npm account but can give anyone else access as well.

Changes

Sensible defaults

To streamline the DX of installing and using mizu, the createHonoMiddleware function falls back to a default createConfig function, which uses the configuration specified in the README.

Moreover, the MIZU_ENDPOINT environment variable falls back to the default url of the local mizu service (http://localhost:8788/v0/logs).

This makes the quickstart much quicker, so that a consumer doesn't need to modify their .dev.vars, and they can simply write the following in their application code:

import { createHonoMiddleware } from '@mizu-dev/hono';

const app = new Hono()

app.use(createHonoMiddleware())

// ...

Modified build

  • Added rimraf to clean the dist folder before building
  • Updated tsconfig.json to use similar module/target as swc
  • build:types script will compile typescript
  • build:swc will finish the build
  • build first build types, then runs swc

The build contains .d.ts files now

Misc

Update the package.json and README
The package.json now contains fields necessary for publishing the client library as a publish package.

Add .npmignore in client-library/
We need to ignore lots of files in our published package, like the src directory, as well as ts, swc, and linting configs.

Move some deps to devDependencies
Biome, SWC, and typescript are now all dev dependencies.

brettimus added 30 commits June 3, 2024 17:58
- changed types to "node" instead of cloudflare workers
- changed "module" to NodeNext, which required renaming a bunch of imports
@brettimus brettimus force-pushed the publishable-client-library branch from be139db to cf84a21 Compare June 5, 2024 19:19
@brettimus brettimus marked this pull request as ready for review June 6, 2024 09:52
Copy link
Member

@flenter flenter left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎉 Love the default createConfig option.

client-library/README.md Outdated Show resolved Hide resolved
Copy link
Member

@keturiosakys keturiosakys left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎉

@brettimus brettimus merged commit 638271c into main Jun 6, 2024
2 checks passed
@brettimus brettimus deleted the publishable-client-library branch June 6, 2024 10:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants