kempo-server 1.9.0 → 1.9.2
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/README.md +4 -2
- package/docs/caching.html +1 -1
- package/docs/cli-utils.html +1 -1
- package/docs/configuration.html +38 -2
- package/docs/examples.html +1 -1
- package/docs/fs-utils.html +1 -1
- package/docs/getting-started.html +1 -1
- package/docs/index.html +6 -2
- package/docs/init.js +0 -0
- package/docs/middleware.html +1 -1
- package/docs/nav.inc.html +41 -0
- package/docs/nav.inc.js +16 -0
- package/docs/request-response.html +1 -1
- package/docs/routing.html +1 -1
- package/docs/theme.css +9 -0
- package/package.json +1 -5
- package/src/defaultConfig.js +0 -1
- package/cli-utils-screenshot.png +0 -0
- package/docs/.config.json +0 -6
package/README.md
CHANGED
|
@@ -215,10 +215,12 @@ Kempo Server can be customized with a simple JSON configuration file to control
|
|
|
215
215
|
|
|
216
216
|
For detailed configuration options and examples, see **[CONFIG.md](./CONFIG.md)**.
|
|
217
217
|
|
|
218
|
+
**Important:** The config file must be placed **inside the server root directory** (the `--root` folder). All paths in the config (like `customRoutes`) are resolved relative to the config file location.
|
|
219
|
+
|
|
218
220
|
Quick start:
|
|
219
221
|
```bash
|
|
220
|
-
# Create a
|
|
221
|
-
echo '{"cache": {"enabled": true}}' >
|
|
222
|
+
# Create a config file INSIDE the server root
|
|
223
|
+
echo '{"cache": {"enabled": true}}' > public/.config.json
|
|
222
224
|
|
|
223
225
|
# Use different configs for different environments
|
|
224
226
|
kempo-server --root public --config dev.config.json
|
package/docs/caching.html
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
<title>Caching - Kempo Server</title>
|
|
7
7
|
<meta name='viewport' content='width=device-width, initial-scale=1'>
|
|
8
8
|
<link rel="icon" type="image/png" sizes="48x48" href="./media/icon48.png">
|
|
9
|
-
<link rel="manifest" href="./manifest.json"
|
|
9
|
+
<link rel="manifest" href="./manifest.json" />
|
|
10
10
|
<link rel="stylesheet" href="./kempo.min.css" />
|
|
11
11
|
</head>
|
|
12
12
|
<body>
|
package/docs/cli-utils.html
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
<title>CLI Utilities - Kempo Server</title>
|
|
7
7
|
<meta name='viewport' content='width=device-width, initial-scale=1'>
|
|
8
8
|
<link rel="icon" type="image/png" sizes="48x48" href="./media/icon48.png">
|
|
9
|
-
<link rel="manifest" href="./manifest.json"
|
|
9
|
+
<link rel="manifest" href="./manifest.json" />
|
|
10
10
|
<link rel="stylesheet" href="./kempo.min.css" />
|
|
11
11
|
</head>
|
|
12
12
|
<body>
|
package/docs/configuration.html
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
<title>Configuration - Kempo Server</title>
|
|
6
6
|
<meta name='viewport' content='width=device-width, initial-scale=1'>
|
|
7
7
|
<link rel="icon" type="image/png" sizes="48x48" href="./media/icon48.png">
|
|
8
|
-
<link rel="manifest" href="./manifest.json"
|
|
8
|
+
<link rel="manifest" href="./manifest.json" />
|
|
9
9
|
<link rel="stylesheet" href="./kempo.min.css" />
|
|
10
10
|
</head>
|
|
11
11
|
<body>
|
|
@@ -15,6 +15,9 @@
|
|
|
15
15
|
<p>Customize Kempo Server's behavior with a simple JSON configuration file.</p>
|
|
16
16
|
|
|
17
17
|
<h2>Configuration File</h2>
|
|
18
|
+
<div class="callout warning">
|
|
19
|
+
<strong>Important:</strong> The configuration file must be placed <strong>inside the server root directory</strong> (the folder specified by <code>--root</code>). For example, if you run <code>kempo-server --root public</code>, your config file should be at <code>public/.config.json</code> or <code>public/dev.config.json</code>, not in the project root.
|
|
20
|
+
</div>
|
|
18
21
|
<p>To configure the server, create a configuration file (by default <code>.config.json</code>) within the root directory of your server (<code>public</code> in the start example). You can specify a different configuration file using the <code>--config</code> flag:</p>
|
|
19
22
|
<pre><code class="hljs bash"># Use default .config.json<br />kempo-server --root public<br /><br /># Use custom config file<br />kempo-server --root public --config staging.config.json<br /><br /># Use absolute path<br />kempo-server --root public --config /etc/kempo/production.config.json</code></pre>
|
|
20
23
|
<p>This json file can have any of the following properties. Any property not defined will use the default configuration.</p>
|
|
@@ -64,6 +67,14 @@
|
|
|
64
67
|
<h3 id="customRoutes">customRoutes</h3>
|
|
65
68
|
<p>An object mapping custom route paths to file paths. Useful for aliasing or serving files from outside the document root.</p>
|
|
66
69
|
|
|
70
|
+
<div class="callout info">
|
|
71
|
+
<strong>Path Resolution:</strong> All paths in <code>customRoutes</code> are resolved <strong>relative to the config file's location</strong> (which is the server root). To reference files outside the server root (like <code>node_modules</code> or a <code>src</code> folder), use <code>../</code> to navigate up to the project root.
|
|
72
|
+
</div>
|
|
73
|
+
|
|
74
|
+
<div class="callout info">
|
|
75
|
+
<strong>Route Priority:</strong> Custom routes take priority over files that exist in the directory structure. If you have both <code>public/dist/app.js</code> and a custom route <code>"/dist/**": "../src/**"</code>, the custom route will be used and the file will be served from <code>src/</code>.
|
|
76
|
+
</div>
|
|
77
|
+
|
|
67
78
|
<h4>Basic Routes</h4>
|
|
68
79
|
<p>Map specific paths to files:</p>
|
|
69
80
|
<pre><code class="hljs json">{<br /> <span class="hljs-attr">"customRoutes"</span>: {<br /> <span class="hljs-attr">"/vendor/bootstrap.css"</span>: <span class="hljs-string">"./node_modules/bootstrap/dist/css/bootstrap.min.css"</span>,<br /> <span class="hljs-attr">"/api/status"</span>: <span class="hljs-string">"./status.js"</span>,<br /> <span class="hljs-attr">"/health"</span>: <span class="hljs-string">"./health-check.js"</span><br /> }<br />}</code></pre>
|
|
@@ -79,7 +90,32 @@
|
|
|
79
90
|
<li><code>docs/readme.md</code> would serve <code>./documentation/readme.md</code></li>
|
|
80
91
|
<li><code>lib/utils.js</code> would serve <code>./node_modules/my-library/build/utils.js</code></li>
|
|
81
92
|
</ul>
|
|
82
|
-
<
|
|
93
|
+
<h4>Wildcard Syntax</h4>
|
|
94
|
+
<ul>
|
|
95
|
+
<li><code>*</code> - Matches a single path segment (anything between <code>/</code> characters)</li>
|
|
96
|
+
<li><code>**</code> - Matches recursively (any depth of subdirectories)</li>
|
|
97
|
+
</ul>
|
|
98
|
+
<p>Use <code>**</code> when you want to redirect an entire directory tree. Multiple wildcards can be used in a single route pattern.</p>
|
|
99
|
+
|
|
100
|
+
<h4>Common Use Case: Dev vs Production Builds</h4>
|
|
101
|
+
<p>A common pattern is to serve source files during development but built/minified files in production. Given this project structure:</p>
|
|
102
|
+
<pre><code class="hljs">project/
|
|
103
|
+
├── src/ # Source files
|
|
104
|
+
│ └── app.js
|
|
105
|
+
├── node_modules/
|
|
106
|
+
├── public/ # Server root (--root public)
|
|
107
|
+
│ ├── dev.config.json # Config lives HERE (inside server root)
|
|
108
|
+
│ ├── dist/ # Built files
|
|
109
|
+
│ │ └── app.js
|
|
110
|
+
│ └── index.html</code></pre>
|
|
111
|
+
<p>Your <code>dev.config.json</code> can redirect <code>/dist/**</code> requests to serve from <code>src/</code> instead:</p>
|
|
112
|
+
<pre><code class="hljs json">{
|
|
113
|
+
"customRoutes": {
|
|
114
|
+
"/dist/**": "../src/**",
|
|
115
|
+
"/kempo-ui/**": "../node_modules/kempo-ui/**"
|
|
116
|
+
}
|
|
117
|
+
}</code></pre>
|
|
118
|
+
<p>Now requests to <code>/dist/app.js</code> will serve <code>../src/app.js</code> (the unminified source), while production uses the actual <code>dist/</code> files.</p>
|
|
83
119
|
|
|
84
120
|
<h3 id="maxRescanAttempts">maxRescanAttempts</h3>
|
|
85
121
|
<p>The maximum number of times to attempt rescanning the file system when a file is not found. Defaults to 3.</p>
|
package/docs/examples.html
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
<title>Examples & Demos - Kempo Server</title>
|
|
6
6
|
<meta name='viewport' content='width=device-width, initial-scale=1'>
|
|
7
7
|
<link rel="icon" type="image/png" sizes="48x48" href="./media/icon48.png">
|
|
8
|
-
<link rel="manifest" href="./manifest.json"
|
|
8
|
+
<link rel="manifest" href="./manifest.json" />
|
|
9
9
|
<link rel="stylesheet" href="./kempo.min.css" />
|
|
10
10
|
</head>
|
|
11
11
|
<body>
|
package/docs/fs-utils.html
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
<title>File System Utilities - Kempo Server</title>
|
|
7
7
|
<meta name='viewport' content='width=device-width, initial-scale=1'>
|
|
8
8
|
<link rel="icon" type="image/png" sizes="48x48" href="./media/icon48.png">
|
|
9
|
-
<link rel="manifest" href="./manifest.json"
|
|
9
|
+
<link rel="manifest" href="./manifest.json" />
|
|
10
10
|
<link rel="stylesheet" href="./kempo.min.css" />
|
|
11
11
|
</head>
|
|
12
12
|
<body>
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
<title>Getting Started - Kempo Server</title>
|
|
6
6
|
<meta name='viewport' content='width=device-width, initial-scale=1'>
|
|
7
7
|
<link rel="icon" type="image/png" sizes="48x48" href="./media/icon48.png">
|
|
8
|
-
<link rel="manifest" href="./manifest.json"
|
|
8
|
+
<link rel="manifest" href="./manifest.json" />
|
|
9
9
|
<link rel="stylesheet" href="./kempo.min.css" />
|
|
10
10
|
</head>
|
|
11
11
|
<body>
|
package/docs/index.html
CHANGED
|
@@ -5,10 +5,13 @@
|
|
|
5
5
|
<title>Kempo Server - Documentation</title>
|
|
6
6
|
<meta name='viewport' content='width=device-width, initial-scale=1'>
|
|
7
7
|
<link rel="icon" type="image/png" sizes="48x48" href="./media/icon48.png">
|
|
8
|
-
<link rel="manifest" href="./manifest.json"
|
|
9
|
-
<link rel="stylesheet" href="
|
|
8
|
+
<link rel="manifest" href="./manifest.json" />
|
|
9
|
+
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/kempo-css@1.3.2/dist/kempo.min.css" />
|
|
10
|
+
<link rel="stylesheet" href="./theme.css" />
|
|
11
|
+
<script>window.litDisableBundleWarning = true;</script>
|
|
10
12
|
</head>
|
|
11
13
|
<body>
|
|
14
|
+
<k-import src="./nav.inc.html"></k-import>
|
|
12
15
|
<main>
|
|
13
16
|
<h1 class="ta-center">Kempo Server</h1>
|
|
14
17
|
<div class="ta-center">
|
|
@@ -80,5 +83,6 @@ npx kempo-server --root public</code></pre>
|
|
|
80
83
|
</div>
|
|
81
84
|
</main>
|
|
82
85
|
<div style="height:25vh"></div>
|
|
86
|
+
<script type="module" src="https://cdn.jsdelivr.net/npm/kempo-ui@0.0.42/dist/components/Import.js"></script>
|
|
83
87
|
</body>
|
|
84
88
|
</html>
|
package/docs/init.js
ADDED
|
File without changes
|
package/docs/middleware.html
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
<title>Middleware - Kempo Server</title>
|
|
6
6
|
<meta name='viewport' content='width=device-width, initial-scale=1'>
|
|
7
7
|
<link rel="icon" type="image/png" sizes="48x48" href="./media/icon48.png">
|
|
8
|
-
<link rel="manifest" href="./manifest.json"
|
|
8
|
+
<link rel="manifest" href="./manifest.json" />
|
|
9
9
|
<link rel="stylesheet" href="./kempo.min.css" />
|
|
10
10
|
</head>
|
|
11
11
|
<body>
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
<nav
|
|
2
|
+
class="d-f bg-primary fixed"
|
|
3
|
+
>
|
|
4
|
+
<button
|
|
5
|
+
id="toggleNavSideMenu"
|
|
6
|
+
class="link"
|
|
7
|
+
>
|
|
8
|
+
<k-icon name="menu"></k-icon>
|
|
9
|
+
</button>
|
|
10
|
+
<a
|
|
11
|
+
href="./"
|
|
12
|
+
class="d-if ph"
|
|
13
|
+
style="align-items: center"
|
|
14
|
+
>
|
|
15
|
+
<img src="./media/icon32.png" alt="Kempo Server Icon" class="pr" />
|
|
16
|
+
Kempo Server
|
|
17
|
+
</a>
|
|
18
|
+
<div class="flex"></div>
|
|
19
|
+
<a href="https://github.com/dustinpoissant/kempo-ui?tab=License-1-ov-file#creative-commons-attribution-noncommercial-sharealike-20" target="_blank"><k-icon name="license"></k-icont></a>
|
|
20
|
+
<a href="https://github.com/dustinpoissant/kempo-ui" target="_blank"><k-icon name="github-mark"></k-icont></a>
|
|
21
|
+
<k-theme-switcher></k-theme-switcher>
|
|
22
|
+
</nav>
|
|
23
|
+
<div style="width: 100%; height: 4rem;"></div>
|
|
24
|
+
<k-side-menu
|
|
25
|
+
id="navSideMenu"
|
|
26
|
+
>
|
|
27
|
+
<menu>
|
|
28
|
+
<a href="./" class="ta-center bb mb r0">
|
|
29
|
+
<h1 class="tc-primary">Kempo Server</h1>
|
|
30
|
+
<img src="./media/icon128.png" alt="Kempo UI Icon" />
|
|
31
|
+
</a>
|
|
32
|
+
|
|
33
|
+
<div class="pl mb">
|
|
34
|
+
<a href="./">Quick Start</a>
|
|
35
|
+
</div>
|
|
36
|
+
</menu>
|
|
37
|
+
</k-side-menu>
|
|
38
|
+
<script src="https://cdn.jsdelivr.net/npm/kempo-ui@0.0.42/dist/components/SideMenu.js" type="module"></script>
|
|
39
|
+
<script src="https://cdn.jsdelivr.net/npm/kempo-ui@0.0.42/dist/components/Icon.js" type="module"></script>
|
|
40
|
+
<script src="https://cdn.jsdelivr.net/npm/kempo-ui@0.0.42/dist/components/ThemeSwitcher.js" type="module"></script>
|
|
41
|
+
<script src="./nav.inc.js" type="module"></script>
|
package/docs/nav.inc.js
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
document.getElementById('toggleNavSideMenu').addEventListener('click', async () => {
|
|
2
|
+
await window.customElements.whenDefined('k-side-menu');
|
|
3
|
+
document.getElementById('navSideMenu').toggle();
|
|
4
|
+
});
|
|
5
|
+
document.addEventListener('click', function(e) {
|
|
6
|
+
if (e.target.matches('a[href^="#"]')) {
|
|
7
|
+
e.preventDefault();
|
|
8
|
+
const targetId = e.target.getAttribute('href').replace('#', '');
|
|
9
|
+
const target = document.getElementById(targetId);
|
|
10
|
+
if (target) {
|
|
11
|
+
target.scrollIntoView({ behavior: 'smooth' });
|
|
12
|
+
const url = window.location.pathname + window.location.search + '#' + targetId;
|
|
13
|
+
history.replaceState(null, '', url);
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
});
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
<title>Request & Response - Kempo Server</title>
|
|
6
6
|
<meta name='viewport' content='width=device-width, initial-scale=1'>
|
|
7
7
|
<link rel="icon" type="image/png" sizes="48x48" href="./media/icon48.png">
|
|
8
|
-
<link rel="manifest" href="./manifest.json"
|
|
8
|
+
<link rel="manifest" href="./manifest.json" />
|
|
9
9
|
<link rel="stylesheet" href="./kempo.min.css" />
|
|
10
10
|
</head>
|
|
11
11
|
<body>
|
package/docs/routing.html
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
<title>Routes & Routing - Kempo Server</title>
|
|
6
6
|
<meta name='viewport' content='width=device-width, initial-scale=1'>
|
|
7
7
|
<link rel="icon" type="image/png" sizes="48x48" href="./media/icon48.png">
|
|
8
|
-
<link rel="manifest" href="./manifest.json"
|
|
8
|
+
<link rel="manifest" href="./manifest.json" />
|
|
9
9
|
<link rel="stylesheet" href="./kempo.min.css" />
|
|
10
10
|
</head>
|
|
11
11
|
<body>
|
package/docs/theme.css
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
:root {
|
|
2
|
+
--c_primary: rgb(153, 51, 255);
|
|
3
|
+
--c_primary__hover: rgb(119, 17, 221);
|
|
4
|
+
--c_secondary: rgb(51, 102, 255);
|
|
5
|
+
--c_secondary__hover: rgb(17, 68, 221);
|
|
6
|
+
--tc_primary: light-dark(#93f, rgb(187, 102, 255));
|
|
7
|
+
--tc_secondary: light-dark(#36f, rgb(138, 180, 248));
|
|
8
|
+
--c_highlight: light-dark(rgba(153, 51, 255, 0.25), rgba(153, 51, 255, 0.25));
|
|
9
|
+
}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "kempo-server",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "1.9.
|
|
4
|
+
"version": "1.9.2",
|
|
5
5
|
"description": "A lightweight, zero-dependency, file based routing server.",
|
|
6
6
|
"main": "dist/index.js",
|
|
7
7
|
"exports": {
|
|
@@ -23,15 +23,11 @@
|
|
|
23
23
|
"author": "",
|
|
24
24
|
"license": "ISC",
|
|
25
25
|
"devDependencies": {
|
|
26
|
-
"essentialcss": "^2.0.1",
|
|
27
26
|
"kempo-testing-framework": "^1.2.3",
|
|
28
27
|
"terser": "^5.43.1"
|
|
29
28
|
},
|
|
30
29
|
"repository": {
|
|
31
30
|
"type": "git",
|
|
32
31
|
"url": "https://github.com/dustinpoissant/kempo-server"
|
|
33
|
-
},
|
|
34
|
-
"dependencies": {
|
|
35
|
-
"kempo-css": "^1.0.5"
|
|
36
32
|
}
|
|
37
33
|
}
|
package/src/defaultConfig.js
CHANGED
package/cli-utils-screenshot.png
DELETED
|
Binary file
|