Skip to content

Commit

Permalink
chore: releases
Browse files Browse the repository at this point in the history
  • Loading branch information
Julien-R44 committed Sep 23, 2024
1 parent bb90735 commit 66fc1ae
Show file tree
Hide file tree
Showing 13 changed files with 97 additions and 60 deletions.
24 changes: 0 additions & 24 deletions .changeset/thirty-coats-beg.md

This file was deleted.

67 changes: 45 additions & 22 deletions packages/core/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,30 @@
# @tuyau/core

## 0.2.0

### Minor Changes

- df82585: See https://github.com/Julien-Sponsors/tuyau/issues/4

Basically we allow the use of a validator directly in the controller file. For example:

```ts
export const myValidator = vine.compile(
vine.object({
id: vine.number(),
}),
)

export default class MyController {
public async handle({ request }: HttpContext) {
const payload = await request.validateUsing(myValidator)
// ...
}
}
```

It didn't work before. Now it's possible

## 0.1.4

### Patch Changes
Expand All @@ -26,13 +51,13 @@
```ts
/// <reference path="../../adonisrc.ts" />

import { createTuyau } from "@tuyau/client";
import type { api } from "@your-monorepo/server/.adonisjs/api";
import { createTuyau } from '@tuyau/client'
import type { api } from '@your-monorepo/server/.adonisjs/api'

export const tuyau = createTuyau({
api,
baseUrl: "http://localhost:3333",
});
baseUrl: 'http://localhost:3333',
})
```

As you can see, you first need to change the import path and the imported value. Next, you need to pass this `api` object as an argument to the `createTuyau` function.
Expand All @@ -47,35 +72,33 @@

```ts
// Backend
router
.get("/posts/:id/generate-invitation", "...")
.as("posts.generateInvitation");
router.get('/posts/:id/generate-invitation', '...').as('posts.generateInvitation')
// Client
await tuyau.$route("posts.generateInvitation", { id: 1 }).$get({
await tuyau.$route('posts.generateInvitation', { id: 1 }).$get({
query: { limit: 10, page: 1 },
});
})
```

### Generating URL from route name

If you need to generate the URL of a route using the route name, you can use the `$url` method. This method is pretty similar to [Ziggy](https://github.com/tighten/ziggy) behavior :

```ts
tuyau.$url("users.posts", { id: 1, postId: 2 }); // http://localhost:3333/users/1/posts/2
tuyau.$url("venues.events.show", [1, 2]); // http://localhost:3333/venues/1/events/2
tuyau.$url("users", { query: { page: 1, limit: 10 } }); // http://localhost:3333/users?page=1&limit=10
tuyau.$url('users.posts', { id: 1, postId: 2 }) // http://localhost:3333/users/1/posts/2
tuyau.$url('venues.events.show', [1, 2]) // http://localhost:3333/venues/1/events/2
tuyau.$url('users', { query: { page: 1, limit: 10 } }) // http://localhost:3333/users?page=1&limit=10
```

If you are used to Ziggy and prefer to have a `route` method instead of `$url`, you can define a custom method in your client file pretty easily :

```ts
export const tuyau = createTuyau({
api,
baseUrl: "http://localhost:3333",
});
baseUrl: 'http://localhost:3333',
})
window.route = tuyau.$url.bind(tuyau);
window.route = tuyau.$url.bind(tuyau)
```

Then you can use the `route` method in your frontend code :
Expand All @@ -84,9 +107,9 @@
export function MyComponent() {
return (
<div>
<a href={route("users.posts", { id: 1, postId: 2 })}>Go to post</a>
<a href={route('users.posts', { id: 1, postId: 2 })}>Go to post</a>
</div>
);
)
}
```

Expand All @@ -95,9 +118,9 @@
If you need to check if a route name exists, you can use the `$has` method. You can also use wildcards in the route name :

```ts
tuyau.$has("users"); // true
tuyau.$has("users.posts"); // true
tuyau.$has("users.*.comments"); // true
tuyau.$has("users.*"); // true
tuyau.$has("non-existent"); // false
tuyau.$has('users') // true
tuyau.$has('users.posts') // true
tuyau.$has('users.*.comments') // true
tuyau.$has('users.*') // true
tuyau.$has('non-existent') // false
```
2 changes: 1 addition & 1 deletion packages/core/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@tuyau/core",
"type": "module",
"version": "0.1.4",
"version": "0.2.0",
"description": "",
"author": "",
"license": "MIT",
Expand Down
19 changes: 12 additions & 7 deletions packages/openapi/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
# @tuyau/openapi

## 1.0.0

### Patch Changes

- Updated dependencies [df82585]
- @tuyau/core@0.2.0

## 0.1.2

### Patch Changes
Expand All @@ -16,15 +23,13 @@
```ts
router
.group(() => {
router.get('/random', [MiscController, 'index']).detail({ description: 'Get a random thing' })
router
.get("/random", [MiscController, "index"])
.detail({ description: "Get a random thing" });
router
.get("/random/:id", [MiscController, "show"])
.detail({ description: "Get a random thing by id" });
.get('/random/:id', [MiscController, 'show'])
.detail({ description: 'Get a random thing by id' })
})
.prefix("/misc")
.detail({ tags: ["misc"] });
.prefix('/misc')
.detail({ tags: ['misc'] })
```

These `details` will be merged and added to the auto-generated OpenAPI spec.
Expand Down
4 changes: 2 additions & 2 deletions packages/openapi/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@tuyau/openapi",
"type": "module",
"version": "0.2.0",
"version": "1.0.0",
"description": "",
"author": "",
"license": "MIT",
Expand Down Expand Up @@ -33,7 +33,7 @@
"prepublishOnly": "npm run build"
},
"peerDependencies": {
"@tuyau/core": "^0.1.4"
"@tuyau/core": "^0.2.0"
},
"dependencies": {
"defu": "^6.1.4",
Expand Down
8 changes: 8 additions & 0 deletions playgrounds/inertia-react/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# @tuyau/playground-inertia-react

## 0.0.1

### Patch Changes

- Updated dependencies [df82585]
- @tuyau/core@0.2.0
2 changes: 1 addition & 1 deletion playgrounds/inertia-react/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@tuyau/playground-inertia-react",
"type": "module",
"version": "0.0.0",
"version": "0.0.1",
"private": true,
"license": "UNLICENSED",
"scripts": {
Expand Down
8 changes: 8 additions & 0 deletions playgrounds/inertia-solid/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# @tuyau/playground-inertia-solid

## 0.0.1

### Patch Changes

- Updated dependencies [df82585]
- @tuyau/core@0.2.0
2 changes: 1 addition & 1 deletion playgrounds/inertia-solid/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@tuyau/playground-inertia-solid",
"type": "module",
"version": "0.0.0",
"version": "0.0.1",
"private": true,
"license": "UNLICENSED",
"scripts": {
Expand Down
8 changes: 8 additions & 0 deletions playgrounds/inertia-vue/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# @tuyau/playground-inertia-vue

## 0.0.1

### Patch Changes

- Updated dependencies [df82585]
- @tuyau/core@0.2.0
2 changes: 1 addition & 1 deletion playgrounds/inertia-vue/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@tuyau/playground-inertia-vue",
"type": "module",
"version": "0.0.0",
"version": "0.0.1",
"private": true,
"license": "UNLICENSED",
"scripts": {
Expand Down
9 changes: 9 additions & 0 deletions playgrounds/openapi/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# @tuyau/playground-openapi

## 0.0.1

### Patch Changes

- Updated dependencies [df82585]
- @tuyau/core@0.2.0
- @tuyau/openapi@1.0.0
2 changes: 1 addition & 1 deletion playgrounds/openapi/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@tuyau/playground-openapi",
"type": "module",
"version": "0.0.0",
"version": "0.0.1",
"private": true,
"license": "UNLICENSED",
"scripts": {
Expand Down

0 comments on commit 66fc1ae

Please sign in to comment.