@slopware/sloppy-darwin-x64 0.1.0-alpha.0
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/LICENSE +201 -0
- package/README.md +5 -0
- package/bin/sloppy +0 -0
- package/bin/sloppyc +0 -0
- package/docs/KNOWN_LIMITATIONS.md +16 -0
- package/docs/LICENSES.md +6 -0
- package/docs/NOTICE.md +8 -0
- package/examples/README.md +140 -0
- package/examples/auth-api/README.md +20 -0
- package/examples/auth-api/app.js +61 -0
- package/examples/auth-api/appsettings.json +7 -0
- package/examples/auth-api/sloppy.json +5 -0
- package/examples/cache-basic/README.md +9 -0
- package/examples/cache-basic/app.js +32 -0
- package/examples/cache-hybrid-postgres/README.md +10 -0
- package/examples/cache-hybrid-postgres/app.js +27 -0
- package/examples/cache-output-api/README.md +10 -0
- package/examples/cache-output-api/app.js +35 -0
- package/examples/codec-base64-hex/README.md +14 -0
- package/examples/codec-base64-hex/app.js +15 -0
- package/examples/codec-checksums/README.md +15 -0
- package/examples/codec-checksums/app.js +8 -0
- package/examples/codec-compression/README.md +13 -0
- package/examples/codec-compression/app.js +9 -0
- package/examples/codec-streaming-compression/README.md +19 -0
- package/examples/codec-streaming-compression/app.js +16 -0
- package/examples/codec-text-binary/README.md +16 -0
- package/examples/codec-text-binary/app.js +17 -0
- package/examples/compiler-hello/README.md +71 -0
- package/examples/compiler-hello/app.js +7 -0
- package/examples/compiler-hello/expected/app.js +8 -0
- package/examples/compiler-hello/expected/app.js.map +53 -0
- package/examples/compiler-hello/expected/app.plan.json +229 -0
- package/examples/compiler-hello/expected/routes.slrt +0 -0
- package/examples/config-basic/README.md +13 -0
- package/examples/config-basic/app.js +13 -0
- package/examples/config-basic/appsettings.json +7 -0
- package/examples/config-secrets-redaction/README.md +9 -0
- package/examples/config-secrets-redaction/app.js +9 -0
- package/examples/config-secrets-redaction/appsettings.json +5 -0
- package/examples/config-strict-mode/README.md +7 -0
- package/examples/config-strict-mode/app.js +10 -0
- package/examples/config-strict-mode/appsettings.json +7 -0
- package/examples/configured-api/README.md +38 -0
- package/examples/configured-api/app.js +12 -0
- package/examples/configured-api/appsettings.Development.json +5 -0
- package/examples/configured-api/appsettings.json +6 -0
- package/examples/configured-api/sloppy.json +5 -0
- package/examples/core-config-secrets/README.md +10 -0
- package/examples/core-config-secrets/app.js +15 -0
- package/examples/core-fs-time-codec/README.md +9 -0
- package/examples/core-fs-time-codec/app.js +8 -0
- package/examples/core-network-time-codec/README.md +11 -0
- package/examples/core-network-time-codec/app.js +20 -0
- package/examples/core-policy-audit/README.md +7 -0
- package/examples/core-policy-audit/app.js +22 -0
- package/examples/core-process-time-codec/README.md +8 -0
- package/examples/core-process-time-codec/app.js +28 -0
- package/examples/core-worker-time/README.md +8 -0
- package/examples/core-worker-time/app.js +17 -0
- package/examples/crypto-hash-hmac/README.md +17 -0
- package/examples/crypto-hash-hmac/app.js +29 -0
- package/examples/crypto-password/README.md +21 -0
- package/examples/crypto-password/app.js +12 -0
- package/examples/crypto-random-token/README.md +16 -0
- package/examples/crypto-random-token/app.js +12 -0
- package/examples/crypto-secret-constant-time/README.md +21 -0
- package/examples/crypto-secret-constant-time/app.js +15 -0
- package/examples/data-foundation/README.md +39 -0
- package/examples/data-foundation/app.js +63 -0
- package/examples/dependency-graph/README.md +19 -0
- package/examples/dependency-graph/fixtures/graph-helper/index.js +3 -0
- package/examples/dependency-graph/fixtures/graph-helper/package.json +6 -0
- package/examples/dependency-graph/package.json +7 -0
- package/examples/dependency-graph/public/message.txt +1 -0
- package/examples/dependency-graph/sloppy.json +9 -0
- package/examples/dependency-graph/src/main.ts +8 -0
- package/examples/dogfood/README.md +23 -0
- package/examples/dogfood/dogfood.json +136 -0
- package/examples/dynamic-module-include/README.md +20 -0
- package/examples/dynamic-module-include/public/readme.txt +1 -0
- package/examples/dynamic-module-include/sloppy.json +12 -0
- package/examples/dynamic-module-include/src/main.ts +6 -0
- package/examples/dynamic-module-include/src/plugins/alpha.js +3 -0
- package/examples/dynamic-module-include/src/plugins/beta.js +3 -0
- package/examples/ergonomics/README.md +42 -0
- package/examples/ergonomics/app.js +38 -0
- package/examples/framework-controller/README.md +12 -0
- package/examples/framework-controller/app.js +31 -0
- package/examples/framework-di-services/README.md +17 -0
- package/examples/framework-di-services/app.ts +40 -0
- package/examples/framework-explicit-binding/README.md +12 -0
- package/examples/framework-explicit-binding/app.ts +34 -0
- package/examples/framework-hello/README.md +16 -0
- package/examples/framework-hello/app.ts +16 -0
- package/examples/framework-postgres-crud/README.md +73 -0
- package/examples/framework-postgres-crud/app.ts +64 -0
- package/examples/framework-sqlite-crud/README.md +52 -0
- package/examples/framework-sqlite-crud/app.ts +90 -0
- package/examples/framework-sqlite-crud/appsettings.json +11 -0
- package/examples/framework-sqlserver-crud/README.md +73 -0
- package/examples/framework-sqlserver-crud/app.ts +64 -0
- package/examples/framework-validation-errors/README.md +12 -0
- package/examples/framework-validation-errors/app.ts +16 -0
- package/examples/fs-basic/README.md +24 -0
- package/examples/fs-basic/app.js +12 -0
- package/examples/fs-roots-policy/README.md +14 -0
- package/examples/fs-roots-policy/app.js +4 -0
- package/examples/fs-streams/README.md +18 -0
- package/examples/fs-streams/app.js +11 -0
- package/examples/fs-watch/README.md +19 -0
- package/examples/fs-watch/app.js +11 -0
- package/examples/hello/README.md +63 -0
- package/examples/hello/app.js +19 -0
- package/examples/hello-minimal/README.md +51 -0
- package/examples/hello-minimal/sloppy.json +5 -0
- package/examples/hello-minimal/src/main.ts +9 -0
- package/examples/http-client-basic/README.md +11 -0
- package/examples/http-client-basic/app.js +46 -0
- package/examples/http-client-generated/README.md +22 -0
- package/examples/http-client-generated/openapi.json +45 -0
- package/examples/http-client-resilience/README.md +4 -0
- package/examples/http-client-resilience/app.js +38 -0
- package/examples/http-client-runtime-loopback/README.md +24 -0
- package/examples/http-client-testhost/README.md +4 -0
- package/examples/http-client-testhost/app.js +27 -0
- package/examples/http-client-testhost-package-mock/README.md +26 -0
- package/examples/http-client-typed/README.md +5 -0
- package/examples/http-client-typed/app.js +33 -0
- package/examples/modules-api/README.md +30 -0
- package/examples/modules-api/app.js +9 -0
- package/examples/modules-api/modules/routes.js +16 -0
- package/examples/modules-api/sloppy.json +5 -0
- package/examples/modules-basic/README.md +32 -0
- package/examples/modules-basic/app.js +41 -0
- package/examples/net-deadline-cancel/README.md +13 -0
- package/examples/net-deadline-cancel/app.js +34 -0
- package/examples/net-local-ipc/README.md +12 -0
- package/examples/net-local-ipc/app.js +46 -0
- package/examples/net-policy-strict/README.md +12 -0
- package/examples/net-policy-strict/app.js +34 -0
- package/examples/net-tcp-client/README.md +10 -0
- package/examples/net-tcp-client/app.js +23 -0
- package/examples/net-tcp-echo/README.md +11 -0
- package/examples/net-tcp-echo/app.js +45 -0
- package/examples/net-tcp-server/README.md +10 -0
- package/examples/net-tcp-server/app.js +28 -0
- package/examples/node-compat-path-events/README.md +15 -0
- package/examples/node-compat-path-events/sloppy.json +6 -0
- package/examples/node-compat-path-events/src/main.ts +15 -0
- package/examples/ops-compiler/README.md +9 -0
- package/examples/ops-compiler/app.js +26 -0
- package/examples/ops-health-metrics-management/README.md +14 -0
- package/examples/ops-health-metrics-management/app.js +24 -0
- package/examples/orm-basic/README.md +17 -0
- package/examples/orm-basic/app.js +82 -0
- package/examples/orm-cursor-export/README.md +16 -0
- package/examples/orm-cursor-export/app.js +28 -0
- package/examples/orm-migrations/README.md +14 -0
- package/examples/orm-migrations/migrations/.gitkeep +1 -0
- package/examples/orm-migrations/sloppy.json +9 -0
- package/examples/orm-migrations/src/app.ts +34 -0
- package/examples/orm-relations-includes/README.md +10 -0
- package/examples/orm-relations-includes/app.js +47 -0
- package/examples/orm-testservices/README.md +37 -0
- package/examples/orm-testservices/test.mjs +32 -0
- package/examples/os-runtime-api/README.md +11 -0
- package/examples/os-runtime-api/app.js +44 -0
- package/examples/package-zod-like/README.md +28 -0
- package/examples/package-zod-like/fixtures/zod-like/index.js +48 -0
- package/examples/package-zod-like/fixtures/zod-like/package.json +12 -0
- package/examples/package-zod-like/package.json +7 -0
- package/examples/package-zod-like/sloppy.json +6 -0
- package/examples/package-zod-like/src/main.ts +16 -0
- package/examples/postgres-basic/README.md +31 -0
- package/examples/postgres-basic/app.js +50 -0
- package/examples/prealpha-control-plane/README.md +50 -0
- package/examples/prealpha-control-plane/appsettings.Development.json +11 -0
- package/examples/prealpha-control-plane/appsettings.json +15 -0
- package/examples/prealpha-control-plane/sloppy.json +5 -0
- package/examples/prealpha-control-plane/src/db/schema.js +7 -0
- package/examples/prealpha-control-plane/src/db/seed.js +6 -0
- package/examples/prealpha-control-plane/src/main.js +21 -0
- package/examples/prealpha-control-plane/src/routes/apps.js +34 -0
- package/examples/prealpha-control-plane/src/routes/builds.js +25 -0
- package/examples/prealpha-control-plane/src/routes/deployments.js +19 -0
- package/examples/prealpha-control-plane/src/routes/diagnostics.js +11 -0
- package/examples/prealpha-control-plane/src/routes/health.js +27 -0
- package/examples/prealpha-control-plane/src/routes/projects.js +38 -0
- package/examples/prealpha-control-plane/src/services/diagnosticsSink.js +11 -0
- package/examples/prealpha-control-plane/src/services/repositories.js +9 -0
- package/examples/prealpha-control-plane/src/validation/schemas.js +6 -0
- package/examples/program-fs-process/README.md +31 -0
- package/examples/program-fs-process/sloppy.json +9 -0
- package/examples/program-fs-process/src/main.ts +27 -0
- package/examples/program-hello/README.md +32 -0
- package/examples/program-hello/main.ts +8 -0
- package/examples/program-hello/message.ts +1 -0
- package/examples/program-hello/sloppy.json +5 -0
- package/examples/rate-limit-auth/README.md +3 -0
- package/examples/rate-limit-auth/app.js +14 -0
- package/examples/rate-limit-basic/README.md +3 -0
- package/examples/rate-limit-basic/app.js +13 -0
- package/examples/rate-limit-redis/README.md +5 -0
- package/examples/rate-limit-redis/app.js +20 -0
- package/examples/rate-limit-testhost/README.md +4 -0
- package/examples/rate-limit-testhost/app.js +13 -0
- package/examples/rate-limit-websocket/README.md +3 -0
- package/examples/rate-limit-websocket/app.js +16 -0
- package/examples/realtime-auth/README.md +8 -0
- package/examples/realtime-auth/app.js +25 -0
- package/examples/realtime-auth/test.mjs +43 -0
- package/examples/realtime-chat/README.md +8 -0
- package/examples/realtime-chat/app.js +32 -0
- package/examples/realtime-chat/test.mjs +52 -0
- package/examples/realtime-dashboard/README.md +20 -0
- package/examples/realtime-dashboard/app.js +37 -0
- package/examples/realtime-presence/README.md +8 -0
- package/examples/realtime-presence/app.js +32 -0
- package/examples/realtime-presence/test.mjs +50 -0
- package/examples/realtime-testhost/README.md +8 -0
- package/examples/realtime-testhost/test.mjs +31 -0
- package/examples/redis-basic/README.md +17 -0
- package/examples/redis-basic/app.js +39 -0
- package/examples/redis-cache/README.md +14 -0
- package/examples/redis-cache/app.js +36 -0
- package/examples/redis-locks/README.md +13 -0
- package/examples/redis-locks/app.js +49 -0
- package/examples/request-context/README.md +32 -0
- package/examples/request-context/app.js +15 -0
- package/examples/sqlite-basic/README.md +52 -0
- package/examples/sqlite-basic/app.js +56 -0
- package/examples/sqlserver-basic/README.md +36 -0
- package/examples/sqlserver-basic/app.js +59 -0
- package/examples/static-files-basic/README.md +11 -0
- package/examples/static-files-basic/app.js +12 -0
- package/examples/static-files-basic/public/app.js +1 -0
- package/examples/static-files-basic/public/site.css +3 -0
- package/examples/static-files-package/README.md +12 -0
- package/examples/static-files-package/app.js +10 -0
- package/examples/static-files-package/public/index.html +2 -0
- package/examples/static-files-precompressed/README.md +12 -0
- package/examples/static-files-precompressed/app.js +11 -0
- package/examples/static-files-precompressed/public/app.js +1 -0
- package/examples/static-files-precompressed/public/app.js.br +0 -0
- package/examples/static-files-precompressed/public/app.js.gz +0 -0
- package/examples/static-files-spa/README.md +12 -0
- package/examples/static-files-spa/app.js +16 -0
- package/examples/static-files-spa/dist/assets/app.js +1 -0
- package/examples/static-files-spa/dist/index.html +4 -0
- package/examples/static-files-testhost/README.md +8 -0
- package/examples/static-files-testhost/app.js +13 -0
- package/examples/static-files-testhost/public/app.js +1 -0
- package/examples/static-files-testhost/public/app.js.gz +0 -0
- package/examples/static-files-testhost/test.mjs +38 -0
- package/examples/testhost-basic/README.md +26 -0
- package/examples/testhost-db/README.md +31 -0
- package/examples/testservices-postgres/README.md +68 -0
- package/examples/testservices-redis/README.md +71 -0
- package/examples/testservices-sqlserver/README.md +75 -0
- package/examples/time-basic/README.md +18 -0
- package/examples/time-basic/app.js +12 -0
- package/examples/time-deadline-cancellation/README.md +11 -0
- package/examples/time-deadline-cancellation/app.js +27 -0
- package/examples/time-fake-clock/README.md +14 -0
- package/examples/time-fake-clock/app.js +25 -0
- package/examples/time-interval-schedule/README.md +13 -0
- package/examples/time-interval-schedule/app.js +60 -0
- package/examples/users-api-sqlite/README.md +74 -0
- package/examples/users-api-sqlite/app.js +11 -0
- package/examples/users-api-sqlite/appsettings.Development.json +11 -0
- package/examples/users-api-sqlite/appsettings.json +11 -0
- package/examples/users-api-sqlite/modules/users.js +40 -0
- package/examples/users-api-sqlite/sloppy.json +5 -0
- package/examples/validation-errors/README.md +36 -0
- package/examples/validation-errors/app.js +14 -0
- package/examples/validation-errors/invalid-user.http +6 -0
- package/examples/validation-errors/sloppy.json +5 -0
- package/examples/web-dynamic-routes/README.md +17 -0
- package/examples/web-dynamic-routes/app.ts +27 -0
- package/examples/webhooks-basic/README.md +11 -0
- package/examples/webhooks-basic/app.js +48 -0
- package/examples/websocket-auth/README.md +8 -0
- package/examples/websocket-auth/app.js +16 -0
- package/examples/websocket-echo/README.md +9 -0
- package/examples/websocket-echo/app.js +36 -0
- package/examples/websocket-json-schema/README.md +5 -0
- package/examples/websocket-json-schema/app.js +25 -0
- package/examples/websocket-testhost/README.md +11 -0
- package/examples/websocket-testhost/test.mjs +49 -0
- package/examples/workers-background-service/README.md +7 -0
- package/examples/workers-background-service/app.js +16 -0
- package/examples/workers-js-isolate/README.md +8 -0
- package/examples/workers-js-isolate/app.js +19 -0
- package/examples/workers-js-isolate/workers/parser.ts +11 -0
- package/examples/workers-shutdown/README.md +6 -0
- package/examples/workers-shutdown/app.js +26 -0
- package/examples/workers-workerpool/README.md +6 -0
- package/examples/workers-workerpool/app.js +23 -0
- package/examples/workers-workqueue/README.md +8 -0
- package/examples/workers-workqueue/app.js +24 -0
- package/manifest.json +59 -0
- package/package.json +31 -0
- package/stdlib/sloppy/README.md +177 -0
- package/stdlib/sloppy/app.js +2142 -0
- package/stdlib/sloppy/auth.js +1813 -0
- package/stdlib/sloppy/bootstrap.manifest.json +83 -0
- package/stdlib/sloppy/cache.js +1542 -0
- package/stdlib/sloppy/codec.js +1153 -0
- package/stdlib/sloppy/config.js +61 -0
- package/stdlib/sloppy/crypto.js +312 -0
- package/stdlib/sloppy/data.js +2945 -0
- package/stdlib/sloppy/ffi.js +185 -0
- package/stdlib/sloppy/fs.js +795 -0
- package/stdlib/sloppy/health.js +603 -0
- package/stdlib/sloppy/http.js +1595 -0
- package/stdlib/sloppy/index.js +59 -0
- package/stdlib/sloppy/internal/bytes.js +31 -0
- package/stdlib/sloppy/internal/capabilities.js +155 -0
- package/stdlib/sloppy/internal/config.js +640 -0
- package/stdlib/sloppy/internal/disposable.js +31 -0
- package/stdlib/sloppy/internal/headers.js +63 -0
- package/stdlib/sloppy/internal/intrinsics.js +2 -0
- package/stdlib/sloppy/internal/json.js +20 -0
- package/stdlib/sloppy/internal/logging.js +278 -0
- package/stdlib/sloppy/internal/modules.js +405 -0
- package/stdlib/sloppy/internal/redaction.js +87 -0
- package/stdlib/sloppy/internal/routes.js +2279 -0
- package/stdlib/sloppy/internal/runtime-classic.js +19837 -0
- package/stdlib/sloppy/internal/services.js +690 -0
- package/stdlib/sloppy/internal/shared.js +32 -0
- package/stdlib/sloppy/internal/testhost-diagnostics.js +88 -0
- package/stdlib/sloppy/internal/testhost-http-server.js +238 -0
- package/stdlib/sloppy/internal/testhost-http.js +118 -0
- package/stdlib/sloppy/internal/testhost-loopback.js +50 -0
- package/stdlib/sloppy/internal/testservices-docker.js +154 -0
- package/stdlib/sloppy/internal/validation.js +117 -0
- package/stdlib/sloppy/metrics.js +427 -0
- package/stdlib/sloppy/net.js +5208 -0
- package/stdlib/sloppy/node/assert/strict.js +39 -0
- package/stdlib/sloppy/node/assert.js +228 -0
- package/stdlib/sloppy/node/buffer.js +247 -0
- package/stdlib/sloppy/node/console.js +33 -0
- package/stdlib/sloppy/node/constants.js +9 -0
- package/stdlib/sloppy/node/crypto.js +89 -0
- package/stdlib/sloppy/node/diagnostics_channel.js +41 -0
- package/stdlib/sloppy/node/events.js +113 -0
- package/stdlib/sloppy/node/fs/promises.js +27 -0
- package/stdlib/sloppy/node/fs.js +280 -0
- package/stdlib/sloppy/node/http.js +11 -0
- package/stdlib/sloppy/node/https.js +11 -0
- package/stdlib/sloppy/node/module.js +40 -0
- package/stdlib/sloppy/node/os.js +22 -0
- package/stdlib/sloppy/node/path.js +78 -0
- package/stdlib/sloppy/node/perf_hooks.js +12 -0
- package/stdlib/sloppy/node/process.js +129 -0
- package/stdlib/sloppy/node/querystring.js +21 -0
- package/stdlib/sloppy/node/stream/promises.js +3 -0
- package/stdlib/sloppy/node/stream.js +132 -0
- package/stdlib/sloppy/node/string_decoder.js +23 -0
- package/stdlib/sloppy/node/timers.js +26 -0
- package/stdlib/sloppy/node/tty.js +18 -0
- package/stdlib/sloppy/node/url.js +17 -0
- package/stdlib/sloppy/node/util.js +95 -0
- package/stdlib/sloppy/node/zlib.js +72 -0
- package/stdlib/sloppy/orm.js +2188 -0
- package/stdlib/sloppy/os.js +580 -0
- package/stdlib/sloppy/problem-details.js +29 -0
- package/stdlib/sloppy/providers/sqlite.js +26 -0
- package/stdlib/sloppy/rate-limit.js +856 -0
- package/stdlib/sloppy/realtime.js +1508 -0
- package/stdlib/sloppy/redis.js +1272 -0
- package/stdlib/sloppy/request-id.js +184 -0
- package/stdlib/sloppy/request-logging.js +101 -0
- package/stdlib/sloppy/results.js +933 -0
- package/stdlib/sloppy/schema.js +546 -0
- package/stdlib/sloppy/testing.js +4081 -0
- package/stdlib/sloppy/testservices.js +1041 -0
- package/stdlib/sloppy/time.js +894 -0
- package/stdlib/sloppy/webhooks.js +1330 -0
- package/stdlib/sloppy/workers.js +986 -0
- package/templates/api/README.md +82 -0
- package/templates/api/appsettings.Development.json +14 -0
- package/templates/api/appsettings.json +13 -0
- package/templates/api/data/.gitkeep +1 -0
- package/templates/api/gitignore +4 -0
- package/templates/api/migrations/0001_create_users.sql +1 -0
- package/templates/api/package.json +16 -0
- package/templates/api/public/hello.txt +1 -0
- package/templates/api/sloppy.json +14 -0
- package/templates/api/src/config.ts +1 -0
- package/templates/api/src/db/migrate.ts +14 -0
- package/templates/api/src/db/schema.ts +4 -0
- package/templates/api/src/db/usersRepository.ts +23 -0
- package/templates/api/src/main.ts +18 -0
- package/templates/api/src/models/user.ts +7 -0
- package/templates/api/src/routes/health.ts +20 -0
- package/templates/api/src/routes/users.ts +40 -0
- package/templates/api/src/services/usersService.ts +21 -0
- package/templates/api/tsconfig.json +15 -0
- package/templates/cli/README.md +16 -0
- package/templates/cli/gitignore +2 -0
- package/templates/cli/package.json +13 -0
- package/templates/cli/sloppy.json +6 -0
- package/templates/cli/src/commands/echo.ts +9 -0
- package/templates/cli/src/commands/inspect.ts +20 -0
- package/templates/cli/src/main.ts +50 -0
- package/templates/cli/tsconfig.json +15 -0
- package/templates/minimal-api/README.md +14 -0
- package/templates/minimal-api/gitignore +3 -0
- package/templates/minimal-api/package.json +14 -0
- package/templates/minimal-api/sloppy.json +5 -0
- package/templates/minimal-api/src/main.ts +9 -0
- package/templates/minimal-api/tsconfig.json +15 -0
- package/templates/node-compat/README.md +40 -0
- package/templates/node-compat/gitignore +2 -0
- package/templates/node-compat/package.json +11 -0
- package/templates/node-compat/sloppy.json +6 -0
- package/templates/node-compat/src/main.ts +40 -0
- package/templates/package-api/README.md +44 -0
- package/templates/package-api/fixtures/validator-lite/index.js +7 -0
- package/templates/package-api/fixtures/validator-lite/package.json +6 -0
- package/templates/package-api/gitignore +3 -0
- package/templates/package-api/package.json +17 -0
- package/templates/package-api/sloppy.json +5 -0
- package/templates/package-api/src/main.ts +10 -0
- package/templates/package-api/src/routes/health.ts +5 -0
- package/templates/package-api/src/routes/users.ts +12 -0
- package/templates/package-api/tsconfig.json +15 -0
- package/templates/program/README.md +12 -0
- package/templates/program/gitignore +1 -0
- package/templates/program/package.json +10 -0
- package/templates/program/sloppy.json +6 -0
- package/templates/program/src/main.ts +9 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for describing the origin of the Work and
|
|
141
|
+
reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Support. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or support.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
179
|
+
|
|
180
|
+
To apply the Apache License to your work, attach the following
|
|
181
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
182
|
+
replaced with your own identifying information. (Don't include
|
|
183
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
184
|
+
comment syntax for the file format. We also recommend that a
|
|
185
|
+
file or class name and description of purpose be included on the
|
|
186
|
+
same "printed page" as the copyright notice for easier
|
|
187
|
+
identification within any third-party works.
|
|
188
|
+
|
|
189
|
+
Copyright 2026 The Sloppy Authors
|
|
190
|
+
|
|
191
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
192
|
+
you may not use this file except in compliance with the License.
|
|
193
|
+
You may obtain a copy of the License at
|
|
194
|
+
|
|
195
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
196
|
+
|
|
197
|
+
Unless required by applicable law or agreed to in writing, software
|
|
198
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
199
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
200
|
+
implied. See the License for the specific language governing permissions
|
|
201
|
+
and limitations under the License.
|
package/README.md
ADDED
package/bin/sloppy
ADDED
|
Binary file
|
package/bin/sloppyc
ADDED
|
Binary file
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
# Known Limitations
|
|
2
|
+
|
|
3
|
+
This package is an experimental pre-alpha development artifact.
|
|
4
|
+
|
|
5
|
+
- Publishing uses a separate release step.
|
|
6
|
+
- Production readiness is tracked separately.
|
|
7
|
+
- Full Node, Bun, and Deno compatibility, package-manager installs, and runtime
|
|
8
|
+
node_modules discovery are separate tracks.
|
|
9
|
+
- V8 execution, live provider readiness, TLS hardening, and release readiness use their own
|
|
10
|
+
lanes.
|
|
11
|
+
- V8 SDK headers, import libraries, and source/build trees are intentionally excluded.
|
|
12
|
+
- V8 runtime support is included only in packages built with a matching Sloppy-owned SDK
|
|
13
|
+
and validated by the V8 package smoke lane.
|
|
14
|
+
- PostgreSQL and SQL Server live-provider behavior requires separate opt-in evidence.
|
|
15
|
+
- Signing, notarization, installers, auto-update, and package-manager distribution are not
|
|
16
|
+
included.
|
package/docs/LICENSES.md
ADDED
package/docs/NOTICE.md
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
# Notice
|
|
2
|
+
|
|
3
|
+
This experimental local package may include runtime dependencies provided by the
|
|
4
|
+
host build environment. It does not include V8 SDK headers/import libraries,
|
|
5
|
+
database drivers, package manager metadata, installers, or signed release metadata.
|
|
6
|
+
|
|
7
|
+
Dependency license review and a complete release notice file are still required
|
|
8
|
+
before publishing.
|
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
# Sloppy Examples
|
|
2
|
+
|
|
3
|
+
Examples are split by confidence level. Runnable examples are useful to try by
|
|
4
|
+
hand during the public alpha, pre-production period. Fixture examples are small
|
|
5
|
+
source shapes kept stable by tests.
|
|
6
|
+
|
|
7
|
+
Run commands from the repository root unless a row says otherwise. `sloppy run`
|
|
8
|
+
handler execution requires a V8-enabled build.
|
|
9
|
+
|
|
10
|
+
For a new app, use the packaged templates instead of copying an example:
|
|
11
|
+
|
|
12
|
+
```powershell
|
|
13
|
+
sloppy create my-api --template minimal-api
|
|
14
|
+
sloppy create my-tool --template program
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
## Example Inventory
|
|
18
|
+
|
|
19
|
+
| Example | Status | Command | What it covers | Requirements / expected result |
|
|
20
|
+
| --- | --- | --- | --- | --- |
|
|
21
|
+
| `compiler-hello` | runnable with `sloppy run --once` | `ctest -R conformance.hello.*run_once` | Compiler artifact execution | V8 lane returns `Hello from Sloppy`. |
|
|
22
|
+
| `program-hello` | runnable Program Mode source | `sloppy run examples/program-hello/main.ts -- Ada` | Route-free program Plan, relative module import, args/context, and console stdout | V8 lane prints `hello from sloppy program mode Ada`; non-V8 builds can still compile and inspect `kind: program` artifacts. |
|
|
23
|
+
| `program-fs-process` | runnable Program Mode source | `sloppy run` from `examples/program-fs-process` | Program stdlib imports for filesystem and OS/process APIs, package run shape | V8 lane writes under `./tmp`, runs `git --version`, and exits with the child exit code. |
|
|
24
|
+
| `package-zod-like` | package graph fixture | `npm install && sloppy build && sloppy deps .sloppy` from the example directory | Local fixture package resolution from `node_modules`, package `exports`, Program Mode dependency graph | Uses a local `file:` dependency; no registry access required. Runtime execution requires V8. |
|
|
25
|
+
| `dependency-graph` | package graph fixture | `npm install && sloppy build && sloppy deps .sloppy --format json` from the example directory | Installed fixture package, `node:path` compatibility shim, `assetInclude`, dependency graph inspection | Uses a local `file:` dependency; no registry access required. |
|
|
26
|
+
| `node-compat-path-events` | compile-only / tooling fixture | `sloppy build && sloppy deps .sloppy` from the example directory | Supported `node:path` and `node:events` compatibility shims | Shows explicit shim imports; does not claim full Node runtime behavior. |
|
|
27
|
+
| `dynamic-module-include` | compile-only / tooling fixture | `sloppy build && sloppy deps .sloppy` from the example directory | Computed dynamic imports over `moduleInclude` plus asset metadata | Runtime dynamic import succeeds only for modules sealed into the graph. |
|
|
28
|
+
| `hello-minimal` | runnable with source input | `sloppy run examples/hello-minimal/src/main.ts --once GET /hello/Ada` | Smallest project/source-input app | V8 lane writes a full HTTP response with `{"hello":"Ada"}` body. |
|
|
29
|
+
| `web-dynamic-routes` | runnable with source input | `sloppyc build examples/web-dynamic-routes/app.ts --out .sloppy` | Static and dynamic web route registration with partial Plan metadata | Static route metadata remains complete; dynamic routes emit findings and require V8 for handler execution. |
|
|
30
|
+
| `prealpha-control-plane` | contributor/internal app-host and source-input run | `ctest -R "bootstrap.stdlib.prealpha_control_plane_dogfood\|conformance.prealpha_control_plane"` | Multi-file app, modules, CORS, request IDs/logging, ProblemDetails, SQLite-shaped provider, services, health | App-host test passes; V8 source-input lane returns `Compiler Platform`. |
|
|
31
|
+
| `testhost-basic` | documentation example | Read `examples/testhost-basic/README.md` | `TestHost.create(app)` fluent request/response assertions | Plain JavaScript example; covered by bootstrap TestHost tests. |
|
|
32
|
+
| `testhost-db` | documentation example | Read `examples/testhost-db/README.md` | Test data helper shape for SQLite-backed tests | SQLite execution depends on the active native bridge lane. |
|
|
33
|
+
| `testservices-postgres` | documentation example | Read `examples/testservices-postgres/README.md` | Experimental Docker-backed PostgreSQL service with migrations, seed, reset, and TestHost | Requires Docker, the opt-in TestServices gate, and the PostgreSQL provider bridge. |
|
|
34
|
+
| `testservices-sqlserver` | documentation example | Read `examples/testservices-sqlserver/README.md` | Experimental Docker-backed SQL Server service with migrations, seed, reset, and TestHost | Requires Docker, the opt-in TestServices gate, SQL Server provider bridge, and ODBC driver. |
|
|
35
|
+
| `cache-basic` | API-shape fixture | Read `examples/cache-basic/README.md` | Memory cache, cache-aside, schema validation, tag invalidation | App-host shape; covered by bootstrap cache tests. |
|
|
36
|
+
| `cache-output-api` | API-shape fixture | Read `examples/cache-output-api/README.md` | OutputCache and HTTP cache headers | App-host shape; covered by bootstrap cache tests. |
|
|
37
|
+
| `cache-hybrid-postgres` | live-provider example | Configure PostgreSQL, then run through the app host | Hybrid cache with PostgreSQL distributed backend | Requires PostgreSQL provider support and a live service; default lanes skip external provider requirements. |
|
|
38
|
+
| `request-context` | runnable with `sloppy run --once` | `ctest -R conformance.request_context.*run_once` | Route params, query, method, path, raw target | V8 lane returns JSON request context fields. |
|
|
39
|
+
| `static-files-basic` | compile-only / tooling fixture | `sloppy build examples/static-files-basic/app.js --out .sloppy-static-basic` | `app.staticFiles` public directory shape | Static assets are a build-time snapshot; handler execution requires V8. |
|
|
40
|
+
| `static-files-spa` | compile-only / tooling fixture | `sloppy build examples/static-files-spa/app.js --out .sloppy-static-spa` | `app.spa` fallback and asset route shape | API routes win before SPA fallback; runtime handler execution requires V8. |
|
|
41
|
+
| `static-files-precompressed` | compile-only / tooling fixture | `sloppy build examples/static-files-precompressed/app.js --out .sloppy-static-precompressed` | Precompressed static variant metadata | Placeholder `.br` and `.gz` files demonstrate selection metadata only. |
|
|
42
|
+
| `static-files-package` | package graph fixture | `sloppy package examples/static-files-package/app.js --out .sloppy-static-package` | Static assets copied into package artifacts | Package path is local alpha packaging, not a release archive. |
|
|
43
|
+
| `static-files-testhost` | documentation example | `node examples/static-files-testhost/test.mjs` | In-process static file TestHost behavior | Exercises route precedence, `HEAD`, precompressed selection, and traversal rejection. |
|
|
44
|
+
| `redis-basic` | live-provider example | Read `examples/redis-basic/README.md` | First-party Redis client shape | Optional provider fixture. Requires Redis and the Sloppy network bridge; default lanes use fake bridge protocol tests only. |
|
|
45
|
+
| `redis-cache` | live-provider example | Read `examples/redis-cache/README.md` | Redis-backed cache provider with tags and service registration | Optional provider fixture. Requires Redis and the Sloppy network bridge. |
|
|
46
|
+
| `redis-locks` | live-provider example | Read `examples/redis-locks/README.md` | Redis single-key lease shape | Optional provider fixture. Requires Redis and the Sloppy network bridge; no cluster or Redlock claim. |
|
|
47
|
+
| `testservices-redis` | documentation example | Read `examples/testservices-redis/README.md` | Experimental Docker-backed Redis service with client, env, flush, reset, and TestHost | Requires Docker, the opt-in TestServices gate, and the Sloppy network bridge. |
|
|
48
|
+
| `auth-api` | compile-only / tooling fixture | `sloppy build && sloppy routes .sloppy && sloppy openapi .sloppy` from the example directory | JWT/API-key/session auth setup, route requirements, roles, policies, OpenAPI security metadata | Uses placeholder secrets; protected-route manual execution needs a request path that can supply headers or cookies. |
|
|
49
|
+
| `realtime-dashboard` | compile-only / tooling fixture | `sloppy build examples/realtime-dashboard/app.js --out .sloppy && sloppy routes .sloppy && sloppy openapi .sloppy` | SSE route metadata, WebSocket route intent, and in-process hub shape | SSE uses bounded `Results.stream`; WebSocket route execution requires HTTP/1.1 Upgrade in native `sloppy run`. |
|
|
50
|
+
| `websocket-echo` | documentation example | Read `examples/websocket-echo/README.md` | App-host WebSocket text/JSON echo, origin policy, subprotocols, heartbeat, idle timeout, and limits | TestHost covers the full app-host API; native `sloppy run` covers text/binary HTTP Upgrade sessions. |
|
|
51
|
+
| `websocket-auth` | documentation example | Read `examples/websocket-auth/README.md` | JWT-protected WebSocket route with required scope | Use with TestHost `.withJwt(...)`; protected native WebSocket routes fail closed until auth principals are materialized on upgraded connections. |
|
|
52
|
+
| `websocket-json-schema` | documentation example | Read `examples/websocket-json-schema/README.md` | Schema-validated JSON WebSocket messages | App-host TestHost behavior only. |
|
|
53
|
+
| `websocket-testhost` | documentation example | `node examples/websocket-testhost/test.mjs` | First-party WebSocket TestHost client helpers | Plain JavaScript app-host test; no external WebSocket package required. |
|
|
54
|
+
| `users-api-sqlite` | runnable with `sloppy run --once` | `ctest -R conformance.users_api_sqlite.*run_once` | SQLite source-input conformance app | V8/SQLite lane returns seeded users. |
|
|
55
|
+
| `framework-hello` | runnable with source input | `ctest -R conformance.framework_hello` | Typed route binding and request context | V8 lane returns `{"hello":"Ada"}`. |
|
|
56
|
+
| `framework-di-services` | runnable with source input | `ctest -R conformance.framework_di_services_example.run_once` | Singleton/scoped/transient service injection | V8 lane returns deterministic service values. |
|
|
57
|
+
| `framework-sqlite-crud` | runnable with source input | `ctest -R conformance.framework_sqlite_crud` | Typed SQLite provider injection and CRUD shape | V8/SQLite lane returns seeded SQLite users. |
|
|
58
|
+
| `configured-api` | compile-only / tooling fixture | `ctest -R "conformance.configured_api\|examples.configured_api"` | Project config and Plan inspection | Emits artifacts and CLI metadata; no positive handler execution claim. |
|
|
59
|
+
| `modules-api` | compile-only / tooling fixture | `ctest -R "conformance.modules_api\|examples.modules_api"` | Function module source-input workflow | Emits artifacts and CLI metadata. |
|
|
60
|
+
| `validation-errors` | compile-only / tooling fixture | `ctest -R "conformance.validation_errors\|examples.validation_errors"` | Plan validation metadata and OpenAPI/doctor output | Emits artifacts and CLI metadata. |
|
|
61
|
+
| `framework-explicit-binding` | compile-only / tooling fixture | `ctest -R conformance.framework_explicit_binding` | `Route`, `Query`, `Body`, `Header`, `RequestContext` binding metadata | Emits artifacts and CLI metadata. |
|
|
62
|
+
| `framework-validation-errors` | compile-only / tooling fixture | `ctest -R conformance.framework_validation_errors` | Schema-backed body binding diagnostics | Emits artifacts and CLI metadata. |
|
|
63
|
+
| `framework-postgres-crud` | live-provider example | `.\tools\windows\test-live-postgres.ps1` | Typed PostgreSQL provider shape | Optional provider example. Requires V8, PostgreSQL client support, connection-string config, and live PostgreSQL service; default lane skips/unavailable when missing. |
|
|
64
|
+
| `framework-sqlserver-crud` | live-provider example | `.\tools\windows\test-live-sqlserver.ps1` | Typed SQL Server provider shape | Optional provider example. Requires V8, Microsoft ODBC Driver 17 or 18, connection-string config, and live SQL Server service; default lane skips/unavailable when missing. |
|
|
65
|
+
| `postgres-basic` | live-provider fixture | `.\tools\windows\test-live-postgres.ps1` | PostgreSQL runtime provider bridge | Optional provider fixture. Requires PostgreSQL client support and live PostgreSQL setup. |
|
|
66
|
+
| `sqlserver-basic` | live-provider fixture | `.\tools\windows\test-live-sqlserver.ps1` | SQL Server runtime provider bridge | Optional provider fixture. Requires live SQL Server setup and Microsoft ODBC Driver 17 or 18. |
|
|
67
|
+
| `codec-base64-hex` | API-shape fixture | `ctest -R examples.codec.api_shape` | Base64/Base64Url/Hex helpers | Static example check only. |
|
|
68
|
+
| `codec-checksums` | API-shape fixture | `ctest -R examples.codec.api_shape` | CRC/checksum helper boundary | Static example check only; not authentication. |
|
|
69
|
+
| `codec-compression` | API-shape fixture | `ctest -R examples.codec.api_shape` | gzip/gunzip helper shape | Static example check only. |
|
|
70
|
+
| `codec-streaming-compression` | API-shape fixture | `ctest -R examples.codec.api_shape` | streaming compression shape | Static example check only. |
|
|
71
|
+
| `codec-text-binary` | API-shape fixture | `ctest -R examples.codec.api_shape` | Text and binary reader/writer helpers | Static example check only. |
|
|
72
|
+
| `config-basic` | compile-only / tooling fixture | `ctest -R examples.config.api_shape` | Config binding and defaults | Source build and static example checks; no positive handler execution claim. |
|
|
73
|
+
| `config-secrets-redaction` | compile-only / tooling fixture | `ctest -R examples.config.api_shape` | Secret wrapper/redaction boundary | Source build and static example checks; `doctor` reports missing required secret config until configured. |
|
|
74
|
+
| `config-strict-mode` | compile-only / tooling fixture | `ctest -R examples.config.api_shape` | Strict config reads | Source build and static example checks; no positive handler execution claim. |
|
|
75
|
+
| `core-config-secrets` | core integration fixture | `ctest -R examples.core_integration.api_shape` | Core config/secret policy shape | Static example check only. |
|
|
76
|
+
| `core-fs-time-codec` | core integration fixture | `ctest -R examples.core_integration.api_shape` | Combined filesystem/time/codec API shape | Static example check only. |
|
|
77
|
+
| `core-network-time-codec` | core integration fixture | `ctest -R examples.core_integration.api_shape` | Combined network/time/codec API shape | Static example check only. |
|
|
78
|
+
| `core-policy-audit` | core integration fixture | `ctest -R examples.core_integration.api_shape` | Capability/audit policy shape | Static example check only. |
|
|
79
|
+
| `core-process-time-codec` | core integration fixture | `ctest -R examples.core_integration.api_shape` | Process/time/codec API shape | Static example check only. |
|
|
80
|
+
| `core-worker-time` | core integration fixture | `ctest -R examples.core_integration.api_shape` | Worker/time API shape | Static example check only. |
|
|
81
|
+
| `crypto-hash-hmac` | API-shape fixture | `ctest -R examples.crypto.api_shape` | Hash/HMAC/Secret helpers | Static example check only. |
|
|
82
|
+
| `crypto-password` | API-shape fixture | `ctest -R examples.crypto.api_shape` | Async password hashing helpers | Static example check only. |
|
|
83
|
+
| `crypto-random-token` | API-shape fixture | `ctest -R examples.crypto.api_shape` | Random token helpers | Static example check only. |
|
|
84
|
+
| `crypto-secret-constant-time` | API-shape fixture | `ctest -R examples.crypto.api_shape` | Secret cleanup and constant-time compare shape | Static example check only. |
|
|
85
|
+
| `data-foundation` | API-shape fixture | `ctest -R examples.data_foundation.api_shape` | Provider/capability descriptors | Static example check only. |
|
|
86
|
+
| `orm-basic` | documentation example | Read `examples/orm-basic/README.md` | First-party `sloppy/orm` model, schema, CRUD, relation include, and migration script shape | Handler execution needs `ctx.db` to be supplied by an active Sloppy database provider. |
|
|
87
|
+
| `orm-relations-includes` | documentation example | Read `examples/orm-relations-includes/README.md` | ORM one-join and collection split-query includes | Handler execution needs `ctx.db` to be supplied by an active Sloppy database provider. |
|
|
88
|
+
| `orm-cursor-export` | documentation example | Read `examples/orm-cursor-export/README.md` | ORM cursor metadata and NDJSON adapter with the bounded `Results.stream` descriptor | Handler execution needs `ctx.db` to be supplied by an active Sloppy database provider. |
|
|
89
|
+
| `orm-migrations` | compile-only / tooling fixture | `sloppy build && sloppy orm migration script .sloppy --provider main` from the example directory | Compiler-emitted ORM Plan metadata and CLI migration draft/status/apply commands | Produces reviewable SQL from static table metadata; `status` and `apply` use the configured provider database and migration history. |
|
|
90
|
+
| `orm-testservices` | documentation example | Read `examples/orm-testservices/README.md` | ORM app-host test shape with `TestServices.postgres/sqlServer` skip semantics | Live execution requires environment-provided database services and native provider support; missing prerequisites report `SKIPPED`. |
|
|
91
|
+
| `dogfood` | contributor/internal machine-readable catalog | `.\tools\windows\dogfood.ps1 -StatusOnly -Json` | Scenario vocabulary and lane expectations | Catalog validation; not an app by itself. |
|
|
92
|
+
| `ergonomics` | API-shape fixture | `ctest -R examples.ergonomics.api_shape` | Route groups, Results helpers, config/log/services shape | Static example check only. |
|
|
93
|
+
| `framework-controller` | API-shape fixture | `ctest -R examples.framework.api_shape` | Controller mapper and DI shape | App-host fixture; compiler source input covers the static controller mapping subset in compiler fixtures. |
|
|
94
|
+
| `fs-basic` | API-shape fixture | `ctest -R examples.fs.api_shape` | Directory/File helpers and deadline option | Static example check only. |
|
|
95
|
+
| `fs-roots-policy` | API-shape fixture | `ctest -R examples.fs.api_shape` | Logical root path shape | Static example check only. |
|
|
96
|
+
| `fs-streams` | API-shape fixture | `ctest -R examples.fs.api_shape` | File stream/line iteration shape | Static example check only. |
|
|
97
|
+
| `fs-watch` | API-shape fixture | `ctest -R examples.fs.api_shape` | Directory watch shape | Static example check only. |
|
|
98
|
+
| `hello` | hello fixture | `ctest -R examples.hello.api_shape` | Smallest app-host hello shape | Static example check only. |
|
|
99
|
+
| `http-client-basic` | API-shape fixture | `ctest -R bootstrap.stdlib.http_client` | Outbound `HttpClient` helper shape | Bootstrap test uses local test bridge; runtime bridge lanes are separate. |
|
|
100
|
+
| `http-client-typed` | documentation example | Read `examples/http-client-typed/README.md` | Typed outbound client registered through services | App-host shape is covered by `tests/bootstrap/test_http_client_factory.mjs`. |
|
|
101
|
+
| `http-client-generated` | documentation example | Read `examples/http-client-generated/README.md` | OpenAPI-to-`Http.typedClient` generated client shape | Generator behavior is covered by `tests/bootstrap/test_http_client_factory.mjs`. |
|
|
102
|
+
| `http-client-resilience` | documentation example | Read `examples/http-client-resilience/README.md` | Retry, circuit-breaker, bulkhead, and pool options | API shape is covered by `tests/bootstrap/test_http_client_factory.mjs`. |
|
|
103
|
+
| `http-client-testhost` | documentation example | Read `examples/http-client-testhost/README.md` | `TestHttp.mock()` with `TestHost` outbound overrides | App-host mock path is covered by `tests/bootstrap/test_http_client_factory.mjs`. |
|
|
104
|
+
| `http-client-testhost-package-mock` | documentation example | Read `examples/http-client-testhost-package-mock/README.md` | Artifact/package TestHost outbound mock injection | Process-host harness is covered by `tests/bootstrap/test_testhost_process_modes.mjs`; positive handler execution requires a V8-enabled CLI. |
|
|
105
|
+
| `http-client-runtime-loopback` | documentation example | Read `examples/http-client-runtime-loopback/README.md` | Native-backed outbound loopback client path | Low-level loopback coverage is in `tests/bootstrap/test_http_client.mjs`; artifact/package runtime execution requires V8. |
|
|
106
|
+
| `modules-basic` | API-shape fixture | `ctest -R examples.modules_basic.api_shape` | Module phases and route contribution shape | Static example check only. |
|
|
107
|
+
| `net-deadline-cancel` | API-shape fixture | `ctest -R examples.net.api_shape` | Network cancellation shape | Static example check only. |
|
|
108
|
+
| `net-local-ipc` | API-shape fixture | `ctest -R examples.net.api_shape` | Local IPC shape | Static example check only. |
|
|
109
|
+
| `net-policy-strict` | API-shape fixture | `ctest -R examples.net.api_shape` | Network policy shape | Static example check only. |
|
|
110
|
+
| `net-tcp-client` | API-shape fixture | `ctest -R examples.net.api_shape` | TCP client shape | Static example check only. |
|
|
111
|
+
| `net-tcp-echo` | API-shape fixture | `ctest -R examples.net.api_shape` | TCP echo shape | Static example check only. |
|
|
112
|
+
| `net-tcp-server` | API-shape fixture | `ctest -R examples.net.api_shape` | TCP server shape | Static example check only. |
|
|
113
|
+
| `os-runtime-api` | API-shape fixture | `ctest -R examples.os.api_shape` | OS/environment/process/signal API shape | Static example check only. |
|
|
114
|
+
| `sqlite-basic` | provider fixture | `ctest -R examples.sqlite_basic.api_shape` | SQLite provider API shape | Static example check; runtime SQLite lanes are separate. |
|
|
115
|
+
| `time-basic` | API-shape fixture | `ctest -R examples.time.api_shape` | Clock/time helpers | Static example check only. |
|
|
116
|
+
| `time-deadline-cancellation` | API-shape fixture | `ctest -R examples.time.api_shape` | Deadline/cancellation shape | Static example check only. |
|
|
117
|
+
| `time-fake-clock` | API-shape fixture | `ctest -R examples.time.api_shape` | Fake clock shape | Static example check only. |
|
|
118
|
+
| `time-interval-schedule` | API-shape fixture | `ctest -R examples.time.api_shape` | Interval/schedule shape | Static example check only. |
|
|
119
|
+
| `workers-background-service` | curated worker fixture | `ctest -R examples.workers.api_shape` | Background service shape | Static example check only. |
|
|
120
|
+
| `workers-js-isolate` | API-shape fixture | `ctest -R examples.workers.api_shape` | Worker isolate shape | Static example check only. |
|
|
121
|
+
| `workers-shutdown` | API-shape fixture | `ctest -R examples.workers.api_shape` | Worker shutdown shape | Static example check only. |
|
|
122
|
+
| `workers-workerpool` | curated worker fixture | `ctest -R examples.workers.api_shape` | Worker pool shape | Static example check only. |
|
|
123
|
+
| `workers-workqueue` | API-shape fixture | `ctest -R examples.workers.api_shape` | Work queue shape | Static example check only. |
|
|
124
|
+
|
|
125
|
+
## Status Meanings
|
|
126
|
+
|
|
127
|
+
- `runnable with sloppy run --once`: the example is expected to execute through
|
|
128
|
+
generated artifacts and V8 in a configured V8 build.
|
|
129
|
+
- `compile-only / tooling fixture`: the example is expected to compile and feed
|
|
130
|
+
Plan-backed CLI tools, but no positive handler execution is claimed.
|
|
131
|
+
- `package graph fixture`: the example demonstrates package/dependency graph
|
|
132
|
+
behavior. Local `file:` dependencies avoid internet access.
|
|
133
|
+
- `documentation example`: the example is reader-facing documentation for an
|
|
134
|
+
API shape already covered by focused tests. It is not a standalone execution
|
|
135
|
+
lane.
|
|
136
|
+
- `live-provider example`: the example needs an external database and matching
|
|
137
|
+
optional provider dependency. Default Sloppy apps do not need PostgreSQL, SQL
|
|
138
|
+
Server, Redis, libpq, or ODBC.
|
|
139
|
+
- `API-shape fixture`: static checks keep the example honest about imports,
|
|
140
|
+
APIs, and documentation boundaries.
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
# Auth API
|
|
2
|
+
|
|
3
|
+
Small source-input example for Sloppy JWT bearer, rotating memory-backed session
|
|
4
|
+
cookies, API keys, roles, policies, and Plan/OpenAPI auth metadata.
|
|
5
|
+
|
|
6
|
+
Build from this directory:
|
|
7
|
+
|
|
8
|
+
```sh
|
|
9
|
+
sloppy build
|
|
10
|
+
sloppy routes .sloppy
|
|
11
|
+
sloppy openapi .sloppy --output openapi.json
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
`appsettings.json` declares sample JWT, session, and API-key secret keys for
|
|
15
|
+
local builds. Provide deployment values through environment-specific
|
|
16
|
+
configuration. Do not commit real auth secrets.
|
|
17
|
+
|
|
18
|
+
Runtime handler execution requires a V8-enabled Sloppy build. `sloppy run
|
|
19
|
+
--once` is useful for public routes, but it does not provide a convenient
|
|
20
|
+
manual header input path for protected-route testing.
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { Sloppy, Results, Auth, Config } from "sloppy";
|
|
2
|
+
|
|
3
|
+
const app = Sloppy.create();
|
|
4
|
+
|
|
5
|
+
app.use(Auth.jwtBearer({
|
|
6
|
+
issuer: "sloppy.local",
|
|
7
|
+
audience: "api",
|
|
8
|
+
secret: Config.required("Auth:JwtSecret"),
|
|
9
|
+
}));
|
|
10
|
+
|
|
11
|
+
app.use(Auth.cookieSession({
|
|
12
|
+
name: "sloppy.session",
|
|
13
|
+
secret: Config.required("Auth:SessionSecret"),
|
|
14
|
+
store: Auth.sessionStore.memory({ maxEntries: 128 }),
|
|
15
|
+
idleTimeoutMs: 1800000,
|
|
16
|
+
absoluteTimeoutMs: 86400000,
|
|
17
|
+
rotation: true,
|
|
18
|
+
csrf: true,
|
|
19
|
+
}));
|
|
20
|
+
|
|
21
|
+
app.get("/public", () => Results.ok({ ok: true }));
|
|
22
|
+
|
|
23
|
+
app.post("/login", (ctx) => Auth.signIn(ctx, {
|
|
24
|
+
sub: "user-1",
|
|
25
|
+
roles: ["user"],
|
|
26
|
+
claims: { email: "ada@example.com" },
|
|
27
|
+
}));
|
|
28
|
+
|
|
29
|
+
app.post("/logout", (ctx) => Auth.signOut(ctx));
|
|
30
|
+
|
|
31
|
+
app.get("/me", (ctx) => Results.ok({
|
|
32
|
+
subject: ctx.user.sub,
|
|
33
|
+
roles: ctx.user.roles,
|
|
34
|
+
scheme: ctx.user.scheme,
|
|
35
|
+
})).requireAuth();
|
|
36
|
+
|
|
37
|
+
app.get("/admin", () => Results.ok({ ok: true }))
|
|
38
|
+
.requireAuth({ role: "admin" });
|
|
39
|
+
|
|
40
|
+
app.use(Auth.apiKey({
|
|
41
|
+
header: "x-api-key",
|
|
42
|
+
validate: (key) => key === Config.required("Auth:ApiKey"),
|
|
43
|
+
}));
|
|
44
|
+
|
|
45
|
+
app.get("/internal/status", () => Results.ok({ ok: true }))
|
|
46
|
+
.requireAuth("apiKeyAuth");
|
|
47
|
+
|
|
48
|
+
app.auth.addPolicy("admin-or-ops", (user) =>
|
|
49
|
+
user.roles.includes("admin") || user.claims.department === "ops",
|
|
50
|
+
);
|
|
51
|
+
app.auth.addPolicy("users-read", Auth.policy((policy) =>
|
|
52
|
+
policy.requireAuthenticated().requireScope("users:read"),
|
|
53
|
+
));
|
|
54
|
+
|
|
55
|
+
app.get("/ops", () => Results.ok({ ok: true }))
|
|
56
|
+
.requireAuth({ policy: "admin-or-ops" });
|
|
57
|
+
|
|
58
|
+
app.get("/users", () => Results.ok({ ok: true }))
|
|
59
|
+
.requireAuth({ policy: "users-read" });
|
|
60
|
+
|
|
61
|
+
export default app;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
# Cache Basic Example
|
|
2
|
+
|
|
3
|
+
This example uses `Cache.memory(...)` for cache-aside reads and tag invalidation.
|
|
4
|
+
|
|
5
|
+
- `GET /users/42` uses `getOrCreate(...)` with a schema and tags.
|
|
6
|
+
- `POST /users/42/invalidate` invalidates the user and list tags.
|
|
7
|
+
|
|
8
|
+
Memory cache is per process. Use `Cache.sqlite`, `Cache.postgres`, or
|
|
9
|
+
`Cache.sqlServer` when multiple app instances must share entries.
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { Cache, Results, Schema, Sloppy } from "sloppy";
|
|
2
|
+
|
|
3
|
+
const app = Sloppy.create();
|
|
4
|
+
const cache = Cache.memory("main", { maxEntries: 1000, ttlMs: 30000 });
|
|
5
|
+
const UserDto = Schema.object({
|
|
6
|
+
id: Schema.integer(),
|
|
7
|
+
name: Schema.string(),
|
|
8
|
+
});
|
|
9
|
+
|
|
10
|
+
app.services.addCache(cache);
|
|
11
|
+
app.services.addSingleton("users", () => ({
|
|
12
|
+
async findById(id) {
|
|
13
|
+
return id === "42" ? { id: 42, name: "Ada Lovelace" } : null;
|
|
14
|
+
},
|
|
15
|
+
}));
|
|
16
|
+
|
|
17
|
+
app.get("/users/{id}", async (ctx) => {
|
|
18
|
+
const user = await cache.getOrCreate(`users:${ctx.route.id}`, {
|
|
19
|
+
ttlMs: 30000,
|
|
20
|
+
tags: [`user:${ctx.route.id}`, "users"],
|
|
21
|
+
schema: UserDto,
|
|
22
|
+
}, async () => ctx.services.get("users").findById(ctx.route.id));
|
|
23
|
+
|
|
24
|
+
return user === null ? Results.notFound() : Results.json(user);
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
app.post("/users/{id}/invalidate", async (ctx) => {
|
|
28
|
+
await cache.invalidateTags([`user:${ctx.route.id}`, "users"]);
|
|
29
|
+
return Results.noContent();
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
export default app;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
# Cache Hybrid PostgreSQL Example
|
|
2
|
+
|
|
3
|
+
This example shows the app-host shape for a hybrid cache:
|
|
4
|
+
|
|
5
|
+
- memory cache handles hot in-process hits;
|
|
6
|
+
- PostgreSQL distributed cache shares entries across app instances;
|
|
7
|
+
- `getOrCreate(...)` coalesces same-process misses.
|
|
8
|
+
|
|
9
|
+
It requires PostgreSQL provider support, a configured connection string, and a
|
|
10
|
+
live PostgreSQL service. Default Sloppy lanes do not require PostgreSQL.
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { Cache, Results, Sloppy, data } from "sloppy";
|
|
2
|
+
|
|
3
|
+
const app = Sloppy.create();
|
|
4
|
+
|
|
5
|
+
app.services.addSingleton("data.main", () => data.postgres.open({
|
|
6
|
+
connectionString: app.config.require("Sloppy:Providers:postgres:main:connectionString"),
|
|
7
|
+
}));
|
|
8
|
+
|
|
9
|
+
app.services.addSingleton("cache.main", (scope) => Cache.hybrid("main", {
|
|
10
|
+
memory: Cache.memory({ maxEntries: 10000, ttlMs: 10000 }),
|
|
11
|
+
distributed: Cache.postgres(scope.get("data.main"), {
|
|
12
|
+
namespace: "products",
|
|
13
|
+
ttlMs: 60000,
|
|
14
|
+
}),
|
|
15
|
+
}));
|
|
16
|
+
|
|
17
|
+
app.get("/products/{id}", async (ctx) => {
|
|
18
|
+
const cache = ctx.services.get("cache.main");
|
|
19
|
+
const product = await cache.getOrCreate(`products:${ctx.route.id}`, {
|
|
20
|
+
ttlMs: 30000,
|
|
21
|
+
tags: [`product:${ctx.route.id}`, "products"],
|
|
22
|
+
}, async () => ({ id: ctx.route.id, source: "postgres" }));
|
|
23
|
+
|
|
24
|
+
return Results.json(product);
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
export default app;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
# Cache Output API Example
|
|
2
|
+
|
|
3
|
+
This example separates server-side OutputCache from HTTP cache headers.
|
|
4
|
+
|
|
5
|
+
- `GET /products?category=books&page=1` is cached by Sloppy on the server.
|
|
6
|
+
- `GET /assets/config.json` emits `Cache-Control`, `Vary`, and `ETag` headers
|
|
7
|
+
for clients and proxies, but does not use server-side output cache.
|
|
8
|
+
|
|
9
|
+
OutputCache keys use the route pattern and configured vary fields, not raw URLs
|
|
10
|
+
or secret headers.
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { Cache, Results, Sloppy } from "sloppy";
|
|
2
|
+
|
|
3
|
+
const app = Sloppy.create();
|
|
4
|
+
|
|
5
|
+
function createOutputCache() {
|
|
6
|
+
return Cache.memory("default", { maxEntries: 1000, ttlMs: 30000 });
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
app.services.addSingleton("cache.default", () => createOutputCache());
|
|
10
|
+
|
|
11
|
+
let productCalls = 0;
|
|
12
|
+
app.get("/products", (ctx) => {
|
|
13
|
+
productCalls += 1;
|
|
14
|
+
const calls = productCalls;
|
|
15
|
+
const category = ctx.query.category ?? "all";
|
|
16
|
+
const page = Number(ctx.query.page ?? 1);
|
|
17
|
+
return Results.json({
|
|
18
|
+
category,
|
|
19
|
+
page,
|
|
20
|
+
calls,
|
|
21
|
+
});
|
|
22
|
+
}).outputCache({
|
|
23
|
+
ttlMs: 30000,
|
|
24
|
+
varyByQuery: ["category", "page"],
|
|
25
|
+
tags: ["products"],
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
app.get("/assets/config.json", () => Results.json({ version: 1 }))
|
|
29
|
+
.cacheHeaders({
|
|
30
|
+
cacheControl: "public, max-age=60",
|
|
31
|
+
vary: ["Accept-Encoding"],
|
|
32
|
+
etag: true,
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
export default app;
|