Skip to content

Commit

Permalink
fix(api): chain hono apps to fix type infer (#47)
Browse files Browse the repository at this point in the history
  • Loading branch information
duongdev committed Jun 8, 2024
1 parent b55565e commit ac88b27
Show file tree
Hide file tree
Showing 7 changed files with 395 additions and 393 deletions.
12 changes: 6 additions & 6 deletions apps/api/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@ import { hono as appV1 } from '@/v1'

const app = new Hono({ strict: true })

// * Global middlewares
app.use(trimTrailingSlash())
app.use(prettyJSON({ space: 2 }))
app.use(logger())
// * Global middlewares
.use(trimTrailingSlash())
.use(prettyJSON({ space: 2 }))
.use(logger())

// * Mounting versioned APIs
app.route('/api/v1', appV1)
// * Mounting versioned APIs
.route('/api/v1', appV1)

export * from '@/v1/validation'
export * from './prisma/generated/zod'
Expand Down
12 changes: 6 additions & 6 deletions apps/api/v1/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@ import walletsApp from './routes/wallets'

export const hono = new Hono()

hono.use('*', authMiddleware)
.use('*', authMiddleware)

hono.route('/auth', authApp)
hono.route('/budgets', budgetsApp)
hono.route('/users', usersApp)
hono.route('/transactions', transactionsApp)
hono.route('/wallets', walletsApp)
.route('/auth', authApp)
.route('/budgets', budgetsApp)
.route('/users', usersApp)
.route('/transactions', transactionsApp)
.route('/wallets', walletsApp)
4 changes: 1 addition & 3 deletions apps/api/v1/routes/auth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@ import { getAuth } from '@hono/clerk-auth'
import { Hono } from 'hono'
import { findUserById } from '../services/user.service'

const router = new Hono()

router.get('/me', async (c) => {
const router = new Hono().get('/me', async (c) => {
const auth = getAuth(c)

if (!auth?.userId) {
Expand Down
Loading

0 comments on commit ac88b27

Please sign in to comment.