simpledi-app-generator 0.0.14 → 0.0.15
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { Hono, type Schema, type Env } from 'hono';
|
|
2
|
+
import { getTestServer } from './getTestServer';
|
|
3
|
+
|
|
4
|
+
export const getNewTestServer = (
|
|
5
|
+
routes: Record<
|
|
6
|
+
string,
|
|
7
|
+
{ handler: Hono<Env, Schema, string>; mw?: any[] }
|
|
8
|
+
> = {}
|
|
9
|
+
) => {
|
|
10
|
+
const app = new Hono();
|
|
11
|
+
Object.keys(routes).forEach((route: string) => {
|
|
12
|
+
console.log('route', route);
|
|
13
|
+
if (!routes || !routes[route]) {
|
|
14
|
+
console.warn('Route not found', route);
|
|
15
|
+
return;
|
|
16
|
+
}
|
|
17
|
+
app.route(route, routes[route].handler);
|
|
18
|
+
routes[route].mw?.forEach((mw) => app.use(route, mw));
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
return getTestServer(app);
|
|
22
|
+
};
|