-
I have a mega-scale application with over 600 tables in it's DB, with a peak of about 200 requests/s. It needs a full re-codeing.
Your answer would be much appreciated @yusukebe. |
Beta Was this translation helpful? Give feedback.
Replies: 5 comments 3 replies
-
Hi @movahhedi I'll answer them:
Unfortunately, it will be impossible. You are right; it will be the issue with TypeScript. To benchmark it, you can create an app with many routes with the following script: import { writeFile } from 'fs'
const generateRoutes = (count: number) => {
const imports = `
import { Hono } from 'hono';
import { z } from 'zod';
import { zValidator } from '@hono/zod-validator';
`
const schema = `
const schema = z.object({
q: z.string()
})\n
`
let routes = imports + schema + 'export const app = new Hono()\n'
for (let i = 1; i <= count; i++) {
routes += ` .get('/route${i}/:id', zValidator('query', schema), (c) => {
return c.json({
query: c.req.valid('query'),
id: c.req.param('id'),
ok: true
})
})\n`
}
return routes
}
const count = 300
const routes = generateRoutes(count)
writeFile('app.ts', routes, (err) => {
if (err) throw err
console.log(`${count} routes have been written to app.ts`)
}) The IDE can't handle over 300 routes on my machine. Below is the error message when it has many handler limits of the number: So, you need to separate the routes if you want to use the RPC feature.
Yes. It will be good to use this method. Creating an instance of Hono is only performed at application initialization time, so once up and running, there is no cost to do Please see the following comment I wrote: https://github.com/orgs/honojs/discussions/2066#discussioncomment-8239397 But regardless of which framework you use, I believe 2500 routes are too large. In my opinion, it is better to separate the applications. You can refer to this comment: https://github.com/orgs/honojs/discussions/2066#discussioncomment-8239698
It is difficult to handle 600 routes in a client created by // src/routes/book.ts
const book = new Hono()
.get('/', (c) => c.json(0))
.post('/', (c) => c.json(0))
.put('/', (c) => c.json(0))
.delete('/', (c) => c.json(0))
// src/main.ts
main.route('/book', book)
// client of a book
const bookClient = hc<typeof book>('/book')
// ...
// src/routes/author.ts
const author = new Hono()
.get('/', (c) => c.json(0))
.post('/', (c) => c.json(0))
.put('/', (c) => c.json(0))
.delete('/', (c) => c.json(0))
// src/main.ts
main.route('/author', author)
// client of an author
const authorClient = hc<typeof author>('/author') |
Beta Was this translation helpful? Give feedback.
-
Thanks for your response @yusukebe.
So if I distribute these 2500 routes in like 25 |
Beta Was this translation helpful? Give feedback.
-
I created a repo with the code you sent, and tweaked it to create multiple |
Beta Was this translation helpful? Give feedback.
-
With the code @movahhedi/hono-test, I created 15 Hono instances, each with 200 routes (15x200 = 3000 routes), without any Is it possible to create a version of Hono, remove some less-used features, make it lightweight for TypeScript that can handle large codebases (just like how you created Even for the server-side itself (without |
Beta Was this translation helpful? Give feedback.
-
Beta Was this translation helpful? Give feedback.
Hi @movahhedi
I'll answer them:
Unfortunately, it will be impossible. You are right; it will be the issue with TypeScript. To benchmark it, you can create an app with many routes with the following script: