bun-router 0.7.4-experimental.4 → 0.7.4-experimental.5
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.
- package/lib/fs/fsys.ts +5 -1
- package/lib/logger/logger.ts +1 -1
- package/lib/router/router.ts +2 -2
- package/package.json +1 -1
package/lib/fs/fsys.ts
CHANGED
@@ -32,5 +32,9 @@ function splitFilePath(p: string): string[] {
|
|
32
32
|
return p.split(path.sep);
|
33
33
|
}
|
34
34
|
|
35
|
+
function resolveModulePath(module: string) {
|
36
|
+
return path.join(process.cwd(), module);
|
37
|
+
}
|
38
|
+
|
35
39
|
|
36
|
-
export { readDir, ext, splitFilePath };
|
40
|
+
export { readDir, ext, splitFilePath, resolveModulePath };
|
package/lib/logger/logger.ts
CHANGED
@@ -9,7 +9,7 @@ _ _
|
|
9
9
|
|___|___|_|_| |_| |___|___|_| |___|_|
|
10
10
|
|
11
11
|
`;
|
12
|
-
const VERSION = '0.7.4-experimental.
|
12
|
+
const VERSION = '0.7.4-experimental.5';
|
13
13
|
const Logger = (): BunLogger => {
|
14
14
|
return {
|
15
15
|
info: async (statusCode: number, routePath: string, method: string, message?: string) => {
|
package/lib/router/router.ts
CHANGED
@@ -2,7 +2,7 @@ import path from 'path';
|
|
2
2
|
import { Database } from 'bun:sqlite';
|
3
3
|
import { Route, BunRouter, RouterOptions, Options, HttpHandler } from './router.d';
|
4
4
|
import { httpStatusCodes } from '../http/status';
|
5
|
-
import { readDir } from '../fs/fsys';
|
5
|
+
import { readDir, resolveModulePath } from '../fs/fsys';
|
6
6
|
import { Logger, startMessage } from '../logger/logger';
|
7
7
|
import { http } from '../http/http';
|
8
8
|
import { RouteTree } from './tree';
|
@@ -54,7 +54,7 @@ const Router: BunRouter = (port?: number | string, options?: RouterOptions<Optio
|
|
54
54
|
method: 'GET',
|
55
55
|
handler: async () => {
|
56
56
|
if (ext === '.tsx') {
|
57
|
-
const component = await loadComponent(purePath.split('.')[0]);
|
57
|
+
const component = await loadComponent(resolveModulePath(purePath.split('.')[0]));
|
58
58
|
return await http.render(component());
|
59
59
|
} else {
|
60
60
|
return await http.file(200, fp);
|