kopia lustrzana https://github.com/transitive-bullshit/chatgpt-api
pull/715/head
rodzic
69b86f4b48
commit
d422e91d5b
|
@ -0,0 +1,33 @@
|
||||||
|
import { createRoute, type OpenAPIHono, z } from '@hono/zod-openapi'
|
||||||
|
|
||||||
|
const route = createRoute({
|
||||||
|
description: 'Custom cache control tool',
|
||||||
|
operationId: 'customCacheControlTool',
|
||||||
|
method: 'post',
|
||||||
|
path: '/custom-cache-control-tool',
|
||||||
|
request: {
|
||||||
|
body: {
|
||||||
|
content: {
|
||||||
|
'application/json': {
|
||||||
|
schema: z.object({}).passthrough()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
responses: {
|
||||||
|
200: {
|
||||||
|
description: 'Echoed request body',
|
||||||
|
content: {
|
||||||
|
'application/json': {
|
||||||
|
schema: z.object({}).passthrough()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
export function registerCustomCacheControlTool(app: OpenAPIHono) {
|
||||||
|
return app.openapi(route, async (c) => {
|
||||||
|
return c.json(c.req.valid('json'))
|
||||||
|
})
|
||||||
|
}
|
|
@ -0,0 +1,33 @@
|
||||||
|
import { createRoute, type OpenAPIHono, z } from '@hono/zod-openapi'
|
||||||
|
|
||||||
|
const route = createRoute({
|
||||||
|
description: 'Custom rate limit tool',
|
||||||
|
operationId: 'customRateLimitTool',
|
||||||
|
method: 'post',
|
||||||
|
path: '/custom-rate-limit-tool',
|
||||||
|
request: {
|
||||||
|
body: {
|
||||||
|
content: {
|
||||||
|
'application/json': {
|
||||||
|
schema: z.object({}).passthrough()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
responses: {
|
||||||
|
200: {
|
||||||
|
description: 'Echoed request body',
|
||||||
|
content: {
|
||||||
|
'application/json': {
|
||||||
|
schema: z.object({}).passthrough()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
export function registerCustomRateLimitTool(app: OpenAPIHono) {
|
||||||
|
return app.openapi(route, async (c) => {
|
||||||
|
return c.json(c.req.valid('json'))
|
||||||
|
})
|
||||||
|
}
|
|
@ -0,0 +1,26 @@
|
||||||
|
import { createRoute, type OpenAPIHono, z } from '@hono/zod-openapi'
|
||||||
|
|
||||||
|
const route = createRoute({
|
||||||
|
description: 'Disabled for free plan tool',
|
||||||
|
operationId: 'disabledForFreePlanTool',
|
||||||
|
method: 'get',
|
||||||
|
path: '/disabled-for-free-plan-tool',
|
||||||
|
responses: {
|
||||||
|
200: {
|
||||||
|
description: 'OK',
|
||||||
|
content: {
|
||||||
|
'application/json': {
|
||||||
|
schema: z.object({
|
||||||
|
status: z.string()
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
export function registerDisabledForFreePlanTool(app: OpenAPIHono) {
|
||||||
|
return app.openapi(route, async (c) => {
|
||||||
|
return c.json({ status: 'ok' })
|
||||||
|
})
|
||||||
|
}
|
|
@ -0,0 +1,33 @@
|
||||||
|
import { createRoute, type OpenAPIHono, z } from '@hono/zod-openapi'
|
||||||
|
|
||||||
|
const route = createRoute({
|
||||||
|
description: 'Disabled rate limit tool',
|
||||||
|
operationId: 'disabledRateLimitTool',
|
||||||
|
method: 'post',
|
||||||
|
path: '/disabled-rate-limit-tool',
|
||||||
|
request: {
|
||||||
|
body: {
|
||||||
|
content: {
|
||||||
|
'application/json': {
|
||||||
|
schema: z.object({}).passthrough()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
responses: {
|
||||||
|
200: {
|
||||||
|
description: 'Echoed request body',
|
||||||
|
content: {
|
||||||
|
'application/json': {
|
||||||
|
schema: z.object({}).passthrough()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
export function registerDisabledRateLimitTool(app: OpenAPIHono) {
|
||||||
|
return app.openapi(route, async (c) => {
|
||||||
|
return c.json(c.req.valid('json'))
|
||||||
|
})
|
||||||
|
}
|
|
@ -0,0 +1,26 @@
|
||||||
|
import { createRoute, type OpenAPIHono, z } from '@hono/zod-openapi'
|
||||||
|
|
||||||
|
const route = createRoute({
|
||||||
|
description: 'Disabled tool',
|
||||||
|
operationId: 'disabledTool',
|
||||||
|
method: 'get',
|
||||||
|
path: '/disabled-tool',
|
||||||
|
responses: {
|
||||||
|
200: {
|
||||||
|
description: 'OK',
|
||||||
|
content: {
|
||||||
|
'application/json': {
|
||||||
|
schema: z.object({
|
||||||
|
status: z.string()
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
export function registerDisabledTool(app: OpenAPIHono) {
|
||||||
|
return app.openapi(route, async (c) => {
|
||||||
|
return c.json({ status: 'ok' })
|
||||||
|
})
|
||||||
|
}
|
|
@ -0,0 +1,33 @@
|
||||||
|
import { createRoute, type OpenAPIHono, z } from '@hono/zod-openapi'
|
||||||
|
|
||||||
|
const route = createRoute({
|
||||||
|
description: 'Echoes the request body',
|
||||||
|
operationId: 'echo',
|
||||||
|
method: 'post',
|
||||||
|
path: '/echo',
|
||||||
|
request: {
|
||||||
|
body: {
|
||||||
|
content: {
|
||||||
|
'application/json': {
|
||||||
|
schema: z.object({}).passthrough()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
responses: {
|
||||||
|
200: {
|
||||||
|
description: 'Echoed request body',
|
||||||
|
content: {
|
||||||
|
'application/json': {
|
||||||
|
schema: z.object({}).passthrough()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
export function registerEcho(app: OpenAPIHono) {
|
||||||
|
return app.openapi(route, async (c) => {
|
||||||
|
return c.json(c.req.valid('json'))
|
||||||
|
})
|
||||||
|
}
|
|
@ -0,0 +1,33 @@
|
||||||
|
import { createRoute, type OpenAPIHono, z } from '@hono/zod-openapi'
|
||||||
|
|
||||||
|
const route = createRoute({
|
||||||
|
description: 'No store cache control tool',
|
||||||
|
operationId: 'noStoreCacheControlTool',
|
||||||
|
method: 'post',
|
||||||
|
path: '/no-store-cache-control-tool',
|
||||||
|
request: {
|
||||||
|
body: {
|
||||||
|
content: {
|
||||||
|
'application/json': {
|
||||||
|
schema: z.object({}).passthrough()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
responses: {
|
||||||
|
200: {
|
||||||
|
description: 'Echoed request body',
|
||||||
|
content: {
|
||||||
|
'application/json': {
|
||||||
|
schema: z.object({}).passthrough()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
export function registerNoStoreCacheControlTool(app: OpenAPIHono) {
|
||||||
|
return app.openapi(route, async (c) => {
|
||||||
|
return c.json(c.req.valid('json'))
|
||||||
|
})
|
||||||
|
}
|
|
@ -0,0 +1,33 @@
|
||||||
|
import { createRoute, type OpenAPIHono, z } from '@hono/zod-openapi'
|
||||||
|
|
||||||
|
const route = createRoute({
|
||||||
|
description: 'Pure tool',
|
||||||
|
operationId: 'pure',
|
||||||
|
method: 'post',
|
||||||
|
path: '/pure',
|
||||||
|
request: {
|
||||||
|
body: {
|
||||||
|
content: {
|
||||||
|
'application/json': {
|
||||||
|
schema: z.object({}).passthrough()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
responses: {
|
||||||
|
200: {
|
||||||
|
description: 'Echoed request body',
|
||||||
|
content: {
|
||||||
|
'application/json': {
|
||||||
|
schema: z.object({}).passthrough()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
export function registerPure(app: OpenAPIHono) {
|
||||||
|
return app.openapi(route, async (c) => {
|
||||||
|
return c.json(c.req.valid('json'))
|
||||||
|
})
|
||||||
|
}
|
|
@ -3,8 +3,16 @@ import { OpenAPIHono } from '@hono/zod-openapi'
|
||||||
import { logger as honoLogger } from 'hono/logger'
|
import { logger as honoLogger } from 'hono/logger'
|
||||||
|
|
||||||
import { initExitHooks } from './exit-hooks'
|
import { initExitHooks } from './exit-hooks'
|
||||||
|
import { registerCustomCacheControlTool } from './routes/custom-cache-control-tool'
|
||||||
|
import { registerCustomRateLimitTool } from './routes/custom-rate-limit-tool'
|
||||||
|
import { registerDisabledForFreePlanTool } from './routes/disabled-for-free-plan-tool'
|
||||||
|
import { registerDisabledRateLimitTool } from './routes/disabled-rate-limit-tool'
|
||||||
|
import { registerDisabledTool } from './routes/disabled-tool'
|
||||||
|
import { registerEcho } from './routes/echo'
|
||||||
import { registerGetUser } from './routes/get-user'
|
import { registerGetUser } from './routes/get-user'
|
||||||
import { registerHealthCheck } from './routes/health-check'
|
import { registerHealthCheck } from './routes/health-check'
|
||||||
|
import { registerNoStoreCacheControlTool } from './routes/no-store-cache-control-tool'
|
||||||
|
import { registerPure } from './routes/pure'
|
||||||
|
|
||||||
export const app = new OpenAPIHono()
|
export const app = new OpenAPIHono()
|
||||||
|
|
||||||
|
@ -12,6 +20,14 @@ app.use(honoLogger())
|
||||||
|
|
||||||
registerHealthCheck(app)
|
registerHealthCheck(app)
|
||||||
registerGetUser(app)
|
registerGetUser(app)
|
||||||
|
registerDisabledTool(app)
|
||||||
|
registerDisabledForFreePlanTool(app)
|
||||||
|
registerEcho(app)
|
||||||
|
registerPure(app)
|
||||||
|
registerCustomCacheControlTool(app)
|
||||||
|
registerNoStoreCacheControlTool(app)
|
||||||
|
registerCustomRateLimitTool(app)
|
||||||
|
registerDisabledRateLimitTool(app)
|
||||||
|
|
||||||
app.doc31('/docs', {
|
app.doc31('/docs', {
|
||||||
openapi: '3.1.0',
|
openapi: '3.1.0',
|
||||||
|
|
Ładowanie…
Reference in New Issue