feat(api): redefine openapi for user
Some checks failed
Build and Push Docker Image / build (push) Failing after 39s
Some checks failed
Build and Push Docker Image / build (push) Failing after 39s
This commit is contained in:
parent
1276ca6938
commit
d7c1b0525a
@ -1,4 +1,4 @@
|
|||||||
import { db, user as userDb } from '@boring.tools/database'
|
import { db, user } from '@boring.tools/database'
|
||||||
import { UserOutput, UserWebhookInput } from '@boring.tools/schema'
|
import { UserOutput, UserWebhookInput } from '@boring.tools/schema'
|
||||||
import { createRoute, type z } from '@hono/zod-openapi'
|
import { createRoute, type z } from '@hono/zod-openapi'
|
||||||
import { HTTPException } from 'hono/http-exception'
|
import { HTTPException } from 'hono/http-exception'
|
||||||
@ -41,12 +41,12 @@ const userCreate = async ({
|
|||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
await db
|
await db
|
||||||
.insert(userDb)
|
.insert(user)
|
||||||
.values({
|
.values({
|
||||||
...data,
|
...data,
|
||||||
})
|
})
|
||||||
.onConflictDoUpdate({
|
.onConflictDoUpdate({
|
||||||
target: userDb.id,
|
target: user.id,
|
||||||
set: data,
|
set: data,
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@ -1,11 +1,9 @@
|
|||||||
import { z } from '@hono/zod-openapi'
|
import { z } from '@hono/zod-openapi'
|
||||||
|
|
||||||
export const UserOutput = z
|
export const UserOutput = z.object({
|
||||||
.object({
|
id: z.string().openapi({
|
||||||
id: z.string().openapi({
|
example: 'user_2metCkqOhUhHN1jEhLyh8wMODu7',
|
||||||
example: 'user_2metCkqOhUhHN1jEhLyh8wMODu7',
|
}),
|
||||||
}),
|
name: z.string(),
|
||||||
name: z.string(),
|
email: z.string().email(),
|
||||||
email: z.string().email(),
|
})
|
||||||
})
|
|
||||||
.openapi('User')
|
|
||||||
|
@ -1,20 +1,30 @@
|
|||||||
import { z } from '@hono/zod-openapi'
|
import { z } from '@hono/zod-openapi'
|
||||||
|
|
||||||
export const UserWebhookInput = z.object({
|
export const UserWebhookInput = z
|
||||||
data: z.object({
|
.object({
|
||||||
id: z.string(),
|
data: z.object({
|
||||||
first_name: z.string(),
|
id: z.string().openapi({
|
||||||
last_name: z.string(),
|
example: 'user_2metCkqOhUhHN1jEhLyh8wMODu7',
|
||||||
email_addresses: z.array(
|
|
||||||
z.object({
|
|
||||||
email_address: z.string(),
|
|
||||||
id: z.string(),
|
|
||||||
verification: z.object({
|
|
||||||
status: z.string(),
|
|
||||||
}),
|
|
||||||
}),
|
}),
|
||||||
),
|
first_name: z.string().openapi({
|
||||||
image_url: z.string(),
|
example: 'Jane',
|
||||||
}),
|
}),
|
||||||
type: z.string(),
|
last_name: z.string().openapi({
|
||||||
})
|
example: 'Doe',
|
||||||
|
}),
|
||||||
|
email_addresses: z.array(
|
||||||
|
z.object({
|
||||||
|
email_address: z.string().openapi({
|
||||||
|
example: 'jane@doe.com',
|
||||||
|
}),
|
||||||
|
}),
|
||||||
|
),
|
||||||
|
image_url: z.string().openapi({
|
||||||
|
example: 'https://example.com/image.png',
|
||||||
|
}),
|
||||||
|
}),
|
||||||
|
type: z.string().openapi({
|
||||||
|
examples: ['user.created', 'user.updated'],
|
||||||
|
}),
|
||||||
|
})
|
||||||
|
.openapi('User')
|
||||||
|
Loading…
Reference in New Issue
Block a user