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,29 +1,66 @@
|
|
|
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 { existsSync } from "node:fs";
|
|
19
2
|
import { join, basename } from "node:path";
|
|
20
3
|
import esbuild from "esbuild";
|
|
21
4
|
import { pathToFileURL } from "node:url";
|
|
5
|
+
/** Default max request body size: 10MB. */
|
|
6
|
+
export const DEFAULT_MAX_BODY_SIZE = 10 * 1024 * 1024;
|
|
22
7
|
/** Cache directory for transpiled API routes. */
|
|
23
8
|
const apiCacheDir = join(process.cwd(), "node_modules", ".jen", "api-cache");
|
|
9
|
+
/**
|
|
10
|
+
* Coerce query parameter value to appropriate type.
|
|
11
|
+
* - "true" / "false" → boolean
|
|
12
|
+
* - numeric strings → number
|
|
13
|
+
* - empty string → null
|
|
14
|
+
* - otherwise → string
|
|
15
|
+
*
|
|
16
|
+
* @param value - Raw query string value
|
|
17
|
+
* @returns Coerced value
|
|
18
|
+
*/
|
|
19
|
+
function coerceQueryValue(value) {
|
|
20
|
+
if (value === "true") return true;
|
|
21
|
+
if (value === "false") return false;
|
|
22
|
+
if (value === "") return null;
|
|
23
|
+
const num = Number(value);
|
|
24
|
+
if (!isNaN(num) && value.trim() !== "") return num;
|
|
25
|
+
return value;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Validate and parse query parameters with type coercion.
|
|
29
|
+
* Prevents type confusion bugs like `query.limit + 10` returning "10010" string.
|
|
30
|
+
*
|
|
31
|
+
* @param url - URL object with search parameters
|
|
32
|
+
* @returns Parsed query parameters with coerced types
|
|
33
|
+
*/
|
|
34
|
+
export function validateQuery(url) {
|
|
35
|
+
const query = {};
|
|
36
|
+
for (const [key, value] of url.searchParams.entries()) {
|
|
37
|
+
query[key] = coerceQueryValue(value);
|
|
38
|
+
}
|
|
39
|
+
return query;
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Validate request body with size limit.
|
|
43
|
+
* Default max size is 10MB. Throws ValidationError if exceeded or invalid JSON.
|
|
44
|
+
*
|
|
45
|
+
* @param body - Parsed body object
|
|
46
|
+
* @param bodySize - Size of body in bytes
|
|
47
|
+
* @param maxSize - Maximum allowed body size in bytes (default 10MB)
|
|
48
|
+
* @returns true if body is valid
|
|
49
|
+
* @throws ValidationError if body exceeds maxSize
|
|
50
|
+
*/
|
|
51
|
+
export function validateBody(body, bodySize, maxSize = DEFAULT_MAX_BODY_SIZE) {
|
|
52
|
+
if (bodySize > maxSize) {
|
|
53
|
+
throw {
|
|
54
|
+
error: "Payload too large",
|
|
55
|
+
field: "body",
|
|
56
|
+
details: `Max size is ${maxSize} bytes, got ${bodySize} bytes`,
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
return true;
|
|
60
|
+
}
|
|
24
61
|
/**
|
|
25
62
|
* Transpile a TypeScript API route file to JavaScript.
|
|
26
|
-
* Uses esbuild to convert TS
|
|
63
|
+
* Uses esbuild to convert TS + JS, bundle dependencies, and output as ESM.
|
|
27
64
|
* The transpiled file is cached in node_modules/.jen/api-cache with a timestamp
|
|
28
65
|
* in the filename to allow side-by-side versions if the file changes.
|
|
29
66
|
*
|
|
@@ -70,11 +107,13 @@ async function transpileApiRoute(filePath) {
|
|
|
70
107
|
* 2. Resolve route file (exact or dynamic match)
|
|
71
108
|
* 3. Transpile if TypeScript
|
|
72
109
|
* 4. Load module and find handler for HTTP method
|
|
73
|
-
* 5. Parse request body
|
|
74
|
-
* 6.
|
|
75
|
-
* 7.
|
|
110
|
+
* 5. Parse request body with size limit
|
|
111
|
+
* 6. Validate query and body
|
|
112
|
+
* 7. Call handler with context
|
|
113
|
+
* 8. Serialize response (Response, string, or object)
|
|
76
114
|
*
|
|
77
115
|
* All errors send JSON response with error message.
|
|
116
|
+
* HTTP 413 (Payload Too Large) if body exceeds 10MB.
|
|
78
117
|
* HTTP 405 (Method Not Allowed) if method handler not exported.
|
|
79
118
|
* HTTP 404 if no matching route file.
|
|
80
119
|
* HTTP 500 if handler throws or transpilation fails.
|
|
@@ -83,12 +122,30 @@ async function transpileApiRoute(filePath) {
|
|
|
83
122
|
* @returns true if handled, false if no API route found
|
|
84
123
|
*/
|
|
85
124
|
export async function tryHandleApiRoute(opts) {
|
|
86
|
-
const { req, res, siteDir } = opts;
|
|
125
|
+
const { req, res, siteDir, maxBodySize = DEFAULT_MAX_BODY_SIZE } = opts;
|
|
87
126
|
const url = new URL(
|
|
88
127
|
req.url ?? "/",
|
|
89
128
|
`http://${req.headers.host ?? "localhost"}`,
|
|
90
129
|
);
|
|
91
|
-
const
|
|
130
|
+
const methodStr = (req.method ?? "GET").toUpperCase();
|
|
131
|
+
// Validate method is one of the allowed HTTP methods
|
|
132
|
+
const allowedMethods = [
|
|
133
|
+
"GET",
|
|
134
|
+
"POST",
|
|
135
|
+
"PUT",
|
|
136
|
+
"DELETE",
|
|
137
|
+
"PATCH",
|
|
138
|
+
"HEAD",
|
|
139
|
+
"OPTIONS",
|
|
140
|
+
];
|
|
141
|
+
const method = methodStr;
|
|
142
|
+
if (!allowedMethods.includes(method)) {
|
|
143
|
+
res.statusCode = 405;
|
|
144
|
+
res.setHeader("content-type", "application/json; charset=utf-8");
|
|
145
|
+
res.setHeader("allow", allowedMethods.join(", "));
|
|
146
|
+
res.end(JSON.stringify({ error: `${methodStr} not allowed` }));
|
|
147
|
+
return true;
|
|
148
|
+
}
|
|
92
149
|
// Only handle /api/* requests
|
|
93
150
|
if (!url.pathname.startsWith("/api/")) return false;
|
|
94
151
|
// Extract path segments after /api/ prefix
|
|
@@ -169,15 +226,49 @@ export async function tryHandleApiRoute(opts) {
|
|
|
169
226
|
res.end(JSON.stringify({ error: `${method} not allowed` }));
|
|
170
227
|
return true;
|
|
171
228
|
}
|
|
172
|
-
// Parse request body
|
|
173
|
-
|
|
229
|
+
// Parse request body with size limit
|
|
230
|
+
let body;
|
|
231
|
+
let bodySize = 0;
|
|
232
|
+
try {
|
|
233
|
+
const result = await readRequestBody(req, maxBodySize);
|
|
234
|
+
body = result.body;
|
|
235
|
+
bodySize = result.size;
|
|
236
|
+
// Validate body size
|
|
237
|
+
validateBody(body, bodySize, maxBodySize);
|
|
238
|
+
} catch (err) {
|
|
239
|
+
if (err.error === "Payload too large") {
|
|
240
|
+
res.statusCode = 413;
|
|
241
|
+
res.setHeader("content-type", "application/json; charset=utf-8");
|
|
242
|
+
res.end(JSON.stringify({ error: err.error, details: err.details }));
|
|
243
|
+
return true;
|
|
244
|
+
}
|
|
245
|
+
res.statusCode = 400;
|
|
246
|
+
res.setHeader("content-type", "application/json; charset=utf-8");
|
|
247
|
+
res.end(JSON.stringify({ error: "Bad request", details: err.message }));
|
|
248
|
+
return true;
|
|
249
|
+
}
|
|
250
|
+
// Validate and coerce query parameters
|
|
251
|
+
let query;
|
|
252
|
+
try {
|
|
253
|
+
query = validateQuery(url);
|
|
254
|
+
} catch (err) {
|
|
255
|
+
res.statusCode = 400;
|
|
256
|
+
res.setHeader("content-type", "application/json; charset=utf-8");
|
|
257
|
+
res.end(
|
|
258
|
+
JSON.stringify({
|
|
259
|
+
error: "Invalid query parameters",
|
|
260
|
+
details: err.message,
|
|
261
|
+
}),
|
|
262
|
+
);
|
|
263
|
+
return true;
|
|
264
|
+
}
|
|
174
265
|
// Build handler context
|
|
175
266
|
const ctx = {
|
|
176
267
|
req,
|
|
177
268
|
res,
|
|
178
269
|
url,
|
|
179
270
|
method,
|
|
180
|
-
query
|
|
271
|
+
query,
|
|
181
272
|
body,
|
|
182
273
|
params: routeParams,
|
|
183
274
|
};
|
|
@@ -216,39 +307,58 @@ export async function tryHandleApiRoute(opts) {
|
|
|
216
307
|
}
|
|
217
308
|
}
|
|
218
309
|
/**
|
|
219
|
-
* Parse request body based on Content-Type header.
|
|
310
|
+
* Parse request body based on Content-Type header with size limit enforcement.
|
|
220
311
|
* Reads all chunks from the request stream and deserializes based on content type.
|
|
221
312
|
*
|
|
222
|
-
* - GET/HEAD: Returns null (no body expected)
|
|
223
|
-
* - JSON (application/json): Parses and returns object;
|
|
224
|
-
* - Other: Returns { __raw }
|
|
313
|
+
* - GET/HEAD: Returns { body: null, size: 0 } (no body expected)
|
|
314
|
+
* - JSON (application/json): Parses and returns object; throws on invalid JSON
|
|
315
|
+
* - Other: Returns { body: { __raw }, size: byteLength }
|
|
316
|
+
*
|
|
317
|
+
* Throws ValidationError if body size exceeds maxSize.
|
|
225
318
|
*
|
|
226
319
|
* This function is shared between different request handlers in the framework.
|
|
227
320
|
*
|
|
228
321
|
* @param req - Node.js IncomingMessage to read body from
|
|
229
|
-
* @
|
|
322
|
+
* @param maxSize - Maximum allowed body size in bytes (default 10MB)
|
|
323
|
+
* @returns Object with parsed body and size in bytes
|
|
324
|
+
* @throws ValidationError if body exceeds maxSize or invalid JSON
|
|
230
325
|
*/
|
|
231
|
-
async function readRequestBody(req) {
|
|
326
|
+
async function readRequestBody(req, maxSize = DEFAULT_MAX_BODY_SIZE) {
|
|
232
327
|
const method = (req.method ?? "GET").toUpperCase();
|
|
233
328
|
// Methods without bodies per HTTP spec
|
|
234
|
-
if (method === "GET" || method === "HEAD") return null;
|
|
235
|
-
// Read all body chunks
|
|
329
|
+
if (method === "GET" || method === "HEAD") return { body: null, size: 0 };
|
|
330
|
+
// Read all body chunks with size limit check
|
|
236
331
|
const chunks = [];
|
|
237
|
-
|
|
238
|
-
|
|
332
|
+
let totalSize = 0;
|
|
333
|
+
try {
|
|
334
|
+
for await (const chunk of req) {
|
|
335
|
+
totalSize += chunk.length;
|
|
336
|
+
if (totalSize > maxSize) {
|
|
337
|
+
throw {
|
|
338
|
+
error: "Payload too large",
|
|
339
|
+
field: "body",
|
|
340
|
+
details: `Max size is ${maxSize} bytes, got at least ${totalSize} bytes`,
|
|
341
|
+
};
|
|
342
|
+
}
|
|
343
|
+
chunks.push(Buffer.from(chunk));
|
|
344
|
+
}
|
|
345
|
+
} catch (err) {
|
|
346
|
+
// Re-throw validation errors
|
|
347
|
+
if (err.error === "Payload too large") throw err;
|
|
348
|
+
throw new Error(`Failed to read request body: ${err.message}`);
|
|
239
349
|
}
|
|
240
|
-
if (chunks.length === 0) return null;
|
|
241
|
-
const
|
|
350
|
+
if (chunks.length === 0) return { body: null, size: 0 };
|
|
351
|
+
const bodyBuffer = Buffer.concat(chunks);
|
|
352
|
+
const raw = bodyBuffer.toString("utf8");
|
|
242
353
|
const ct = (req.headers["content-type"] ?? "").toString();
|
|
243
354
|
// Try to parse JSON
|
|
244
355
|
if (ct.includes("application/json")) {
|
|
245
356
|
try {
|
|
246
|
-
return JSON.parse(raw);
|
|
247
|
-
} catch {
|
|
248
|
-
|
|
249
|
-
return { __raw: raw };
|
|
357
|
+
return { body: JSON.parse(raw), size: bodyBuffer.byteLength };
|
|
358
|
+
} catch (err) {
|
|
359
|
+
throw new Error(`Invalid JSON: ${err.message}`);
|
|
250
360
|
}
|
|
251
361
|
}
|
|
252
362
|
// Return raw body for non-JSON content
|
|
253
|
-
return { __raw: raw };
|
|
363
|
+
return { body: { __raw: raw }, size: bodyBuffer.byteLength };
|
|
254
364
|
}
|
|
@@ -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 { existsSync } from "node:fs";
|
|
19
2
|
import { join, normalize } from "node:path";
|
|
20
3
|
import { pathToFileURL } from "node:url";
|