create-jen-app 1.2.3 → 1.2.4
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/dist/colors.js +0 -17
- package/dist/create.js +5 -17
- package/dist/generator.js +14 -31
- package/dist/index.js +6 -1
- package/package.json +1 -1
- package/templates/ssr-isr/README.md +77 -0
- package/templates/ssr-isr/build.js +118 -0
- package/templates/ssr-isr/jen.config.ts +109 -0
- package/templates/ssr-isr/jenjs.d.ts +22 -0
- package/templates/ssr-isr/lib/api/(hello).js +9 -0
- package/templates/ssr-isr/lib/auth/cookie-utils.js +79 -0
- package/templates/ssr-isr/lib/auth/index.js +2 -0
- package/templates/ssr-isr/lib/auth/jwt.js +57 -0
- package/templates/ssr-isr/lib/auth/session.js +92 -0
- package/templates/ssr-isr/lib/build/asset-hashing.d.ts +10 -0
- package/templates/ssr-isr/lib/build/asset-hashing.js +25 -0
- package/templates/ssr-isr/lib/build/asset-manifest.d.ts +11 -0
- package/templates/ssr-isr/lib/build/asset-manifest.js +21 -0
- package/templates/{static → ssr-isr}/lib/build/build.d.ts +1 -1
- package/templates/ssr-isr/lib/build/build.js +141 -0
- package/templates/{static → ssr-isr}/lib/build/island-hydration.d.ts +8 -5
- package/templates/ssr-isr/lib/build/island-hydration.js +44 -0
- package/templates/ssr-isr/lib/build/minifier.d.ts +20 -0
- package/templates/ssr-isr/lib/build/minifier.js +46 -0
- package/templates/ssr-isr/lib/build/page-renderer.d.ts +17 -0
- package/templates/ssr-isr/lib/build/page-renderer.js +28 -0
- package/templates/ssr-isr/lib/build/production-build.d.ts +10 -0
- package/templates/ssr-isr/lib/build/production-build.js +13 -0
- package/templates/ssr-isr/lib/build/ssg-pipeline.d.ts +15 -0
- package/templates/ssr-isr/lib/build/ssg-pipeline.js +113 -0
- package/templates/ssr-isr/lib/build-tools/build-site.js +36 -0
- package/templates/ssr-isr/lib/cache/index.js +10 -0
- package/templates/ssr-isr/lib/cache/memory.js +40 -0
- package/templates/ssr-isr/lib/cache/redis.js +61 -0
- package/templates/ssr-isr/lib/cli/banner.js +28 -0
- package/templates/ssr-isr/lib/cli/templates/ssg/jen.config.js +32 -0
- package/templates/ssr-isr/lib/cli/templates/ssg/site/index.js +9 -0
- package/templates/ssr-isr/lib/cli/templates/ssr/jen.config.js +32 -0
- package/templates/ssr-isr/lib/cli/templates/ssr/site/index.js +9 -0
- package/templates/ssr-isr/lib/compilers/esbuild-plugins.js +111 -0
- package/templates/ssr-isr/lib/compilers/svelte.js +44 -0
- package/templates/ssr-isr/lib/compilers/vue.js +90 -0
- package/templates/ssr-isr/lib/core/http.js +71 -0
- package/templates/ssr-isr/lib/core/middleware-hooks.js +97 -0
- package/templates/ssr-isr/lib/core/paths.js +39 -0
- package/templates/ssr-isr/lib/core/routes/match.js +47 -0
- package/templates/ssr-isr/lib/core/routes/scan.js +190 -0
- package/templates/ssr-isr/lib/core/types.js +1 -0
- package/templates/ssr-isr/lib/css/compiler.js +74 -0
- package/templates/ssr-isr/lib/db/connector.js +42 -0
- package/templates/ssr-isr/lib/db/drivers/jdb.js +44 -0
- package/templates/ssr-isr/lib/db/drivers/sql.js +182 -0
- package/templates/ssr-isr/lib/db/index.js +48 -0
- package/templates/ssr-isr/lib/db/types.js +1 -0
- package/templates/ssr-isr/lib/graphql/index.js +52 -0
- package/templates/ssr-isr/lib/graphql/resolvers.js +25 -0
- package/templates/ssr-isr/lib/graphql/schema.js +35 -0
- package/templates/ssr-isr/lib/i18n/en.json +4 -0
- package/templates/ssr-isr/lib/i18n/es.json +4 -0
- package/templates/ssr-isr/lib/i18n/index.js +15 -0
- package/templates/ssr-isr/lib/import/jen-import.js +161 -0
- package/templates/ssr-isr/lib/index.js +116 -0
- package/templates/ssr-isr/lib/jdb/engine.js +275 -0
- package/templates/ssr-isr/lib/jdb/index.js +34 -0
- package/templates/ssr-isr/lib/jdb/types.js +1 -0
- package/templates/ssr-isr/lib/jdb/utils.js +176 -0
- package/templates/{static → ssr-isr}/lib/middleware/builtins/body-parser.js +0 -17
- package/templates/ssr-isr/lib/middleware/builtins/cors.js +54 -0
- package/templates/{static → ssr-isr}/lib/middleware/builtins/logger.js +0 -17
- package/templates/{static → ssr-isr}/lib/middleware/builtins/rate-limit.js +0 -17
- package/templates/{static → ssr-isr}/lib/middleware/builtins/request-id.js +0 -17
- package/templates/{static → ssr-isr}/lib/middleware/builtins/security-headers.js +0 -17
- package/templates/ssr-isr/lib/middleware/context.js +124 -0
- package/templates/{static → ssr-isr}/lib/middleware/decorators.js +0 -17
- package/templates/{static → ssr-isr}/lib/middleware/errors/handler.js +0 -17
- package/templates/ssr-isr/lib/middleware/errors/http-error.js +10 -0
- package/templates/ssr-isr/lib/middleware/kernel.js +85 -0
- package/templates/ssr-isr/lib/middleware/pipeline.js +148 -0
- package/templates/ssr-isr/lib/middleware/registry.js +85 -0
- package/templates/ssr-isr/lib/middleware/response.js +107 -0
- package/templates/ssr-isr/lib/middleware/types.d.ts +1 -0
- package/templates/ssr-isr/lib/middleware/types.js +1 -0
- package/templates/ssr-isr/lib/middleware/utils/matcher.js +13 -0
- package/templates/{static → ssr-isr}/lib/native/bundle.js +0 -17
- package/templates/{static → ssr-isr}/lib/native/dev-server.js +0 -17
- package/templates/{static → ssr-isr}/lib/native/index.js +0 -17
- package/templates/{static → ssr-isr}/lib/native/optimizer.js +0 -17
- package/templates/ssr-isr/lib/native/style-compiler.js +19 -0
- package/templates/ssr-isr/lib/plugin/loader.js +36 -0
- package/templates/ssr-isr/lib/runtime/client-runtime.js +25 -0
- package/templates/ssr-isr/lib/runtime/hmr.js +59 -0
- package/templates/ssr-isr/lib/runtime/hydrate.js +55 -0
- package/templates/ssr-isr/lib/runtime/island-hydration-client.js +146 -0
- package/templates/ssr-isr/lib/runtime/islands.js +110 -0
- package/templates/ssr-isr/lib/runtime/render.js +244 -0
- package/templates/ssr-isr/lib/server/api-routes.js +237 -0
- package/templates/ssr-isr/lib/server/api.js +108 -0
- package/templates/ssr-isr/lib/server/app.js +438 -0
- package/templates/ssr-isr/lib/server/runtimeServe.js +169 -0
- package/templates/ssr-isr/lib/server/ssr.js +202 -0
- package/templates/ssr-isr/lib/shared/log.js +64 -0
- package/templates/ssr-isr/package.json +23 -0
- package/templates/ssr-isr/server.js +128 -0
- package/templates/ssr-isr/site/pages/(index).tsx +11 -0
- package/templates/ssr-isr/site/styles/global.scss +37 -0
- package/templates/ssr-isr/tsconfig.json +39 -0
- package/templates/static/build.js +30 -18
- package/templates/static/jen.config.ts +0 -18
- package/templates/static/jenjs.d.ts +0 -18
- package/templates/static/lib/api/(hello).js +0 -17
- package/templates/static/lib/api/examples/files/[...slug].js +22 -0
- package/templates/static/lib/api/examples/hello.js +11 -0
- package/templates/static/lib/api/examples/posts/[id].js +37 -0
- package/templates/static/lib/api/examples/posts.js +37 -0
- package/templates/static/lib/api/examples/search.js +23 -0
- package/templates/static/lib/api/index.js +41 -0
- package/templates/static/lib/api/loader.js +234 -0
- package/templates/static/lib/api/router.js +259 -0
- package/templates/static/lib/assets/types.js +1 -0
- package/templates/static/lib/auth/cookie-utils.js +3 -16
- package/templates/static/lib/auth/index.js +0 -17
- package/templates/static/lib/auth/jwt.js +0 -17
- package/templates/static/lib/auth/session.js +0 -17
- package/templates/static/lib/build/asset-hashing.js +44 -36
- package/templates/static/lib/build/asset-manifest.js +16 -33
- package/templates/static/lib/build/build.js +270 -125
- package/templates/static/lib/build/bundle-analyzer-ui.js +417 -0
- package/templates/static/lib/build/bundle-analyzer.js +945 -0
- package/templates/static/lib/build/code-splitter.js +194 -0
- package/templates/static/lib/build/feature-analyzer.js +190 -0
- package/templates/static/lib/build/feature-gate.js +257 -0
- package/templates/static/lib/build/island-hydration.js +17 -35
- package/templates/static/lib/build/lazy-loader.js +322 -0
- package/templates/static/lib/build/minifier.js +40 -59
- package/templates/static/lib/build/page-renderer.js +23 -40
- package/templates/static/lib/build/production-build.js +9 -26
- package/templates/static/lib/build/rust-hashing.js +71 -0
- package/templates/static/lib/build/script-optimizer.js +285 -0
- package/templates/static/lib/build/ssg-pipeline.js +100 -106
- package/templates/static/lib/build/vercel-output.js +298 -0
- package/templates/static/lib/build-tools/build-site.js +0 -17
- package/templates/static/lib/cache/index.js +0 -17
- package/templates/static/lib/cache/memory.js +0 -17
- package/templates/static/lib/cache/redis.js +0 -17
- package/templates/static/lib/cli/banner.js +0 -17
- package/templates/static/lib/cli/templates/ssg/jen.config.js +0 -17
- package/templates/static/lib/cli/templates/ssr/jen.config.js +0 -17
- package/templates/static/lib/client/Image.js +42 -0
- package/templates/static/lib/client/Link.js +190 -0
- package/templates/static/lib/client/PWA.js +46 -0
- package/templates/static/lib/client/Seo.js +97 -0
- package/templates/static/lib/client/index.js +9 -0
- package/templates/static/lib/client/useNavigation.js +25 -0
- package/templates/static/lib/client/useRouter.js +64 -0
- package/templates/static/lib/client-routing/Link.js +17 -0
- package/templates/static/lib/client-routing/index.js +19 -0
- package/templates/static/lib/client-routing/router.js +151 -0
- package/templates/static/lib/client-routing/signal.js +147 -0
- package/templates/static/lib/compilers/esbuild-plugins.js +0 -17
- package/templates/static/lib/compilers/svelte.js +0 -17
- package/templates/static/lib/compilers/vue.js +0 -17
- package/templates/static/lib/core/config.js +0 -17
- package/templates/static/lib/core/feature-guard.js +136 -0
- package/templates/static/lib/core/features.js +99 -0
- package/templates/static/lib/core/http.js +0 -17
- package/templates/static/lib/core/layouts/index.js +10 -0
- package/templates/static/lib/core/layouts/render.js +158 -0
- package/templates/static/lib/core/layouts/scan.js +112 -0
- package/templates/static/lib/core/layouts/types.js +1 -0
- package/templates/static/lib/core/lifecycle.js +129 -0
- package/templates/static/lib/core/loader-schema.js +81 -0
- package/templates/static/lib/core/middleware-hooks.js +0 -17
- package/templates/static/lib/core/paths.js +0 -17
- package/templates/static/lib/core/routes/advanced.js +114 -0
- package/templates/static/lib/core/routes/handlers.js +181 -0
- package/templates/static/lib/core/routes/match.js +89 -17
- package/templates/static/lib/core/routes/orchestrator.js +171 -0
- package/templates/static/lib/core/routes/rendering-config.js +131 -0
- package/templates/static/lib/core/routes/scan.js +0 -17
- package/templates/static/lib/core/types.js +0 -17
- package/templates/static/lib/css/compiler.js +1 -18
- package/templates/static/lib/data-fetching/cache.js +223 -0
- package/templates/static/lib/data-fetching/client.js +202 -0
- package/templates/static/lib/data-fetching/feature-guard.js +29 -0
- package/templates/static/lib/data-fetching/graphql.js +265 -0
- package/templates/static/lib/data-fetching/index.js +57 -0
- package/templates/static/lib/data-fetching/rest.js +256 -0
- package/templates/static/lib/data-fetching/server.js +182 -0
- package/templates/static/lib/data-fetching/types.js +5 -0
- package/templates/static/lib/db/connector.js +0 -17
- package/templates/static/lib/db/drivers/jdb.js +0 -17
- package/templates/static/lib/db/drivers/sql.js +0 -17
- package/templates/static/lib/db/index.js +0 -17
- package/templates/static/lib/db/types.js +0 -17
- package/templates/static/lib/devtools/component-tree.js +106 -0
- package/templates/static/lib/devtools/devtools.js +638 -0
- package/templates/static/lib/devtools/event-bus.js +29 -0
- package/templates/static/lib/devtools/event-logger.js +67 -0
- package/templates/static/lib/devtools/index.js +9 -0
- package/templates/static/lib/devtools/integration.js +149 -0
- package/templates/static/lib/devtools/performance.js +84 -0
- package/templates/static/lib/devtools/persistence.js +57 -0
- package/templates/static/lib/devtools/plugins.js +97 -0
- package/templates/static/lib/devtools/search.js +89 -0
- package/templates/static/lib/devtools/ui.js +769 -0
- package/templates/static/lib/features/api/handler.js +10 -0
- package/templates/static/lib/features/api/index.js +5 -0
- package/templates/static/lib/features/api/types.js +4 -0
- package/templates/static/lib/features/middleware/compiled.js +7 -0
- package/templates/static/lib/features/middleware/index.js +5 -0
- package/templates/static/lib/features/middleware/types.js +4 -0
- package/templates/static/lib/fonts/index.js +46 -0
- package/templates/static/lib/fonts/inject.js +125 -0
- package/templates/static/lib/fonts/loader.js +196 -0
- package/templates/static/lib/fonts/types.js +1 -0
- package/templates/static/lib/graphql/index.js +1 -18
- package/templates/static/lib/graphql/resolvers.js +20 -13
- package/templates/static/lib/graphql/schema.js +0 -17
- package/templates/static/lib/i18n/index.js +7 -19
- package/templates/static/lib/import/jen-import.js +1 -18
- package/templates/static/lib/index.js +79 -125
- package/templates/static/lib/jdb/engine.js +0 -17
- package/templates/static/lib/jdb/index.js +1 -18
- package/templates/static/lib/jdb/types.js +0 -17
- package/templates/static/lib/jdb/utils.js +0 -17
- package/templates/static/lib/middleware/builtins/cors.js +3 -16
- package/templates/static/lib/middleware/context.js +0 -17
- package/templates/static/lib/middleware/kernel.js +117 -25
- package/templates/static/lib/middleware/pipeline.js +0 -17
- package/templates/static/lib/middleware/registry.js +0 -17
- package/templates/static/lib/middleware/response.js +0 -17
- package/templates/static/lib/plugin/examples/analytics-plugin.js +183 -0
- package/templates/static/lib/plugin/examples/cdn-upload-plugin.js +94 -0
- package/templates/static/lib/plugin/loader.js +0 -17
- package/templates/static/lib/plugin/plugin-manager.js +177 -0
- package/templates/static/lib/plugin/types.js +28 -0
- package/templates/static/lib/runtime/client-runtime.js +0 -17
- package/templates/static/lib/runtime/hmr.js +0 -17
- package/templates/static/lib/runtime/hydrate.js +0 -17
- package/templates/static/lib/runtime/island-hydration-client.js +0 -17
- package/templates/static/lib/runtime/islands.js +0 -17
- package/templates/static/lib/runtime/render.js +208 -50
- package/templates/static/lib/security/security-config.js +60 -0
- package/templates/static/lib/security/security-middleware.js +229 -0
- package/templates/static/lib/server/api-routes.js +153 -43
- package/templates/static/lib/server/api.js +0 -17
- package/templates/static/lib/server/app.js +539 -223
- package/templates/static/lib/server/isr.js +365 -0
- package/templates/static/lib/server/runtimeServe.js +31 -24
- package/templates/static/lib/server/ssr.js +98 -22
- package/templates/static/lib/server-actions/handler.js +180 -0
- package/templates/static/lib/server-actions/index.js +19 -0
- package/templates/static/lib/server-actions/middleware.js +146 -0
- package/templates/static/lib/server-actions/scan.js +152 -0
- package/templates/static/lib/server-actions/types.js +1 -0
- package/templates/static/lib/server-actions/validators.js +156 -0
- package/templates/static/lib/shared/log.js +19 -20
- package/templates/static/lib/telemetry/api/rate-limiter.js +32 -0
- package/templates/static/lib/telemetry/api/validator.js +67 -0
- package/templates/static/lib/telemetry/client.js +121 -0
- package/templates/static/lib/telemetry/tests/rate-limiter.test.js +46 -0
- package/templates/static/lib/telemetry/tests/validator.test.js +62 -0
- package/templates/static/lib/vendor/glob/glob.js +4766 -0
- package/templates/static/lib/vendor/preact/LICENSE +21 -0
- package/templates/static/lib/vendor/preact/preact.module.js +797 -0
- package/templates/static/lib/vendor/sass/sass.node.mjs +212 -0
- package/templates/static/package.json +4 -0
- package/templates/static/server.js +22 -22
- package/templates/static/site/(home).tsx +0 -18
- package/templates/static/tsconfig.json +5 -1
- package/templates/static/.esbuild/jen.config.js +0 -19
- package/templates/static/lib/build/asset-hashing.d.ts +0 -10
- package/templates/static/lib/build/asset-manifest.d.ts +0 -11
- package/templates/static/lib/build/minifier.d.ts +0 -20
- package/templates/static/lib/build/page-renderer.d.ts +0 -17
- package/templates/static/lib/build/production-build.d.ts +0 -10
- package/templates/static/lib/build/ssg-pipeline.d.ts +0 -15
- package/templates/static/lib/middleware/errors/http-error.js +0 -27
- package/templates/static/lib/middleware/types.js +0 -18
- package/templates/static/lib/middleware/utils/matcher.js +0 -30
- package/templates/static/lib/native/style-compiler.js +0 -36
- /package/templates/{static → ssr-isr}/lib/api/(hello).d.ts +0 -0
- /package/templates/{static → ssr-isr}/lib/auth/cookie-utils.d.ts +0 -0
- /package/templates/{static → ssr-isr}/lib/auth/index.d.ts +0 -0
- /package/templates/{static → ssr-isr}/lib/auth/jwt.d.ts +0 -0
- /package/templates/{static → ssr-isr}/lib/auth/session.d.ts +0 -0
- /package/templates/{static → ssr-isr}/lib/build-tools/build-site.d.ts +0 -0
- /package/templates/{static → ssr-isr}/lib/cache/index.d.ts +0 -0
- /package/templates/{static → ssr-isr}/lib/cache/memory.d.ts +0 -0
- /package/templates/{static → ssr-isr}/lib/cache/redis.d.ts +0 -0
- /package/templates/{static → ssr-isr}/lib/cli/banner.d.ts +0 -0
- /package/templates/{static → ssr-isr}/lib/cli/templates/ssg/jen.config.d.ts +0 -0
- /package/templates/{static → ssr-isr}/lib/cli/templates/ssg/site/index.d.ts +0 -0
- /package/templates/{static → ssr-isr}/lib/cli/templates/ssr/jen.config.d.ts +0 -0
- /package/templates/{static → ssr-isr}/lib/cli/templates/ssr/site/index.d.ts +0 -0
- /package/templates/{static → ssr-isr}/lib/compilers/esbuild-plugins.d.ts +0 -0
- /package/templates/{static → ssr-isr}/lib/compilers/svelte.d.ts +0 -0
- /package/templates/{static → ssr-isr}/lib/compilers/vue.d.ts +0 -0
- /package/templates/{static → ssr-isr}/lib/core/config.d.ts +0 -0
- /package/templates/{static/lib/middleware/types.d.ts → ssr-isr/lib/core/config.js} +0 -0
- /package/templates/{static → ssr-isr}/lib/core/http.d.ts +0 -0
- /package/templates/{static → ssr-isr}/lib/core/middleware-hooks.d.ts +0 -0
- /package/templates/{static → ssr-isr}/lib/core/paths.d.ts +0 -0
- /package/templates/{static → ssr-isr}/lib/core/routes/match.d.ts +0 -0
- /package/templates/{static → ssr-isr}/lib/core/routes/scan.d.ts +0 -0
- /package/templates/{static → ssr-isr}/lib/core/types.d.ts +0 -0
- /package/templates/{static → ssr-isr}/lib/css/compiler.d.ts +0 -0
- /package/templates/{static → ssr-isr}/lib/db/connector.d.ts +0 -0
- /package/templates/{static → ssr-isr}/lib/db/drivers/jdb.d.ts +0 -0
- /package/templates/{static → ssr-isr}/lib/db/drivers/sql.d.ts +0 -0
- /package/templates/{static → ssr-isr}/lib/db/index.d.ts +0 -0
- /package/templates/{static → ssr-isr}/lib/db/types.d.ts +0 -0
- /package/templates/{static → ssr-isr}/lib/graphql/index.d.ts +0 -0
- /package/templates/{static → ssr-isr}/lib/graphql/resolvers.d.ts +0 -0
- /package/templates/{static → ssr-isr}/lib/graphql/schema.d.ts +0 -0
- /package/templates/{static → ssr-isr}/lib/i18n/index.d.ts +0 -0
- /package/templates/{static → ssr-isr}/lib/import/jen-import.d.ts +0 -0
- /package/templates/{static → ssr-isr}/lib/index.d.ts +0 -0
- /package/templates/{static → ssr-isr}/lib/jdb/engine.d.ts +0 -0
- /package/templates/{static → ssr-isr}/lib/jdb/index.d.ts +0 -0
- /package/templates/{static → ssr-isr}/lib/jdb/types.d.ts +0 -0
- /package/templates/{static → ssr-isr}/lib/jdb/utils.d.ts +0 -0
- /package/templates/{static → ssr-isr}/lib/middleware/builtins/body-parser.d.ts +0 -0
- /package/templates/{static → ssr-isr}/lib/middleware/builtins/cors.d.ts +0 -0
- /package/templates/{static → ssr-isr}/lib/middleware/builtins/logger.d.ts +0 -0
- /package/templates/{static → ssr-isr}/lib/middleware/builtins/rate-limit.d.ts +0 -0
- /package/templates/{static → ssr-isr}/lib/middleware/builtins/request-id.d.ts +0 -0
- /package/templates/{static → ssr-isr}/lib/middleware/builtins/security-headers.d.ts +0 -0
- /package/templates/{static → ssr-isr}/lib/middleware/context.d.ts +0 -0
- /package/templates/{static → ssr-isr}/lib/middleware/decorators.d.ts +0 -0
- /package/templates/{static → ssr-isr}/lib/middleware/errors/handler.d.ts +0 -0
- /package/templates/{static → ssr-isr}/lib/middleware/errors/http-error.d.ts +0 -0
- /package/templates/{static → ssr-isr}/lib/middleware/kernel.d.ts +0 -0
- /package/templates/{static → ssr-isr}/lib/middleware/pipeline.d.ts +0 -0
- /package/templates/{static → ssr-isr}/lib/middleware/registry.d.ts +0 -0
- /package/templates/{static → ssr-isr}/lib/middleware/response.d.ts +0 -0
- /package/templates/{static → ssr-isr}/lib/middleware/utils/matcher.d.ts +0 -0
- /package/templates/{static → ssr-isr}/lib/native/bundle.d.ts +0 -0
- /package/templates/{static → ssr-isr}/lib/native/dev-server.d.ts +0 -0
- /package/templates/{static → ssr-isr}/lib/native/index.d.ts +0 -0
- /package/templates/{static → ssr-isr}/lib/native/optimizer.d.ts +0 -0
- /package/templates/{static → ssr-isr}/lib/native/style-compiler.d.ts +0 -0
- /package/templates/{static → ssr-isr}/lib/plugin/loader.d.ts +0 -0
- /package/templates/{static → ssr-isr}/lib/runtime/client-runtime.d.ts +0 -0
- /package/templates/{static → ssr-isr}/lib/runtime/hmr.d.ts +0 -0
- /package/templates/{static → ssr-isr}/lib/runtime/hydrate.d.ts +0 -0
- /package/templates/{static → ssr-isr}/lib/runtime/island-hydration-client.d.ts +0 -0
- /package/templates/{static → ssr-isr}/lib/runtime/islands.d.ts +0 -0
- /package/templates/{static → ssr-isr}/lib/runtime/render.d.ts +0 -0
- /package/templates/{static → ssr-isr}/lib/server/api-routes.d.ts +0 -0
- /package/templates/{static → ssr-isr}/lib/server/api.d.ts +0 -0
- /package/templates/{static → ssr-isr}/lib/server/app.d.ts +0 -0
- /package/templates/{static → ssr-isr}/lib/server/runtimeServe.d.ts +0 -0
- /package/templates/{static → ssr-isr}/lib/server/ssr.d.ts +0 -0
- /package/templates/{static → ssr-isr}/lib/shared/log.d.ts +0 -0
|
@@ -1,133 +1,87 @@
|
|
|
1
1
|
/*
|
|
2
|
-
*
|
|
3
|
-
* Copyright (C) 2026 oopsio
|
|
2
|
+
* Jen.js Public API - Minimal tree-shakeable barrel exports
|
|
4
3
|
*
|
|
5
|
-
* This
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
* (at your option) any later version.
|
|
4
|
+
* This file exports only the essential public API surface needed by applications.
|
|
5
|
+
* All internal utilities, advanced features, and implementation details are intentionally
|
|
6
|
+
* excluded to enable tree-shaking and keep bundle sizes minimal for typical use cases.
|
|
9
7
|
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
* GNU General Public License for more details.
|
|
14
|
-
*
|
|
15
|
-
* You should have received a copy of the GNU General Public License
|
|
16
|
-
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
8
|
+
* Total exports: ~30 (core types, functions, and components)
|
|
9
|
+
* Previous file: 217 lines exporting everything
|
|
10
|
+
* This file: ~100 lines exporting only public API
|
|
17
11
|
*/
|
|
18
12
|
// ============================================================================
|
|
19
|
-
//
|
|
20
|
-
// ============================================================================
|
|
21
|
-
//
|
|
22
|
-
export
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
//
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
export {
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
export {
|
|
34
|
-
|
|
13
|
+
// ROUTING (4 exports)
|
|
14
|
+
// ============================================================================
|
|
15
|
+
// Core routing functions for matching routes and scanning file system
|
|
16
|
+
export { matchRoute } from "./core/routes/match.js";
|
|
17
|
+
export { scanRoutes } from "./core/routes/scan.js";
|
|
18
|
+
// ============================================================================
|
|
19
|
+
// SERVER / APPLICATION (1 export)
|
|
20
|
+
// ============================================================================
|
|
21
|
+
// Main application factory for creating the HTTP handler
|
|
22
|
+
export { createApp } from "./server/app.js";
|
|
23
|
+
// ============================================================================
|
|
24
|
+
// BUILD & STATIC GENERATION (1 export)
|
|
25
|
+
// ============================================================================
|
|
26
|
+
// Primary build function for static site generation
|
|
27
|
+
export { buildSite } from "./build/build.js";
|
|
28
|
+
// ============================================================================
|
|
29
|
+
// CLIENT COMPONENTS (5 exports + types)
|
|
30
|
+
// ============================================================================
|
|
31
|
+
// Reusable Preact components for common patterns
|
|
32
|
+
export { Image, Seo, PWA } from "./client/index.js";
|
|
33
|
+
export { useRouter, useNavigation } from "./client/index.js";
|
|
34
|
+
// ============================================================================
|
|
35
|
+
// MIDDLEWARE & REQUEST HANDLING (7 exports)
|
|
36
|
+
// ============================================================================
|
|
37
|
+
// Core middleware types and HTTP utilities for route handlers
|
|
38
|
+
// ============================================================================
|
|
39
|
+
// TYPED LOADERS (5 exports)
|
|
40
|
+
// ============================================================================
|
|
41
|
+
// Type-safe data loading with compile-time validation
|
|
35
42
|
export {
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
} from "./
|
|
41
|
-
//
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
43
|
+
defineLoader,
|
|
44
|
+
defineMiddleware,
|
|
45
|
+
validateLoaderData,
|
|
46
|
+
} from "./core/loader-schema.js";
|
|
47
|
+
export { parseCookies, headersToObject } from "./core/http.js";
|
|
48
|
+
// ============================================================================
|
|
49
|
+
// PLUGINS (3 exports)
|
|
50
|
+
// ============================================================================
|
|
51
|
+
// Plugin system for extending framework functionality
|
|
52
|
+
export {
|
|
53
|
+
getPluginManager,
|
|
54
|
+
resetPluginManager,
|
|
55
|
+
} from "./plugin/plugin-manager.js";
|
|
56
|
+
export { HookStage } from "./plugin/types.js";
|
|
57
|
+
// ============================================================================
|
|
58
|
+
// RUNTIME & ISLANDS (2 exports)
|
|
59
|
+
// ============================================================================
|
|
60
|
+
// Client-side hydration and island components for interactivity
|
|
61
|
+
export { Island } from "./runtime/islands.js";
|
|
62
|
+
// ============================================================================
|
|
63
|
+
// CLIENT ROUTING & STATE (8 exports + types)
|
|
64
|
+
// ============================================================================
|
|
65
|
+
// Minimal client-side router and signal-based reactive state
|
|
52
66
|
export {
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
} from "./compilers/esbuild-plugins.js";
|
|
59
|
-
// Core
|
|
60
|
-
export * from "./core/config.js";
|
|
61
|
-
export * from "./core/http.js";
|
|
62
|
-
export * from "./core/paths.js";
|
|
63
|
-
export * from "./core/types.js";
|
|
64
|
-
export * from "./core/routes/match.js";
|
|
65
|
-
export * from "./core/routes/scan.js";
|
|
66
|
-
export * from "./core/middleware-hooks.js";
|
|
67
|
-
// CSS
|
|
68
|
-
export * from "./css/compiler.js";
|
|
69
|
-
// Database
|
|
70
|
-
export * from "./db/index.js";
|
|
71
|
-
export * from "./db/types.js";
|
|
72
|
-
export * from "./db/connector.js";
|
|
73
|
-
export * from "./db/drivers/sql.js";
|
|
74
|
-
export * from "./db/drivers/jdb.js";
|
|
75
|
-
// GraphQL
|
|
76
|
-
export * from "./graphql/index.js";
|
|
77
|
-
export * from "./graphql/schema.js";
|
|
78
|
-
export * from "./graphql/resolvers.js";
|
|
79
|
-
// i18n
|
|
80
|
-
export * from "./i18n/index.js";
|
|
81
|
-
// Import utilities
|
|
67
|
+
navigate,
|
|
68
|
+
getCurrentRoute,
|
|
69
|
+
onRouteChange,
|
|
70
|
+
initRouter,
|
|
71
|
+
} from "./client-routing/router.js";
|
|
82
72
|
export {
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
export
|
|
92
|
-
|
|
93
|
-
//
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
export
|
|
97
|
-
export
|
|
98
|
-
export * from "./middleware/kernel.js";
|
|
99
|
-
export * from "./middleware/registry.js";
|
|
100
|
-
export * from "./middleware/decorators.js";
|
|
101
|
-
export * from "./middleware/builtins/logger.js";
|
|
102
|
-
export * from "./middleware/builtins/request-id.js";
|
|
103
|
-
export * from "./middleware/builtins/security-headers.js";
|
|
104
|
-
export * from "./middleware/builtins/cors.js";
|
|
105
|
-
export * from "./middleware/builtins/body-parser.js";
|
|
106
|
-
export * from "./middleware/builtins/rate-limit.js";
|
|
107
|
-
export * from "./middleware/errors/http-error.js";
|
|
108
|
-
export * from "./middleware/errors/handler.js";
|
|
109
|
-
export * from "./middleware/utils/matcher.js";
|
|
110
|
-
// Native
|
|
111
|
-
export * from "./native/index.js";
|
|
112
|
-
export * from "./native/bundle.js";
|
|
113
|
-
export * from "./native/dev-server.js";
|
|
114
|
-
export * from "./native/optimizer.js";
|
|
115
|
-
export * from "./native/style-compiler.js";
|
|
116
|
-
// Plugin
|
|
117
|
-
export * from "./plugin/loader.js";
|
|
118
|
-
// Runtime
|
|
119
|
-
export * from "./runtime/render.js";
|
|
120
|
-
export * from "./runtime/client-runtime.js";
|
|
121
|
-
export * from "./runtime/hydrate.js";
|
|
122
|
-
export * from "./runtime/hmr.js";
|
|
123
|
-
export * from "./runtime/islands.js";
|
|
124
|
-
export * from "./runtime/island-hydration-client.js";
|
|
125
|
-
// Server
|
|
126
|
-
export * from "./server/app.js";
|
|
127
|
-
// Use new api-routes.ts for HTTP method handlers (replaces old api.js behavior)
|
|
128
|
-
export { tryHandleApiRoute as tryHandleApiRoute_v2 } from "./server/api-routes.js";
|
|
129
|
-
// Keep old api.js exports for backward compatibility
|
|
130
|
-
export { tryHandleApiRoute } from "./server/api.js";
|
|
131
|
-
export * from "./server/runtimeServe.js";
|
|
132
|
-
// Shared utilities
|
|
133
|
-
export * from "./shared/log.js";
|
|
73
|
+
signal,
|
|
74
|
+
computed,
|
|
75
|
+
bindSignal,
|
|
76
|
+
bindInput,
|
|
77
|
+
batch,
|
|
78
|
+
watch,
|
|
79
|
+
createStore,
|
|
80
|
+
} from "./client-routing/signal.js";
|
|
81
|
+
export { Link } from "./client-routing/Link.js";
|
|
82
|
+
// ============================================================================
|
|
83
|
+
// UTILITIES (2 exports)
|
|
84
|
+
// ============================================================================
|
|
85
|
+
// Common utilities for logging and framework usage
|
|
86
|
+
export { log } from "./shared/log.js";
|
|
87
|
+
export { jenImport } from "./import/jen-import.js";
|
|
@@ -1,20 +1,3 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* This file is part of Jen.js.
|
|
3
|
-
* Copyright (C) 2026 oopsio
|
|
4
|
-
*
|
|
5
|
-
* This program is free software: you can redistribute it and/or modify
|
|
6
|
-
* it under the terms of the GNU General Public License as published by
|
|
7
|
-
* the Free Software Foundation, either version 3 of the License, or
|
|
8
|
-
* (at your option) any later version.
|
|
9
|
-
*
|
|
10
|
-
* This program is distributed in the hope that it will be useful,
|
|
11
|
-
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
12
|
-
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
13
|
-
* GNU General Public License for more details.
|
|
14
|
-
*
|
|
15
|
-
* You should have received a copy of the GNU General Public License
|
|
16
|
-
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
17
|
-
*/
|
|
18
1
|
import path from "path";
|
|
19
2
|
import {
|
|
20
3
|
ensureDir,
|
|
@@ -1,20 +1,3 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* This file is part of Jen.js.
|
|
3
|
-
* Copyright (C) 2026 oopsio
|
|
4
|
-
*
|
|
5
|
-
* This program is free software: you can redistribute it and/or modify
|
|
6
|
-
* it under the terms of the GNU General Public License as published by
|
|
7
|
-
* the Free Software Foundation, either version 3 of the License, or
|
|
8
|
-
* (at your option) any later version.
|
|
9
|
-
*
|
|
10
|
-
* This program is distributed in the hope that it will be useful,
|
|
11
|
-
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
12
|
-
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
13
|
-
* GNU General Public License for more details.
|
|
14
|
-
*
|
|
15
|
-
* You should have received a copy of the GNU General Public License
|
|
16
|
-
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
17
|
-
*/
|
|
18
1
|
/**
|
|
19
2
|
* JDB (Jen Database) - A lightweight embedded JSON database for Jen.js applications.
|
|
20
3
|
*
|
|
@@ -30,7 +13,7 @@
|
|
|
30
13
|
* - Simple JSON file format for easy inspection and migration
|
|
31
14
|
*
|
|
32
15
|
* @example
|
|
33
|
-
* import { JDBEngine, type ICollection, type Document } from '
|
|
16
|
+
* import { JDBEngine, type ICollection, type Document } from '../jdb';
|
|
34
17
|
*
|
|
35
18
|
* interface User extends Document {
|
|
36
19
|
* name: string;
|
|
@@ -1,18 +1 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* This file is part of Jen.js.
|
|
3
|
-
* Copyright (C) 2026 oopsio
|
|
4
|
-
*
|
|
5
|
-
* This program is free software: you can redistribute it and/or modify
|
|
6
|
-
* it under the terms of the GNU General Public License as published by
|
|
7
|
-
* the Free Software Foundation, either version 3 of the License, or
|
|
8
|
-
* (at your option) any later version.
|
|
9
|
-
*
|
|
10
|
-
* This program is distributed in the hope that it will be useful,
|
|
11
|
-
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
12
|
-
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
13
|
-
* GNU General Public License for more details.
|
|
14
|
-
*
|
|
15
|
-
* You should have received a copy of the GNU General Public License
|
|
16
|
-
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
17
|
-
*/
|
|
18
1
|
export {};
|
|
@@ -1,20 +1,3 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* This file is part of Jen.js.
|
|
3
|
-
* Copyright (C) 2026 oopsio
|
|
4
|
-
*
|
|
5
|
-
* This program is free software: you can redistribute it and/or modify
|
|
6
|
-
* it under the terms of the GNU General Public License as published by
|
|
7
|
-
* the Free Software Foundation, either version 3 of the License, or
|
|
8
|
-
* (at your option) any later version.
|
|
9
|
-
*
|
|
10
|
-
* This program is distributed in the hope that it will be useful,
|
|
11
|
-
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
12
|
-
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
13
|
-
* GNU General Public License for more details.
|
|
14
|
-
*
|
|
15
|
-
* You should have received a copy of the GNU General Public License
|
|
16
|
-
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
17
|
-
*/
|
|
18
1
|
import fs from "fs/promises";
|
|
19
2
|
import crypto from "crypto";
|
|
20
3
|
/**
|
|
@@ -1,19 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
*
|
|
3
|
-
*
|
|
4
|
-
*
|
|
5
|
-
* This program is free software: you can redistribute it and/or modify
|
|
6
|
-
* it under the terms of the GNU General Public License as published by
|
|
7
|
-
* the Free Software Foundation, either version 3 of the License, or
|
|
8
|
-
* (at your option) any later version.
|
|
9
|
-
*
|
|
10
|
-
* This program is distributed in the hope that it will be useful,
|
|
11
|
-
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
12
|
-
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
13
|
-
* GNU General Public License for more details.
|
|
14
|
-
*
|
|
15
|
-
* You should have received a copy of the GNU General Public License
|
|
16
|
-
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
1
|
+
/**
|
|
2
|
+
* CORS middleware with security defaults
|
|
3
|
+
* Prevents insecure origin sharing with credentials
|
|
17
4
|
*/
|
|
18
5
|
export function cors(options = {}) {
|
|
19
6
|
const defaults = {
|
|
@@ -1,20 +1,3 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* This file is part of Jen.js.
|
|
3
|
-
* Copyright (C) 2026 oopsio
|
|
4
|
-
*
|
|
5
|
-
* This program is free software: you can redistribute it and/or modify
|
|
6
|
-
* it under the terms of the GNU General Public License as published by
|
|
7
|
-
* the Free Software Foundation, either version 3 of the License, or
|
|
8
|
-
* (at your option) any later version.
|
|
9
|
-
*
|
|
10
|
-
* This program is distributed in the hope that it will be useful,
|
|
11
|
-
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
12
|
-
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
13
|
-
* GNU General Public License for more details.
|
|
14
|
-
*
|
|
15
|
-
* You should have received a copy of the GNU General Public License
|
|
16
|
-
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
17
|
-
*/
|
|
18
1
|
import { ResponseBuilder } from "./response.js";
|
|
19
2
|
/**
|
|
20
3
|
* Request context object passed through the middleware chain.
|
|
@@ -1,23 +1,7 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* This file is part of Jen.js.
|
|
3
|
-
* Copyright (C) 2026 oopsio
|
|
4
|
-
*
|
|
5
|
-
* This program is free software: you can redistribute it and/or modify
|
|
6
|
-
* it under the terms of the GNU General Public License as published by
|
|
7
|
-
* the Free Software Foundation, either version 3 of the License, or
|
|
8
|
-
* (at your option) any later version.
|
|
9
|
-
*
|
|
10
|
-
* This program is distributed in the hope that it will be useful,
|
|
11
|
-
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
12
|
-
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
13
|
-
* GNU General Public License for more details.
|
|
14
|
-
*
|
|
15
|
-
* You should have received a copy of the GNU General Public License
|
|
16
|
-
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
17
|
-
*/
|
|
18
1
|
import { Pipeline } from "./pipeline.js";
|
|
19
2
|
import { MiddlewareRegistry } from "./registry.js";
|
|
20
3
|
import { Context } from "./context.js";
|
|
4
|
+
import { log } from "../shared/log.js";
|
|
21
5
|
/**
|
|
22
6
|
* Core HTTP request handler that manages middleware execution and request context.
|
|
23
7
|
*
|
|
@@ -61,6 +45,7 @@ export class Kernel {
|
|
|
61
45
|
/**
|
|
62
46
|
* Processes an HTTP request through the global middleware pipeline.
|
|
63
47
|
* Creates a Context wrapping the request/response, composes middlewares, and executes them.
|
|
48
|
+
* Catches any uncaught errors and sends a safe 500 response.
|
|
64
49
|
*
|
|
65
50
|
* @param req Node.js IncomingMessage (HTTP request object)
|
|
66
51
|
* @param res Node.js ServerResponse (HTTP response object)
|
|
@@ -73,14 +58,84 @@ export class Kernel {
|
|
|
73
58
|
* });
|
|
74
59
|
*/
|
|
75
60
|
async handle(req, res) {
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
61
|
+
try {
|
|
62
|
+
const ctx = new Context(req, res);
|
|
63
|
+
const fn = Pipeline.compose(this.globalMiddleware);
|
|
64
|
+
await fn(ctx, async () => {});
|
|
65
|
+
} catch (err) {
|
|
66
|
+
// Uncaught error in middleware pipeline
|
|
67
|
+
log.error(`[Kernel] Uncaught error: ${err}`);
|
|
68
|
+
if (err && err.stack) {
|
|
69
|
+
log.error(`Stack: ${err.stack}`);
|
|
70
|
+
}
|
|
71
|
+
// If headers already sent, destroy socket
|
|
72
|
+
if (res.headersSent) {
|
|
73
|
+
log.error("[Kernel] Headers already sent, destroying socket");
|
|
74
|
+
if (res.socket && !res.socket.destroyed) {
|
|
75
|
+
res.socket.destroy();
|
|
76
|
+
}
|
|
77
|
+
return;
|
|
78
|
+
}
|
|
79
|
+
// Try to send a safe 500 response
|
|
80
|
+
try {
|
|
81
|
+
res.statusCode = 500;
|
|
82
|
+
res.setHeader("content-type", "text/html; charset=utf-8");
|
|
83
|
+
res.setHeader("cache-control", "no-store, no-cache, must-revalidate");
|
|
84
|
+
res.end(`<!DOCTYPE html>
|
|
85
|
+
<html lang="en">
|
|
86
|
+
<head>
|
|
87
|
+
<meta charset="UTF-8">
|
|
88
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
89
|
+
<title>500 - Internal Server Error</title>
|
|
90
|
+
<style>
|
|
91
|
+
body {
|
|
92
|
+
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
|
|
93
|
+
background: #f5f5f5;
|
|
94
|
+
margin: 0;
|
|
95
|
+
padding: 20px;
|
|
96
|
+
}
|
|
97
|
+
.container {
|
|
98
|
+
max-width: 600px;
|
|
99
|
+
margin: 60px auto;
|
|
100
|
+
background: white;
|
|
101
|
+
padding: 40px;
|
|
102
|
+
border-radius: 8px;
|
|
103
|
+
box-shadow: 0 2px 8px rgba(0,0,0,0.1);
|
|
104
|
+
}
|
|
105
|
+
h1 {
|
|
106
|
+
color: #d32f2f;
|
|
107
|
+
margin: 0 0 20px 0;
|
|
108
|
+
font-size: 32px;
|
|
109
|
+
}
|
|
110
|
+
p {
|
|
111
|
+
color: #666;
|
|
112
|
+
line-height: 1.6;
|
|
113
|
+
margin: 10px 0;
|
|
114
|
+
}
|
|
115
|
+
</style>
|
|
116
|
+
</head>
|
|
117
|
+
<body>
|
|
118
|
+
<div class="container">
|
|
119
|
+
<h1>500 - Internal Server Error</h1>
|
|
120
|
+
<p>The server encountered an unexpected error while processing your request.</p>
|
|
121
|
+
<p>Our team has been notified. Please try again later.</p>
|
|
122
|
+
</div>
|
|
123
|
+
</body>
|
|
124
|
+
</html>`);
|
|
125
|
+
} catch (e) {
|
|
126
|
+
log.error(`[Kernel] Failed to send error response: ${e}`);
|
|
127
|
+
// Last resort: destroy socket
|
|
128
|
+
if (res.socket && !res.socket.destroyed) {
|
|
129
|
+
res.socket.destroy();
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
}
|
|
79
133
|
}
|
|
80
134
|
/**
|
|
81
135
|
* Processes a request through global middleware plus a registered middleware group.
|
|
82
136
|
* Retrieves middleware from the registry by group name and composes them with global middleware.
|
|
83
137
|
* Useful for route-specific or feature-specific middleware chains.
|
|
138
|
+
* Catches any uncaught errors and sends a safe 500 response.
|
|
84
139
|
*
|
|
85
140
|
* @param req Node.js IncomingMessage
|
|
86
141
|
* @param res Node.js ServerResponse
|
|
@@ -93,10 +148,47 @@ export class Kernel {
|
|
|
93
148
|
* await kernel.handleWithGroup(req, res, "apiMiddleware");
|
|
94
149
|
*/
|
|
95
150
|
async handleWithGroup(req, res, groupName) {
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
151
|
+
try {
|
|
152
|
+
const ctx = new Context(req, res);
|
|
153
|
+
const registry = MiddlewareRegistry.get();
|
|
154
|
+
const groupMw = registry.getGroup(groupName);
|
|
155
|
+
const fn = Pipeline.compose([...this.globalMiddleware, ...groupMw]);
|
|
156
|
+
await fn(ctx, async () => {});
|
|
157
|
+
} catch (err) {
|
|
158
|
+
// Uncaught error in middleware pipeline
|
|
159
|
+
log.error(
|
|
160
|
+
`[Kernel] Uncaught error in middleware group "${groupName}": ${err}`,
|
|
161
|
+
);
|
|
162
|
+
if (err && err.stack) {
|
|
163
|
+
log.error(`Stack: ${err.stack}`);
|
|
164
|
+
}
|
|
165
|
+
// If headers already sent, destroy socket
|
|
166
|
+
if (res.headersSent) {
|
|
167
|
+
log.error("[Kernel] Headers already sent, destroying socket");
|
|
168
|
+
if (res.socket && !res.socket.destroyed) {
|
|
169
|
+
res.socket.destroy();
|
|
170
|
+
}
|
|
171
|
+
return;
|
|
172
|
+
}
|
|
173
|
+
// Try to send a safe 500 response
|
|
174
|
+
try {
|
|
175
|
+
res.statusCode = 500;
|
|
176
|
+
res.setHeader("content-type", "application/json");
|
|
177
|
+
res.setHeader("cache-control", "no-store, no-cache, must-revalidate");
|
|
178
|
+
res.end(
|
|
179
|
+
JSON.stringify({
|
|
180
|
+
error: "Internal Server Error",
|
|
181
|
+
message:
|
|
182
|
+
"An unexpected error occurred while processing your request.",
|
|
183
|
+
}),
|
|
184
|
+
);
|
|
185
|
+
} catch (e) {
|
|
186
|
+
log.error(`[Kernel] Failed to send error response: ${e}`);
|
|
187
|
+
// Last resort: destroy socket
|
|
188
|
+
if (res.socket && !res.socket.destroyed) {
|
|
189
|
+
res.socket.destroy();
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
}
|
|
101
193
|
}
|
|
102
194
|
}
|
|
@@ -1,20 +1,3 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* This file is part of Jen.js.
|
|
3
|
-
* Copyright (C) 2026 oopsio
|
|
4
|
-
*
|
|
5
|
-
* This program is free software: you can redistribute it and/or modify
|
|
6
|
-
* it under the terms of the GNU General Public License as published by
|
|
7
|
-
* the Free Software Foundation, either version 3 of the License, or
|
|
8
|
-
* (at your option) any later version.
|
|
9
|
-
*
|
|
10
|
-
* This program is distributed in the hope that it will be useful,
|
|
11
|
-
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
12
|
-
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
13
|
-
* GNU General Public License for more details.
|
|
14
|
-
*
|
|
15
|
-
* You should have received a copy of the GNU General Public License
|
|
16
|
-
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
17
|
-
*/
|
|
18
1
|
/**
|
|
19
2
|
* Middleware composition and execution engine.
|
|
20
3
|
* Composes multiple middleware functions into a single callable function.
|
|
@@ -1,20 +1,3 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* This file is part of Jen.js.
|
|
3
|
-
* Copyright (C) 2026 oopsio
|
|
4
|
-
*
|
|
5
|
-
* This program is free software: you can redistribute it and/or modify
|
|
6
|
-
* it under the terms of the GNU General Public License as published by
|
|
7
|
-
* the Free Software Foundation, either version 3 of the License, or
|
|
8
|
-
* (at your option) any later version.
|
|
9
|
-
*
|
|
10
|
-
* This program is distributed in the hope that it will be useful,
|
|
11
|
-
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
12
|
-
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
13
|
-
* GNU General Public License for more details.
|
|
14
|
-
*
|
|
15
|
-
* You should have received a copy of the GNU General Public License
|
|
16
|
-
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
17
|
-
*/
|
|
18
1
|
/**
|
|
19
2
|
* Global registry for named middleware and middleware groups.
|
|
20
3
|
* Enables reusable middleware composition patterns where middlewares are registered once
|
|
@@ -1,20 +1,3 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* This file is part of Jen.js.
|
|
3
|
-
* Copyright (C) 2026 oopsio
|
|
4
|
-
*
|
|
5
|
-
* This program is free software: you can redistribute it and/or modify
|
|
6
|
-
* it under the terms of the GNU General Public License as published by
|
|
7
|
-
* the Free Software Foundation, either version 3 of the License, or
|
|
8
|
-
* (at your option) any later version.
|
|
9
|
-
*
|
|
10
|
-
* This program is distributed in the hope that it will be useful,
|
|
11
|
-
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
12
|
-
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
13
|
-
* GNU General Public License for more details.
|
|
14
|
-
*
|
|
15
|
-
* You should have received a copy of the GNU General Public License
|
|
16
|
-
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
17
|
-
*/
|
|
18
1
|
/**
|
|
19
2
|
* Fluent builder for constructing HTTP responses.
|
|
20
3
|
* Provides a chainable API for setting status codes, headers, body, and content type.
|