hyperspan 1.0.0 → 1.0.1
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/package.json +2 -2
- package/src/index.ts +0 -2
- package/src/runtimes/bun.ts +6 -6
- package/src/server.ts +8 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "hyperspan",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.1",
|
|
4
4
|
"description": "Hyperspan CLI - for @hyperspan/framework",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"public": true,
|
|
@@ -32,7 +32,7 @@
|
|
|
32
32
|
"test": "bun test"
|
|
33
33
|
},
|
|
34
34
|
"dependencies": {
|
|
35
|
-
"@hyperspan/framework": "^1.0.
|
|
35
|
+
"@hyperspan/framework": "^1.0.1",
|
|
36
36
|
"bun-plugin-tailwind": "^0.1.2",
|
|
37
37
|
"commander": "^14.0.2",
|
|
38
38
|
"degit": "^2.8.4"
|
package/src/index.ts
CHANGED
package/src/runtimes/bun.ts
CHANGED
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
import { createContext } from "@hyperspan/framework";
|
|
2
2
|
import { join } from 'node:path';
|
|
3
|
+
import debug from 'debug';
|
|
3
4
|
|
|
4
5
|
import type { Hyperspan as HS } from '@hyperspan/framework';
|
|
5
6
|
|
|
7
|
+
const log = debug('hyperspan:cli');
|
|
8
|
+
|
|
6
9
|
/**
|
|
7
10
|
* Use Bun server. We don't have to do any path parsing here because Bun has its own path parsing logic with param passing in req.params.
|
|
8
11
|
* Using Bun HTTP server directly is the fastest way to serve the app, and is highly recommended for production.
|
|
@@ -39,20 +42,17 @@ export function startBunServer(server: HS.Server) {
|
|
|
39
42
|
development: process.env.NODE_ENV === 'development',
|
|
40
43
|
routes,
|
|
41
44
|
fetch: async (request: Request) => {
|
|
42
|
-
// Serve static files from the public directory
|
|
43
45
|
const url = new URL(request.url);
|
|
44
|
-
if (url.pathname.startsWith('/_hs/')) {
|
|
45
|
-
return new Response(Bun.file(join('./', server._config.publicDir, url.pathname)));
|
|
46
|
-
}
|
|
47
46
|
|
|
48
|
-
//
|
|
47
|
+
// Serve static files from the public directory
|
|
49
48
|
const file = Bun.file(join('./', server._config.publicDir, url.pathname))
|
|
50
49
|
const fileExists = await file.exists()
|
|
51
50
|
if (fileExists) {
|
|
51
|
+
log(`Serving static file: ${url.pathname}`);
|
|
52
52
|
return new Response(file);
|
|
53
53
|
}
|
|
54
54
|
|
|
55
|
-
|
|
55
|
+
log(`Serving 404: ${url.pathname}`);
|
|
56
56
|
return createContext(request).res.notFound();
|
|
57
57
|
},
|
|
58
58
|
});
|
package/src/server.ts
CHANGED
|
@@ -3,6 +3,7 @@ import { createServer, getRunnableRoute, IS_PROD } from '@hyperspan/framework';
|
|
|
3
3
|
import { CSS_PUBLIC_PATH, CSS_ROUTE_MAP } from '@hyperspan/framework/client/css';
|
|
4
4
|
import { isValidRoutePath, parsePath } from '@hyperspan/framework/utils';
|
|
5
5
|
import { join } from 'node:path';
|
|
6
|
+
import debug from 'debug';
|
|
6
7
|
import tailwind from "bun-plugin-tailwind"
|
|
7
8
|
|
|
8
9
|
import type { Hyperspan as HS } from '@hyperspan/framework';
|
|
@@ -12,6 +13,7 @@ type startConfig = {
|
|
|
12
13
|
};
|
|
13
14
|
|
|
14
15
|
const CWD = process.cwd();
|
|
16
|
+
const log = debug('hyperspan:server');
|
|
15
17
|
|
|
16
18
|
export async function loadConfig(): Promise<HS.Config> {
|
|
17
19
|
const configFile = join(CWD, 'hyperspan.config.ts');
|
|
@@ -73,9 +75,11 @@ export async function addDirectoryAsRoutes(
|
|
|
73
75
|
const buildDir = join(CWD, '.build');
|
|
74
76
|
const cssPublicDir = join(CWD, server._config.publicDir, CSS_PUBLIC_PATH);
|
|
75
77
|
|
|
78
|
+
log(`Scanning directory for routes: ${directoryPath}`);
|
|
79
|
+
|
|
76
80
|
try {
|
|
77
81
|
// Scan directory for TypeScript files
|
|
78
|
-
for await (const file of routesGlob.scan(directoryPath)) {
|
|
82
|
+
for await (const file of routesGlob.scan({ cwd: directoryPath, onlyFiles: true })) {
|
|
79
83
|
const filePath = join(directoryPath, file);
|
|
80
84
|
|
|
81
85
|
// Hidden directories and files start with a double underscore.
|
|
@@ -98,6 +102,9 @@ export async function addDirectoryAsRoutes(
|
|
|
98
102
|
if (!isValidRoutePath(relativeFilePath)) {
|
|
99
103
|
return null;
|
|
100
104
|
}
|
|
105
|
+
|
|
106
|
+
log(`Loading route: ${filePath}`);
|
|
107
|
+
|
|
101
108
|
const module = await import(filePath);
|
|
102
109
|
|
|
103
110
|
const route = getRunnableRoute(module);
|