Skip to content

Commit

Permalink
♻️ bring our types back idk
Browse files Browse the repository at this point in the history
  • Loading branch information
acidjazz committed Jan 7, 2025
1 parent 121a076 commit 3feeedb
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 16 deletions.
4 changes: 3 additions & 1 deletion src/module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,10 @@ export default defineNuxtModule<ModuleOptions>({
configKey: 'apiUtils',
},
defaults: {},
setup(_options, _nuxt) {
setup(_options, nuxt) {
const resolver = createResolver(import.meta.url)
nuxt.options.alias['#api-utils'] = resolver.resolve('./runtime/types/index')

addServerImportsDir(resolver.resolve('./runtime/server/utils'))
},
})
6 changes: 1 addition & 5 deletions src/runtime/server/utils/binder.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
import type { H3Event, Router } from 'h3'

export interface BinderConfig {
prismaFactory: (event: H3Event) => unknown
models: Record<string, unknown>
}
import type { BinderConfig } from '#api-utils'

export function modelBinder(config: BinderConfig, router: Router) {
async function lookupModels<T extends Record<string, unknown>>(modelNames: (keyof T)[], event: H3Event): Promise<T> {
Expand Down
11 changes: 1 addition & 10 deletions src/runtime/server/utils/metapi.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,4 @@
type MetapiDetail = string | import('zod').ZodIssue[]

interface MetapiResponse<T = unknown> {
meta: {
benchmark: string
success: boolean
detail?: MetapiDetail
}
data: T
}
import type { MetapiResponse, MetapiDetail } from '#api-utils'

let start: number | undefined

Expand Down
18 changes: 18 additions & 0 deletions src/runtime/types/index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import type { H3Event } from 'h3'
import type { ZodIssue } from 'zod'

export type BinderConfig = {
prismaFactory: (event: H3Event) => unknown
models: Record<string, unknown>
}

export type MetapiDetail = string | ZodIssue[]

export interface MetapiResponse<T = unknown> {
meta: {
benchmark: string
success: boolean
detail?: MetapiDetail
}
data: T
}

0 comments on commit 3feeedb

Please sign in to comment.