bun-router 0.7.4-experimental.4 → 0.7.4-experimental.5

Sign up to get free protection for your applications and to get access to all the features.
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 };
@@ -9,7 +9,7 @@ _ _
9
9
  |___|___|_|_| |_| |___|___|_| |___|_|
10
10
 
11
11
  `;
12
- const VERSION = '0.7.4-experimental.4';
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) => {
@@ -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);
package/package.json CHANGED
@@ -14,7 +14,7 @@
14
14
  "peerDependencies": {
15
15
  "typescript": "^5.0.0"
16
16
  },
17
- "version": "0.7.4-experimental.4",
17
+ "version": "0.7.4-experimental.5",
18
18
  "dependencies": {
19
19
  "@types/react": "^18.2.22",
20
20
  "eslint-plugin-react-hooks": "^4.6.0",