kempo-server 1.4.3 → 1.4.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.
Files changed (47) hide show
  1. package/.github/copilot-instructions.md +96 -96
  2. package/.github/workflows/publish-npm.yml +41 -0
  3. package/README.md +650 -650
  4. package/builtinMiddleware.js +136 -136
  5. package/defaultConfig.js +129 -129
  6. package/docs/.config.json +5 -5
  7. package/docs/.config.json.example +19 -19
  8. package/docs/api/user/[id]/GET.js +15 -15
  9. package/docs/api/user/[id]/[info]/DELETE.js +12 -12
  10. package/docs/api/user/[id]/[info]/GET.js +17 -17
  11. package/docs/api/user/[id]/[info]/POST.js +18 -18
  12. package/docs/api/user/[id]/[info]/PUT.js +19 -19
  13. package/docs/configuration.html +119 -119
  14. package/docs/examples.html +201 -201
  15. package/docs/getting-started.html +72 -72
  16. package/docs/index.html +81 -81
  17. package/docs/manifest.json +87 -87
  18. package/docs/middleware.html +147 -147
  19. package/docs/request-response.html +95 -95
  20. package/docs/routing.html +77 -77
  21. package/example-middleware.js +23 -23
  22. package/example.config.json +50 -50
  23. package/findFile.js +138 -138
  24. package/getFiles.js +72 -72
  25. package/getFlags.js +34 -34
  26. package/index.js +47 -47
  27. package/middlewareRunner.js +25 -25
  28. package/package.json +10 -6
  29. package/requestWrapper.js +87 -87
  30. package/responseWrapper.js +204 -204
  31. package/router.js +285 -285
  32. package/serveFile.js +71 -71
  33. package/tests/builtinMiddleware-cors.node-test.js +17 -17
  34. package/tests/builtinMiddleware.node-test.js +74 -74
  35. package/tests/defaultConfig.node-test.js +13 -13
  36. package/tests/example-middleware.node-test.js +31 -31
  37. package/tests/findFile.node-test.js +46 -46
  38. package/tests/getFiles.node-test.js +25 -25
  39. package/tests/getFlags.node-test.js +30 -30
  40. package/tests/index.node-test.js +23 -23
  41. package/tests/middlewareRunner.node-test.js +18 -18
  42. package/tests/requestWrapper.node-test.js +51 -51
  43. package/tests/responseWrapper.node-test.js +74 -74
  44. package/tests/router-middleware.node-test.js +46 -46
  45. package/tests/router.node-test.js +88 -88
  46. package/tests/serveFile.node-test.js +52 -52
  47. package/tests/test-utils.js +106 -106
@@ -1,96 +1,96 @@
1
- # Code Contribution Guidelines
2
-
3
- ## Coding Style Guidelines
4
-
5
- ### Code Organization
6
- Use multi-line comments to separate code into logical sections. Group related functionality together.
7
- - Example: In Lit components, group lifecycle callbacks, event handlers, public methods, utility functions, and rendering logic separately.
8
-
9
- ```javascript
10
- /*
11
- Lifecycle Callbacks
12
- */
13
- ```
14
-
15
- ### Avoid single-use variables/functions
16
- Avoid defining a variable or function to only use it once; inline the logic where needed. Some exceptions include:
17
- - recursion
18
- - scope encapsulation (IIFE)
19
- - context changes
20
-
21
- ### Minimal Comments, Empty Lines, and Spacing
22
-
23
- Use minimal comments. Assume readers understand the language. Some exceptions include:
24
- - complex logic
25
- - anti-patterns
26
- - code organization
27
-
28
- Do not put random empty lines within code; put them where they make sense for readability, for example:
29
- - above and below definitions for functions and classes.
30
- - to help break up large sections of logic to be more readable. If there are 100 lines of code with no breaks, it gets hard to read.
31
- - above multi-line comments to indicate the comment belongs to the code below
32
-
33
- No empty lines in css.
34
-
35
- End each file with an empty line.
36
-
37
- End each line with a `;` when possible, even if it is optional.
38
-
39
- Avoid unnecessary spacing, for example:
40
- - after the word `if`
41
- - within parentheses for conditional statements
42
-
43
- ```javascript
44
- let count = 1;
45
-
46
- const incrementOdd = (n) => {
47
- if(n % 2 !== 0){
48
- return n++;
49
- }
50
- return n;
51
- };
52
-
53
- count = incrementOdd(count);
54
- ```
55
-
56
- ### Prefer Arrow Functions
57
- Prefer the use of arrow functions when possible, especially for class methods to avoid binding. Use normal functions if needed for preserving the proper context.
58
- - For very basic logic, use implicit returns
59
- - If there is a single parameter, omit the parentheses.
60
- ```javascript
61
- const addOne = n => n + 1;
62
- ```
63
-
64
- ### Module Exports
65
- - If a module has only one export, use the "default" export, not a named export.
66
- - Do not declare the default export as a const or give it a name; just export the value.
67
-
68
- ```javascript
69
- export default (n) => n + 1;
70
- ```
71
- - If a module has multiple exports, use named exports and do not use a "default" export.
72
-
73
- ### Code Reuse
74
- Create utility functions for shared logic.
75
- - If the shared logic is used in a single file, define a utility function in that file.
76
- - If the shared logic is used in multiple files, create a utility function module file in `src/utils/`.
77
-
78
- ### Naming
79
- Do not prefix identifiers with underscores.
80
- - Never use leading underscores (`_`) for variable, property, method, or function names.
81
- - Use clear, descriptive names without prefixes.
82
- - When true privacy is needed inside classes, prefer native JavaScript private fields (e.g., `#myField`) instead of simulated privacy via underscores.
83
-
84
- ## Lit Components
85
-
86
- ### Component Architecture and Communication
87
-
88
- - Use methods to cause actions; do not emit events to trigger logic. Events are for notifying that something already happened.
89
- - Prefer `el.closest('ktf-test-framework')?.enqueueSuite({...})` over firing an `enqueue` event.
90
-
91
- - Wrap dependent GUI components inside a parent `ktf-test-framework` element. Children find it via `closest('ktf-test-framework')` and call its methods. The framework can query its subtree to orchestrate children.
92
-
93
- - Avoid `window` globals and global custom events for coordination. If broadcast is needed, scope events to the framework element; reserve window events for global, non-visual concerns (e.g., settings changes).
94
-
95
- - Queued status must show the `scheduled` icon. Running may apply `animation="spin"`.
96
-
1
+ # Code Contribution Guidelines
2
+
3
+ ## Coding Style Guidelines
4
+
5
+ ### Code Organization
6
+ Use multi-line comments to separate code into logical sections. Group related functionality together.
7
+ - Example: In Lit components, group lifecycle callbacks, event handlers, public methods, utility functions, and rendering logic separately.
8
+
9
+ ```javascript
10
+ /*
11
+ Lifecycle Callbacks
12
+ */
13
+ ```
14
+
15
+ ### Avoid single-use variables/functions
16
+ Avoid defining a variable or function to only use it once; inline the logic where needed. Some exceptions include:
17
+ - recursion
18
+ - scope encapsulation (IIFE)
19
+ - context changes
20
+
21
+ ### Minimal Comments, Empty Lines, and Spacing
22
+
23
+ Use minimal comments. Assume readers understand the language. Some exceptions include:
24
+ - complex logic
25
+ - anti-patterns
26
+ - code organization
27
+
28
+ Do not put random empty lines within code; put them where they make sense for readability, for example:
29
+ - above and below definitions for functions and classes.
30
+ - to help break up large sections of logic to be more readable. If there are 100 lines of code with no breaks, it gets hard to read.
31
+ - above multi-line comments to indicate the comment belongs to the code below
32
+
33
+ No empty lines in css.
34
+
35
+ End each file with an empty line.
36
+
37
+ End each line with a `;` when possible, even if it is optional.
38
+
39
+ Avoid unnecessary spacing, for example:
40
+ - after the word `if`
41
+ - within parentheses for conditional statements
42
+
43
+ ```javascript
44
+ let count = 1;
45
+
46
+ const incrementOdd = (n) => {
47
+ if(n % 2 !== 0){
48
+ return n++;
49
+ }
50
+ return n;
51
+ };
52
+
53
+ count = incrementOdd(count);
54
+ ```
55
+
56
+ ### Prefer Arrow Functions
57
+ Prefer the use of arrow functions when possible, especially for class methods to avoid binding. Use normal functions if needed for preserving the proper context.
58
+ - For very basic logic, use implicit returns
59
+ - If there is a single parameter, omit the parentheses.
60
+ ```javascript
61
+ const addOne = n => n + 1;
62
+ ```
63
+
64
+ ### Module Exports
65
+ - If a module has only one export, use the "default" export, not a named export.
66
+ - Do not declare the default export as a const or give it a name; just export the value.
67
+
68
+ ```javascript
69
+ export default (n) => n + 1;
70
+ ```
71
+ - If a module has multiple exports, use named exports and do not use a "default" export.
72
+
73
+ ### Code Reuse
74
+ Create utility functions for shared logic.
75
+ - If the shared logic is used in a single file, define a utility function in that file.
76
+ - If the shared logic is used in multiple files, create a utility function module file in `src/utils/`.
77
+
78
+ ### Naming
79
+ Do not prefix identifiers with underscores.
80
+ - Never use leading underscores (`_`) for variable, property, method, or function names.
81
+ - Use clear, descriptive names without prefixes.
82
+ - When true privacy is needed inside classes, prefer native JavaScript private fields (e.g., `#myField`) instead of simulated privacy via underscores.
83
+
84
+ ## Lit Components
85
+
86
+ ### Component Architecture and Communication
87
+
88
+ - Use methods to cause actions; do not emit events to trigger logic. Events are for notifying that something already happened.
89
+ - Prefer `el.closest('ktf-test-framework')?.enqueueSuite({...})` over firing an `enqueue` event.
90
+
91
+ - Wrap dependent GUI components inside a parent `ktf-test-framework` element. Children find it via `closest('ktf-test-framework')` and call its methods. The framework can query its subtree to orchestrate children.
92
+
93
+ - Avoid `window` globals and global custom events for coordination. If broadcast is needed, scope events to the framework element; reserve window events for global, non-visual concerns (e.g., settings changes).
94
+
95
+ - Queued status must show the `scheduled` icon. Running may apply `animation="spin"`.
96
+
@@ -0,0 +1,41 @@
1
+
2
+ name: Publish Package to npmjs
3
+
4
+ on:
5
+ push:
6
+ branches:
7
+ - main
8
+ workflow_dispatch:
9
+
10
+ jobs:
11
+ publish:
12
+ runs-on: ubuntu-latest
13
+ permissions:
14
+ contents: read
15
+ id-token: write # enables npm provenance
16
+ steps:
17
+ - uses: actions/checkout@v4
18
+
19
+ # Setup Node and create an .npmrc that uses the token from NODE_AUTH_TOKEN
20
+ - uses: actions/setup-node@v4
21
+ with:
22
+ node-version: '20.x'
23
+ registry-url: 'https://registry.npmjs.org'
24
+
25
+ - run: npm ci
26
+
27
+ # Auto-increment patch version, commit, and push
28
+ - name: Bump patch version
29
+ run: |
30
+ git config --global user.name "github-actions"
31
+ git config --global user.email "github-actions@github.com"
32
+ npm version patch --no-git-tag-version
33
+ git add package.json package-lock.json || true
34
+ git commit -m "ci: bump patch version [skip ci]" || echo "No changes to commit"
35
+ git push origin HEAD:main || echo "No changes to push"
36
+
37
+ # If your package is public and scoped (e.g., @scope/name), keep --access public.
38
+ # For unscoped public packages, you can omit --access.
39
+ - run: npm publish --provenance --access public
40
+ env:
41
+ NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}