Skip to content

Commit

Permalink
chore: update README
Browse files Browse the repository at this point in the history
  • Loading branch information
mewhhaha committed Jun 22, 2024
1 parent a6e4400 commit 726812f
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion packages/little-worker/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,16 @@ Routes can be generated by using the `little-worker routes [--target app/routes]

> The dots (`.`) will be transformed into slashes (`/`) and the dollar signs (`$`) will be changed into colons (`:`). This transformation will make it match the format in the router.
> Ending with a dollar sign (`$`) will be interpreted as a splat route, and converted to a asterisk (`*`)
> Also supports flat folders containing a `route.ts` or a `route.tsx` file. This can be helpful to co-locate code to a specific route in separate files.
Here are some examples of files and their generated equivalences in the router:

- `get.users.ts` => `.get("/users", ...)`
- `get.users.$userId.ts` => `.get("/users/:userId", ...)`
- `get.users.$userId.bananas.ts` => `.get("/users/:userId/bananas", ...)`
- `get.$.ts` => `.get("/*", ...)`
- `post.users.ts` => `.post("/users", ...)`
- `all.users.ts` => `.all("/users", ...)`

Expand All @@ -49,7 +54,7 @@ These will be automatically sorted when the router is generated to make sure tha

In each of the files you created it is expected that you export a route definition as the default export. You can import the function `route` from `@mewhhaha/little-worker` (or `@mewhhaha/little-router`) that you can use to properly type your export.

> Use the eslint plugin from `@mewhhaha/little-worker/eslint-plugin` to ensure that the route is always correct.
> Use the [eslint plugin](#ensure-correctness-with-lint) from `@mewhhaha/little-worker/eslint-plugin` to ensure that the route is always correct.
```tsx
// In file get.users.$userId.ts
Expand Down

0 comments on commit 726812f

Please sign in to comment.