@sixthsummit/ship-api 0.0.0-stage → 4.1.1
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/CHANGELOG.md +605 -0
- package/LICENSE +202 -0
- package/NOTICE +4 -0
- package/README.md +58 -2
- package/cli/commands/add.js +537 -0
- package/cli/commands/contract.js +2 -0
- package/cli/commands/create.js +250 -0
- package/cli/commands/dev.js +227 -0
- package/cli/commands/doctor.js +286 -0
- package/cli/commands/generate.js +937 -0
- package/cli/commands/graph.js +2 -0
- package/cli/commands/migrate-orm.js +1171 -0
- package/cli/commands/update.js +37 -0
- package/cli/ship-api.js +285 -0
- package/lib/app/auth/AuthProvider.d.ts +91 -0
- package/lib/app/auth/AuthProvider.d.ts.map +1 -0
- package/lib/app/auth/AuthProvider.js +13 -0
- package/lib/app/auth/AuthProvider.js.map +1 -0
- package/lib/app/auth/adapters/firebase.d.ts +79 -0
- package/lib/app/auth/adapters/firebase.d.ts.map +1 -0
- package/lib/app/auth/adapters/firebase.js +122 -0
- package/lib/app/auth/adapters/firebase.js.map +1 -0
- package/lib/app/auth/adapters/jwtCookie.d.ts +55 -0
- package/lib/app/auth/adapters/jwtCookie.d.ts.map +1 -0
- package/lib/app/auth/adapters/jwtCookie.js +120 -0
- package/lib/app/auth/adapters/jwtCookie.js.map +1 -0
- package/lib/app/auth/index.d.ts +8 -0
- package/lib/app/auth/index.d.ts.map +1 -0
- package/lib/app/auth/index.js +7 -0
- package/lib/app/auth/index.js.map +1 -0
- package/lib/app/auth/jwt/AuthFlow.d.ts +94 -0
- package/lib/app/auth/jwt/AuthFlow.d.ts.map +1 -0
- package/lib/app/auth/jwt/AuthFlow.js +127 -0
- package/lib/app/auth/jwt/AuthFlow.js.map +1 -0
- package/lib/app/auth/jwt/DrizzleRefreshTokenStore.d.ts +80 -0
- package/lib/app/auth/jwt/DrizzleRefreshTokenStore.d.ts.map +1 -0
- package/lib/app/auth/jwt/DrizzleRefreshTokenStore.js +134 -0
- package/lib/app/auth/jwt/DrizzleRefreshTokenStore.js.map +1 -0
- package/lib/app/auth/jwt/JwtSigner.d.ts +123 -0
- package/lib/app/auth/jwt/JwtSigner.d.ts.map +1 -0
- package/lib/app/auth/jwt/JwtSigner.js +118 -0
- package/lib/app/auth/jwt/JwtSigner.js.map +1 -0
- package/lib/app/auth/jwt/RefreshTokenStore.d.ts +97 -0
- package/lib/app/auth/jwt/RefreshTokenStore.d.ts.map +1 -0
- package/lib/app/auth/jwt/RefreshTokenStore.js +122 -0
- package/lib/app/auth/jwt/RefreshTokenStore.js.map +1 -0
- package/lib/app/auth/permissionDefinition.d.ts +20 -0
- package/lib/app/auth/permissionDefinition.d.ts.map +1 -0
- package/lib/app/auth/permissionDefinition.js +2 -0
- package/lib/app/auth/permissionDefinition.js.map +1 -0
- package/lib/app/context/RequestContext.d.ts +59 -0
- package/lib/app/context/RequestContext.d.ts.map +1 -0
- package/lib/app/context/RequestContext.js +25 -0
- package/lib/app/context/RequestContext.js.map +1 -0
- package/lib/app/db/QueryOptions.d.ts +82 -0
- package/lib/app/db/QueryOptions.d.ts.map +1 -0
- package/lib/app/db/QueryOptions.js +37 -0
- package/lib/app/db/QueryOptions.js.map +1 -0
- package/lib/app/db/baseFields.d.ts +60 -0
- package/lib/app/db/baseFields.d.ts.map +1 -0
- package/lib/app/db/baseFields.js +54 -0
- package/lib/app/db/baseFields.js.map +1 -0
- package/lib/app/db/buildWhere.d.ts +22 -0
- package/lib/app/db/buildWhere.d.ts.map +1 -0
- package/lib/app/db/buildWhere.js +75 -0
- package/lib/app/db/buildWhere.js.map +1 -0
- package/lib/app/db/client.d.ts +111 -0
- package/lib/app/db/client.d.ts.map +1 -0
- package/lib/app/db/client.js +99 -0
- package/lib/app/db/client.js.map +1 -0
- package/lib/app/db/tenantScoped.d.ts +59 -0
- package/lib/app/db/tenantScoped.d.ts.map +1 -0
- package/lib/app/db/tenantScoped.js +54 -0
- package/lib/app/db/tenantScoped.js.map +1 -0
- package/lib/app/db/transaction.d.ts +58 -0
- package/lib/app/db/transaction.d.ts.map +1 -0
- package/lib/app/db/transaction.js +106 -0
- package/lib/app/db/transaction.js.map +1 -0
- package/lib/app/health/HealthCheck.d.ts +121 -0
- package/lib/app/health/HealthCheck.d.ts.map +1 -0
- package/lib/app/health/HealthCheck.js +151 -0
- package/lib/app/health/HealthCheck.js.map +1 -0
- package/lib/app/health/redisHealthCheck.d.ts +14 -0
- package/lib/app/health/redisHealthCheck.d.ts.map +1 -0
- package/lib/app/health/redisHealthCheck.js +21 -0
- package/lib/app/health/redisHealthCheck.js.map +1 -0
- package/lib/app/lifecycle/Bootstrapper.d.ts +92 -0
- package/lib/app/lifecycle/Bootstrapper.d.ts.map +1 -0
- package/lib/app/lifecycle/Bootstrapper.js +99 -0
- package/lib/app/lifecycle/Bootstrapper.js.map +1 -0
- package/lib/app/registry/routes.d.ts +89 -0
- package/lib/app/registry/routes.d.ts.map +1 -0
- package/lib/app/registry/routes.js +72 -0
- package/lib/app/registry/routes.js.map +1 -0
- package/lib/app/services/DrizzleEntityService.d.ts +123 -0
- package/lib/app/services/DrizzleEntityService.d.ts.map +1 -0
- package/lib/app/services/DrizzleEntityService.js +342 -0
- package/lib/app/services/DrizzleEntityService.js.map +1 -0
- package/lib/app/services/RedisProvider.d.ts +52 -0
- package/lib/app/services/RedisProvider.d.ts.map +1 -0
- package/lib/app/services/RedisProvider.js +75 -0
- package/lib/app/services/RedisProvider.js.map +1 -0
- package/lib/app/services/cache/Cache.d.ts +70 -0
- package/lib/app/services/cache/Cache.d.ts.map +1 -0
- package/lib/app/services/cache/Cache.js +18 -0
- package/lib/app/services/cache/Cache.js.map +1 -0
- package/lib/app/services/cache/InMemoryCache.d.ts +35 -0
- package/lib/app/services/cache/InMemoryCache.d.ts.map +1 -0
- package/lib/app/services/cache/InMemoryCache.js +76 -0
- package/lib/app/services/cache/InMemoryCache.js.map +1 -0
- package/lib/app/services/cache/RedisCache.d.ts +99 -0
- package/lib/app/services/cache/RedisCache.d.ts.map +1 -0
- package/lib/app/services/cache/RedisCache.js +150 -0
- package/lib/app/services/cache/RedisCache.js.map +1 -0
- package/lib/app/services/cache/cached.d.ts +30 -0
- package/lib/app/services/cache/cached.d.ts.map +1 -0
- package/lib/app/services/cache/cached.js +38 -0
- package/lib/app/services/cache/cached.js.map +1 -0
- package/lib/app/services/cache/index.d.ts +5 -0
- package/lib/app/services/cache/index.d.ts.map +1 -0
- package/lib/app/services/cache/index.js +4 -0
- package/lib/app/services/cache/index.js.map +1 -0
- package/lib/app/services/cron/defineCron.d.ts +57 -0
- package/lib/app/services/cron/defineCron.d.ts.map +1 -0
- package/lib/app/services/cron/defineCron.js +15 -0
- package/lib/app/services/cron/defineCron.js.map +1 -0
- package/lib/app/services/cron/index.d.ts +2 -0
- package/lib/app/services/cron/index.d.ts.map +1 -0
- package/lib/app/services/cron/index.js +2 -0
- package/lib/app/services/cron/index.js.map +1 -0
- package/lib/app/services/hooks/LifecycleHooks.d.ts +61 -0
- package/lib/app/services/hooks/LifecycleHooks.d.ts.map +1 -0
- package/lib/app/services/hooks/LifecycleHooks.js +85 -0
- package/lib/app/services/hooks/LifecycleHooks.js.map +1 -0
- package/lib/app/services/jobs/JobsManager.d.ts +67 -0
- package/lib/app/services/jobs/JobsManager.d.ts.map +1 -0
- package/lib/app/services/jobs/JobsManager.js +121 -0
- package/lib/app/services/jobs/JobsManager.js.map +1 -0
- package/lib/app/services/jobs/bullBoard.d.ts +72 -0
- package/lib/app/services/jobs/bullBoard.d.ts.map +1 -0
- package/lib/app/services/jobs/bullBoard.js +96 -0
- package/lib/app/services/jobs/bullBoard.js.map +1 -0
- package/lib/app/services/jobs/defineJob.d.ts +81 -0
- package/lib/app/services/jobs/defineJob.d.ts.map +1 -0
- package/lib/app/services/jobs/defineJob.js +49 -0
- package/lib/app/services/jobs/defineJob.js.map +1 -0
- package/lib/app/services/jobs/index.d.ts +4 -0
- package/lib/app/services/jobs/index.d.ts.map +1 -0
- package/lib/app/services/jobs/index.js +4 -0
- package/lib/app/services/jobs/index.js.map +1 -0
- package/lib/app/services/rateLimit/InMemorySlidingWindowBackend.d.ts +23 -0
- package/lib/app/services/rateLimit/InMemorySlidingWindowBackend.d.ts.map +1 -0
- package/lib/app/services/rateLimit/InMemorySlidingWindowBackend.js +51 -0
- package/lib/app/services/rateLimit/InMemorySlidingWindowBackend.js.map +1 -0
- package/lib/app/services/rateLimit/RateLimitBackend.d.ts +41 -0
- package/lib/app/services/rateLimit/RateLimitBackend.d.ts.map +1 -0
- package/lib/app/services/rateLimit/RateLimitBackend.js +19 -0
- package/lib/app/services/rateLimit/RateLimitBackend.js.map +1 -0
- package/lib/app/services/rateLimit/RedisSlidingWindowBackend.d.ts +16 -0
- package/lib/app/services/rateLimit/RedisSlidingWindowBackend.d.ts.map +1 -0
- package/lib/app/services/rateLimit/RedisSlidingWindowBackend.js +80 -0
- package/lib/app/services/rateLimit/RedisSlidingWindowBackend.js.map +1 -0
- package/lib/app/services/rateLimit/index.d.ts +4 -0
- package/lib/app/services/rateLimit/index.d.ts.map +1 -0
- package/lib/app/services/rateLimit/index.js +3 -0
- package/lib/app/services/rateLimit/index.js.map +1 -0
- package/lib/app/services/storage/DiskStorageAdapter.d.ts +62 -0
- package/lib/app/services/storage/DiskStorageAdapter.d.ts.map +1 -0
- package/lib/app/services/storage/DiskStorageAdapter.js +295 -0
- package/lib/app/services/storage/DiskStorageAdapter.js.map +1 -0
- package/lib/app/services/storage/GCSStorageAdapter.d.ts +44 -0
- package/lib/app/services/storage/GCSStorageAdapter.d.ts.map +1 -0
- package/lib/app/services/storage/GCSStorageAdapter.js +133 -0
- package/lib/app/services/storage/GCSStorageAdapter.js.map +1 -0
- package/lib/app/services/storage/S3StorageAdapter.d.ts +57 -0
- package/lib/app/services/storage/S3StorageAdapter.d.ts.map +1 -0
- package/lib/app/services/storage/S3StorageAdapter.js +162 -0
- package/lib/app/services/storage/S3StorageAdapter.js.map +1 -0
- package/lib/app/services/storage/StorageService.d.ts +88 -0
- package/lib/app/services/storage/StorageService.d.ts.map +1 -0
- package/lib/app/services/storage/StorageService.js +18 -0
- package/lib/app/services/storage/StorageService.js.map +1 -0
- package/lib/app/services/storage/index.d.ts +5 -0
- package/lib/app/services/storage/index.d.ts.map +1 -0
- package/lib/app/services/storage/index.js +4 -0
- package/lib/app/services/storage/index.js.map +1 -0
- package/lib/app/utils/ContextValidators.d.ts +46 -0
- package/lib/app/utils/ContextValidators.d.ts.map +1 -0
- package/lib/app/utils/ContextValidators.js +81 -0
- package/lib/app/utils/ContextValidators.js.map +1 -0
- package/lib/app/utils/defineEnv.d.ts +80 -0
- package/lib/app/utils/defineEnv.d.ts.map +1 -0
- package/lib/app/utils/defineEnv.js +95 -0
- package/lib/app/utils/defineEnv.js.map +1 -0
- package/lib/client.d.ts +139 -0
- package/lib/client.d.ts.map +1 -0
- package/lib/client.js +98 -0
- package/lib/client.js.map +1 -0
- package/lib/contract/application.d.ts +3 -0
- package/lib/contract/application.d.ts.map +1 -0
- package/lib/contract/application.js +2 -0
- package/lib/contract/application.js.map +1 -0
- package/lib/contract/client.d.ts +3 -0
- package/lib/contract/client.d.ts.map +1 -0
- package/lib/contract/client.js +3 -0
- package/lib/contract/client.js.map +1 -0
- package/lib/contract/index.d.ts +3 -0
- package/lib/contract/index.d.ts.map +1 -0
- package/lib/contract/index.js +3 -0
- package/lib/contract/index.js.map +1 -0
- package/lib/contract/manifest.d.ts +3 -0
- package/lib/contract/manifest.d.ts.map +1 -0
- package/lib/contract/manifest.js +2 -0
- package/lib/contract/manifest.js.map +1 -0
- package/lib/contract/openapi.d.ts +3 -0
- package/lib/contract/openapi.d.ts.map +1 -0
- package/lib/contract/openapi.js +3 -0
- package/lib/contract/openapi.js.map +1 -0
- package/lib/contract/project.d.ts +3 -0
- package/lib/contract/project.d.ts.map +1 -0
- package/lib/contract/project.js +3 -0
- package/lib/contract/project.js.map +1 -0
- package/lib/contract/schema.d.ts +3 -0
- package/lib/contract/schema.d.ts.map +1 -0
- package/lib/contract/schema.js +3 -0
- package/lib/contract/schema.js.map +1 -0
- package/lib/drizzle/index.d.ts +3 -0
- package/lib/drizzle/index.d.ts.map +1 -0
- package/lib/drizzle/index.js +3 -0
- package/lib/drizzle/index.js.map +1 -0
- package/lib/hono/auth.d.ts +6 -0
- package/lib/hono/auth.d.ts.map +1 -0
- package/lib/hono/auth.js +54 -0
- package/lib/hono/auth.js.map +1 -0
- package/lib/hono/index.d.ts +4 -0
- package/lib/hono/index.d.ts.map +1 -0
- package/lib/hono/index.js +4 -0
- package/lib/hono/index.js.map +1 -0
- package/lib/http/app/createApp.d.ts +132 -0
- package/lib/http/app/createApp.d.ts.map +1 -0
- package/lib/http/app/createApp.js +215 -0
- package/lib/http/app/createApp.js.map +1 -0
- package/lib/http/app/devRoutes.d.ts +31 -0
- package/lib/http/app/devRoutes.d.ts.map +1 -0
- package/lib/http/app/devRoutes.js +145 -0
- package/lib/http/app/devRoutes.js.map +1 -0
- package/lib/http/app/errors.d.ts +45 -0
- package/lib/http/app/errors.d.ts.map +1 -0
- package/lib/http/app/errors.js +93 -0
- package/lib/http/app/errors.js.map +1 -0
- package/lib/http/app/health.d.ts +66 -0
- package/lib/http/app/health.d.ts.map +1 -0
- package/lib/http/app/health.js +104 -0
- package/lib/http/app/health.js.map +1 -0
- package/lib/http/errors/AppError.d.ts +10 -0
- package/lib/http/errors/AppError.d.ts.map +1 -0
- package/lib/http/errors/AppError.js +19 -0
- package/lib/http/errors/AppError.js.map +1 -0
- package/lib/http/errors/AuthenticationError.d.ts +8 -0
- package/lib/http/errors/AuthenticationError.d.ts.map +1 -0
- package/lib/http/errors/AuthenticationError.js +10 -0
- package/lib/http/errors/AuthenticationError.js.map +1 -0
- package/lib/http/errors/AuthorizationError.d.ts +8 -0
- package/lib/http/errors/AuthorizationError.d.ts.map +1 -0
- package/lib/http/errors/AuthorizationError.js +10 -0
- package/lib/http/errors/AuthorizationError.js.map +1 -0
- package/lib/http/errors/BadRequestError.d.ts +8 -0
- package/lib/http/errors/BadRequestError.d.ts.map +1 -0
- package/lib/http/errors/BadRequestError.js +10 -0
- package/lib/http/errors/BadRequestError.js.map +1 -0
- package/lib/http/errors/ConflictError.d.ts +8 -0
- package/lib/http/errors/ConflictError.d.ts.map +1 -0
- package/lib/http/errors/ConflictError.js +10 -0
- package/lib/http/errors/ConflictError.js.map +1 -0
- package/lib/http/errors/InternalServerError.d.ts +8 -0
- package/lib/http/errors/InternalServerError.d.ts.map +1 -0
- package/lib/http/errors/InternalServerError.js +10 -0
- package/lib/http/errors/InternalServerError.js.map +1 -0
- package/lib/http/errors/NotFoundError.d.ts +8 -0
- package/lib/http/errors/NotFoundError.d.ts.map +1 -0
- package/lib/http/errors/NotFoundError.js +10 -0
- package/lib/http/errors/NotFoundError.js.map +1 -0
- package/lib/http/errors/RateLimitError.d.ts +13 -0
- package/lib/http/errors/RateLimitError.d.ts.map +1 -0
- package/lib/http/errors/RateLimitError.js +16 -0
- package/lib/http/errors/RateLimitError.js.map +1 -0
- package/lib/http/errors/ServiceUnavailableError.d.ts +8 -0
- package/lib/http/errors/ServiceUnavailableError.d.ts.map +1 -0
- package/lib/http/errors/ServiceUnavailableError.js +10 -0
- package/lib/http/errors/ServiceUnavailableError.js.map +1 -0
- package/lib/http/errors/ValidationError.d.ts +9 -0
- package/lib/http/errors/ValidationError.d.ts.map +1 -0
- package/lib/http/errors/ValidationError.js +12 -0
- package/lib/http/errors/ValidationError.js.map +1 -0
- package/lib/http/errors/index.d.ts +11 -0
- package/lib/http/errors/index.d.ts.map +1 -0
- package/lib/http/errors/index.js +12 -0
- package/lib/http/errors/index.js.map +1 -0
- package/lib/http/middleware/apiKey.d.ts +9 -0
- package/lib/http/middleware/apiKey.d.ts.map +1 -0
- package/lib/http/middleware/apiKey.js +71 -0
- package/lib/http/middleware/apiKey.js.map +1 -0
- package/lib/http/middleware/csrf.d.ts +63 -0
- package/lib/http/middleware/csrf.d.ts.map +1 -0
- package/lib/http/middleware/csrf.js +169 -0
- package/lib/http/middleware/csrf.js.map +1 -0
- package/lib/http/middleware/httpLogger.d.ts +39 -0
- package/lib/http/middleware/httpLogger.d.ts.map +1 -0
- package/lib/http/middleware/httpLogger.js +118 -0
- package/lib/http/middleware/httpLogger.js.map +1 -0
- package/lib/http/middleware/idempotency.d.ts +48 -0
- package/lib/http/middleware/idempotency.d.ts.map +1 -0
- package/lib/http/middleware/idempotency.js +180 -0
- package/lib/http/middleware/idempotency.js.map +1 -0
- package/lib/http/middleware/rateLimit.d.ts +105 -0
- package/lib/http/middleware/rateLimit.d.ts.map +1 -0
- package/lib/http/middleware/rateLimit.js +84 -0
- package/lib/http/middleware/rateLimit.js.map +1 -0
- package/lib/http/middleware/requireAuth.d.ts +58 -0
- package/lib/http/middleware/requireAuth.d.ts.map +1 -0
- package/lib/http/middleware/requireAuth.js +63 -0
- package/lib/http/middleware/requireAuth.js.map +1 -0
- package/lib/http/middleware/requirePermission.d.ts +23 -0
- package/lib/http/middleware/requirePermission.d.ts.map +1 -0
- package/lib/http/middleware/requirePermission.js +50 -0
- package/lib/http/middleware/requirePermission.js.map +1 -0
- package/lib/http/middleware/resolveTenant.d.ts +41 -0
- package/lib/http/middleware/resolveTenant.d.ts.map +1 -0
- package/lib/http/middleware/resolveTenant.js +17 -0
- package/lib/http/middleware/resolveTenant.js.map +1 -0
- package/lib/http/streaming/sse.d.ts +31 -0
- package/lib/http/streaming/sse.d.ts.map +1 -0
- package/lib/http/streaming/sse.js +11 -0
- package/lib/http/streaming/sse.js.map +1 -0
- package/lib/http/streaming/streamLLM.d.ts +94 -0
- package/lib/http/streaming/streamLLM.d.ts.map +1 -0
- package/lib/http/streaming/streamLLM.js +94 -0
- package/lib/http/streaming/streamLLM.js.map +1 -0
- package/lib/http/utils/authCookies.d.ts +74 -0
- package/lib/http/utils/authCookies.d.ts.map +1 -0
- package/lib/http/utils/authCookies.js +102 -0
- package/lib/http/utils/authCookies.js.map +1 -0
- package/lib/http/utils/clientIp.d.ts +85 -0
- package/lib/http/utils/clientIp.d.ts.map +1 -0
- package/lib/http/utils/clientIp.js +249 -0
- package/lib/http/utils/clientIp.js.map +1 -0
- package/lib/http/utils/index.d.ts +4 -0
- package/lib/http/utils/index.d.ts.map +1 -0
- package/lib/http/utils/index.js +5 -0
- package/lib/http/utils/index.js.map +1 -0
- package/lib/http/utils/metaTags.d.ts +49 -0
- package/lib/http/utils/metaTags.d.ts.map +1 -0
- package/lib/http/utils/metaTags.js +32 -0
- package/lib/http/utils/metaTags.js.map +1 -0
- package/lib/http/utils/publicSuffix.d.ts +34 -0
- package/lib/http/utils/publicSuffix.d.ts.map +1 -0
- package/lib/http/utils/publicSuffix.js +276 -0
- package/lib/http/utils/publicSuffix.js.map +1 -0
- package/lib/http/utils/uploads.d.ts +92 -0
- package/lib/http/utils/uploads.d.ts.map +1 -0
- package/lib/http/utils/uploads.js +126 -0
- package/lib/http/utils/uploads.js.map +1 -0
- package/lib/http/utils/validate.d.ts +41 -0
- package/lib/http/utils/validate.d.ts.map +1 -0
- package/lib/http/utils/validate.js +55 -0
- package/lib/http/utils/validate.js.map +1 -0
- package/lib/http/utils/webhooks.d.ts +63 -0
- package/lib/http/utils/webhooks.d.ts.map +1 -0
- package/lib/http/utils/webhooks.js +133 -0
- package/lib/http/utils/webhooks.js.map +1 -0
- package/lib/http/ws/auth.d.ts +46 -0
- package/lib/http/ws/auth.d.ts.map +1 -0
- package/lib/http/ws/auth.js +123 -0
- package/lib/http/ws/auth.js.map +1 -0
- package/lib/index.d.ts +80 -0
- package/lib/index.d.ts.map +1 -0
- package/lib/index.js +61 -0
- package/lib/index.js.map +1 -0
- package/lib/kernel/index.d.ts +3 -0
- package/lib/kernel/index.d.ts.map +1 -0
- package/lib/kernel/index.js +3 -0
- package/lib/kernel/index.js.map +1 -0
- package/lib/libraries/.gitkeep +0 -0
- package/lib/libraries/ai/CHANGELOG.md +17 -0
- package/lib/libraries/ai/README.md +164 -0
- package/lib/libraries/ai/adapters/AnthropicAdapter.ts +382 -0
- package/lib/libraries/ai/adapters/LLMProvider.ts +76 -0
- package/lib/libraries/ai/adapters/OpenAIAdapter.ts +466 -0
- package/lib/libraries/ai/experimental/index.ts +20 -0
- package/lib/libraries/ai/index.ts +128 -0
- package/lib/libraries/ai/library.json +19 -0
- package/lib/libraries/ai/loop/agentLoop.ts +377 -0
- package/lib/libraries/ai/prompts/definePrompt.ts +0 -0
- package/lib/libraries/ai/rag/retrieveAndAnswer.ts +177 -0
- package/lib/libraries/ai/streaming/streamLLM.ts +94 -0
- package/lib/libraries/ai/structured/completeStructured.ts +143 -0
- package/lib/libraries/ai/tokens/Tokenizer.ts +216 -0
- package/lib/libraries/ai/tools/defineTool.ts +208 -0
- package/lib/libraries/ai/types.ts +260 -0
- package/lib/libraries/chunking/ChunkingService.ts +103 -0
- package/lib/libraries/chunking/README.md +104 -0
- package/lib/libraries/chunking/docs/api-reference.md +549 -0
- package/lib/libraries/chunking/docs/best-practices.md +321 -0
- package/lib/libraries/chunking/docs/code-organization.md +538 -0
- package/lib/libraries/chunking/docs/configuration.md +418 -0
- package/lib/libraries/chunking/docs/index.md +236 -0
- package/lib/libraries/chunking/docs/quick-start.md +298 -0
- package/lib/libraries/chunking/docs/strategies.md +407 -0
- package/lib/libraries/chunking/docs/summary.md +258 -0
- package/lib/libraries/chunking/docs/troubleshooting.md +527 -0
- package/lib/libraries/chunking/index.ts +17 -0
- package/lib/libraries/chunking/library.json +16 -0
- package/lib/libraries/chunking/strategies/ChunkingStrategy.ts +13 -0
- package/lib/libraries/chunking/strategies/FixedLengthChunkingStrategy.ts +88 -0
- package/lib/libraries/chunking/strategies/SemanticChunkingStrategy.ts +389 -0
- package/lib/libraries/chunking/strategies/SlidingWindowChunkingStrategy.ts +258 -0
- package/lib/libraries/chunking/types/index.ts +63 -0
- package/lib/libraries/email/EmailService.ts +591 -0
- package/lib/libraries/email/README.md +777 -0
- package/lib/libraries/email/TemplateRegistry.ts +148 -0
- package/lib/libraries/email/TemplateRenderer.ts +273 -0
- package/lib/libraries/email/index.ts +4 -0
- package/lib/libraries/email/initializeEmailService.ts +60 -0
- package/lib/libraries/email/library.json +12 -0
- package/lib/libraries/email/types/EmailAddress.ts +4 -0
- package/lib/libraries/email/types/EmailAttachment.ts +11 -0
- package/lib/libraries/email/types/EmailTag.ts +9 -0
- package/lib/libraries/email/types/EmailTemplate.ts +124 -0
- package/lib/libraries/email/types/SendBatchEmailsOptions.ts +9 -0
- package/lib/libraries/email/types/SendBatchEmailsResult.ts +9 -0
- package/lib/libraries/email/types/SendEmailOptions.ts +33 -0
- package/lib/libraries/email/types/SendEmailResult.ts +9 -0
- package/lib/libraries/email/types/index.ts +8 -0
- package/lib/libraries/weaviate/QueryBuilder.ts +292 -0
- package/lib/libraries/weaviate/README.md +284 -0
- package/lib/libraries/weaviate/Weaviate.ts +1419 -0
- package/lib/libraries/weaviate/WeaviateConfig.ts +268 -0
- package/lib/libraries/weaviate/docs/.gitkeep +1 -0
- package/lib/libraries/weaviate/docs/API_REFERENCE.md +1067 -0
- package/lib/libraries/weaviate/docs/CONFIGURATION.md +320 -0
- package/lib/libraries/weaviate/docs/ERROR_HANDLING.md +271 -0
- package/lib/libraries/weaviate/docs/MULTI_TENANCY.md +348 -0
- package/lib/libraries/weaviate/docs/PERFORMANCE.md +602 -0
- package/lib/libraries/weaviate/docs/PLUGIN_DEVELOPMENT.md +547 -0
- package/lib/libraries/weaviate/docs/QUICK_START.md +443 -0
- package/lib/libraries/weaviate/docs/README.md +269 -0
- package/lib/libraries/weaviate/docs/SCHEMA_GUIDE.md +630 -0
- package/lib/libraries/weaviate/docs/WEAVIATE_README.md +520 -0
- package/lib/libraries/weaviate/errors/WeaviateError.ts +92 -0
- package/lib/libraries/weaviate/errors/index.ts +1 -0
- package/lib/libraries/weaviate/index.ts +35 -0
- package/lib/libraries/weaviate/library.json +26 -0
- package/lib/libraries/weaviate/plugins/index.ts +2 -0
- package/lib/libraries/weaviate/schemas/SchemaRegistry.ts +284 -0
- package/lib/libraries/weaviate/schemas/index.ts +2 -0
- package/lib/libraries/weaviate/types/BM25SearchOptions.ts +9 -0
- package/lib/libraries/weaviate/types/ExtendedWeaviateClient.ts +7 -0
- package/lib/libraries/weaviate/types/HybridSearchOptions.ts +11 -0
- package/lib/libraries/weaviate/types/MultiTenancy.ts +81 -0
- package/lib/libraries/weaviate/types/Plugin.ts +17 -0
- package/lib/libraries/weaviate/types/SchemaConfig.ts +25 -0
- package/lib/libraries/weaviate/types/SearchMethod.ts +8 -0
- package/lib/libraries/weaviate/types/SearchOptions.ts +16 -0
- package/lib/libraries/weaviate/types/SearchRequest.ts +19 -0
- package/lib/libraries/weaviate/types/SearchResult.ts +16 -0
- package/lib/libraries/weaviate/types/SearchableField.ts +87 -0
- package/lib/libraries/weaviate/types/VectorIndexConfig.ts +19 -0
- package/lib/libraries/weaviate/types/VectorSearchOptions.ts +18 -0
- package/lib/libraries/weaviate/types/VectorizerConfig.ts +8 -0
- package/lib/libraries/weaviate/types/index.ts +29 -0
- package/lib/libraries/weaviate/utils/TenantContextManager.ts +94 -0
- package/lib/modules/accounts/index.ts +47 -0
- package/lib/modules/accounts/module.json +15 -0
- package/lib/modules/accounts/permissions.ts +33 -0
- package/lib/modules/accounts/routes.ts +200 -0
- package/lib/modules/accounts/schema.ts +219 -0
- package/lib/modules/accounts/services/AccountService.ts +44 -0
- package/lib/modules/accounts/validation/schemas.ts +70 -0
- package/lib/modules/oauth/adapters/GmailOAuthAdapter.ts +35 -0
- package/lib/modules/oauth/adapters/GoogleOAuthAdapter.ts +278 -0
- package/lib/modules/oauth/adapters/MicrosoftOAuthAdapter.ts +269 -0
- package/lib/modules/oauth/adapters/MockOAuthAdapter.ts +138 -0
- package/lib/modules/oauth/adapters/OAuthAdapter.ts +211 -0
- package/lib/modules/oauth/adapters/OAuthAdapterRegistry.ts +77 -0
- package/lib/modules/oauth/adapters/OutlookOAuthAdapter.ts +38 -0
- package/lib/modules/oauth/index.ts +79 -0
- package/lib/modules/oauth/module.json +23 -0
- package/lib/modules/oauth/permissions.ts +39 -0
- package/lib/modules/oauth/routes.ts +497 -0
- package/lib/modules/oauth/schema.ts +127 -0
- package/lib/modules/oauth/services/OAuthConnectionService.ts +147 -0
- package/lib/modules/oauth/state.ts +234 -0
- package/lib/modules/oauth/stateJtiCache.ts +85 -0
- package/lib/modules/oauth/verifyIdToken.ts +178 -0
- package/lib/modules/outbox/EventEmitter.ts +106 -0
- package/lib/modules/outbox/OutboxDrainer.ts +163 -0
- package/lib/modules/outbox/handlers/EventHandler.ts +115 -0
- package/lib/modules/outbox/index.ts +43 -0
- package/lib/modules/outbox/module.json +15 -0
- package/lib/modules/outbox/permissions.ts +36 -0
- package/lib/modules/outbox/routes.ts +219 -0
- package/lib/modules/outbox/schema.ts +207 -0
- package/lib/modules/outbox/services/OutboxEventService.ts +223 -0
- package/lib/observability/logger.d.ts +30 -0
- package/lib/observability/logger.d.ts.map +1 -0
- package/lib/observability/logger.js +110 -0
- package/lib/observability/logger.js.map +1 -0
- package/lib/observability/metrics.d.ts +3 -0
- package/lib/observability/metrics.d.ts.map +1 -0
- package/lib/observability/metrics.js +3 -0
- package/lib/observability/metrics.js.map +1 -0
- package/lib/observability/otel.d.ts +3 -0
- package/lib/observability/otel.d.ts.map +1 -0
- package/lib/observability/otel.js +3 -0
- package/lib/observability/otel.js.map +1 -0
- package/lib/observability/safeErrorFields.d.ts +14 -0
- package/lib/observability/safeErrorFields.d.ts.map +1 -0
- package/lib/observability/safeErrorFields.js +14 -0
- package/lib/observability/safeErrorFields.js.map +1 -0
- package/lib/observability/tracing.d.ts +3 -0
- package/lib/observability/tracing.d.ts.map +1 -0
- package/lib/observability/tracing.js +3 -0
- package/lib/observability/tracing.js.map +1 -0
- package/lib/package.json +4 -0
- package/lib/testing.d.ts +3 -0
- package/lib/testing.d.ts.map +1 -0
- package/lib/testing.js +3 -0
- package/lib/testing.js.map +1 -0
- package/package.json +193 -3
- package/templates/default/.claude/agents/qa-brief.md +106 -0
- package/templates/default/.claude/commands/sherpa-brief.md +23 -0
- package/templates/default/.cursor/rules/api.mdc +80 -0
- package/templates/default/.cursor/rules/commits.mdc +88 -0
- package/templates/default/.cursor/rules/security.mdc +92 -0
- package/templates/default/.cursor/rules/testing.mdc +123 -0
- package/templates/default/.cursor/rules/typescript.mdc +86 -0
- package/templates/default/.env.example +79 -0
- package/templates/default/.github/workflows/sherpa-brief.yml +180 -0
- package/templates/default/AGENTS.md +166 -0
- package/templates/default/CLAUDE.md +17 -0
- package/templates/default/README.md +97 -0
- package/templates/default/_gitignore +27 -0
- package/templates/default/docker-compose.yml +83 -0
- package/templates/default/drizzle.config.ts +34 -0
- package/templates/default/eslint.config.mjs +106 -0
- package/templates/default/package.json +57 -0
- package/templates/default/ship-api.config.ts +21 -0
- package/templates/default/src/client.ts +34 -0
- package/templates/default/src/config/modules.ts +23 -0
- package/templates/default/src/db/schema.ts +26 -0
- package/templates/default/src/environment.ts +81 -0
- package/templates/default/src/index.test.ts +53 -0
- package/templates/default/src/index.ts +11 -0
- package/templates/default/src/instrumentation.ts +13 -0
- package/templates/default/src/server.ts +90 -0
- package/templates/default/tsconfig.json +24 -0
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Module wiring — placeholder.
|
|
3
|
+
*
|
|
4
|
+
* Today, wire modules in `src/index.ts`: that's the type-safe seam for the
|
|
5
|
+
* `hc()` typed client. Each module exposes `buildXxxApp(deps)` — its own
|
|
6
|
+
* bounded sub-app — which you mount on the root with `root.route("/", ...)`.
|
|
7
|
+
* Mounting bounded sub-apps (rather than threading one shared app through
|
|
8
|
+
* every module) keeps each route-type instantiation bounded so the typed
|
|
9
|
+
* client scales. For example, after `ship-api add accounts`:
|
|
10
|
+
*
|
|
11
|
+
* // src/index.ts
|
|
12
|
+
* import { buildAccountsApp, AccountService } from "./modules/accounts/index.js";
|
|
13
|
+
* const { db } = createDb({ config: { connectionString: env.DATABASE_URL }, schema });
|
|
14
|
+
* const root = createApp({ cors });
|
|
15
|
+
* const app = root.route("/", buildAccountsApp({ service: new AccountService(db), provider }));
|
|
16
|
+
* export type ShipApiClient = typeof app;
|
|
17
|
+
*
|
|
18
|
+
* This file is reserved for a planned `ship-api` auto-wiring step that will
|
|
19
|
+
* generate explicit, type-preserving wiring from your installed modules. Until
|
|
20
|
+
* then it intentionally exports nothing — wire in `index.ts`.
|
|
21
|
+
*/
|
|
22
|
+
|
|
23
|
+
export {};
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Composed database schema — single source of truth for both:
|
|
3
|
+
* 1. The runtime via `createDb({ config, schema })` in `src/index.ts`.
|
|
4
|
+
* 2. The migration tooling via `drizzle.config.ts` (`schema:
|
|
5
|
+
* "./src/db/schema.ts"`).
|
|
6
|
+
*
|
|
7
|
+
* The framework ships no default tables — identity/RBAC lives in the
|
|
8
|
+
* `accounts` module (add it with `ship-api add accounts`). Compose each
|
|
9
|
+
* module's exported schema fragment here, then add your own module tables.
|
|
10
|
+
* For example, after `ship-api add accounts`:
|
|
11
|
+
*
|
|
12
|
+
* import { accountsSchema } from "../modules/accounts/index.js";
|
|
13
|
+
* export const schema = { ...accountsSchema, ...yourTables };
|
|
14
|
+
*/
|
|
15
|
+
|
|
16
|
+
// Compose module schema fragments as you add them:
|
|
17
|
+
// import { accountsSchema } from "../modules/accounts/index.js"; // ship-api add accounts
|
|
18
|
+
// import { posts, postsRelations } from "../modules/posts/schema.js"; // ship-api g resource posts
|
|
19
|
+
|
|
20
|
+
export const schema = {
|
|
21
|
+
// ...accountsSchema,
|
|
22
|
+
// posts,
|
|
23
|
+
// postsRelations,
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
export type Schema = typeof schema;
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import { defineEnv } from "@sixthsummit/ship-api";
|
|
2
|
+
import { z } from "zod";
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Runtime configuration boundary. `defineEnv` validates
|
|
6
|
+
* `process.env` against the Zod schema below at boot — fail-fast
|
|
7
|
+
* with a structured "missing/invalid: KEY" error instead of letting
|
|
8
|
+
* bad config produce silent runtime failures.
|
|
9
|
+
*
|
|
10
|
+
* Convention enforced by the project's eslint config: this file is the only
|
|
11
|
+
* application-config boundary for `process.env`. The dependency-free
|
|
12
|
+
* `instrumentation.ts` bootstrap is the intentional early exception. Module
|
|
13
|
+
* and handler code route through the typed `env` object exported below.
|
|
14
|
+
*/
|
|
15
|
+
export const env = defineEnv(
|
|
16
|
+
z.object({
|
|
17
|
+
// ─── Server ────────────────────────────────────────────────────
|
|
18
|
+
PORT: z.coerce.number().int().positive().default(3000),
|
|
19
|
+
NODE_ENV: z.enum(["development", "test", "production"]).default("development"),
|
|
20
|
+
LOG_LEVEL: z.enum(["fatal", "error", "warn", "info", "debug", "trace"]).default("info"),
|
|
21
|
+
/**
|
|
22
|
+
* Comma-separated CORS allowlist. The framework wires `hono/cors`
|
|
23
|
+
* with `credentials: true` against this list at `createApp()`.
|
|
24
|
+
* Browsers reject `origin: '*'` + `credentials: true`; the
|
|
25
|
+
* framework refuses to construct an app under that combination.
|
|
26
|
+
*
|
|
27
|
+
* Example: `CORS_ORIGINS=https://app.example.com,https://admin.example.com`
|
|
28
|
+
*/
|
|
29
|
+
CORS_ORIGINS: z
|
|
30
|
+
.string()
|
|
31
|
+
.optional()
|
|
32
|
+
.transform((value) =>
|
|
33
|
+
value
|
|
34
|
+
? value
|
|
35
|
+
.split(",")
|
|
36
|
+
.map((entry) => entry.trim())
|
|
37
|
+
.filter((entry) => entry.length > 0)
|
|
38
|
+
: undefined,
|
|
39
|
+
),
|
|
40
|
+
|
|
41
|
+
// ─── Database ──────────────────────────────────────────────────
|
|
42
|
+
DATABASE_URL: z.string().url(),
|
|
43
|
+
|
|
44
|
+
// ─── Auth ──────────────────────────────────────────────────────
|
|
45
|
+
OAUTH_STATE_SECRET: z.string().min(32),
|
|
46
|
+
JWT_SIGNING_KEY: z.string().optional(),
|
|
47
|
+
JWT_VERIFICATION_KEYS: z.string().optional(),
|
|
48
|
+
|
|
49
|
+
// ─── Redis (optional in dev, required for rate-limit + jobs) ───
|
|
50
|
+
REDIS_URL: z.string().url().optional(),
|
|
51
|
+
|
|
52
|
+
// ─── Admin (Bull-Board dashboard etc.) ─────────────────────────
|
|
53
|
+
// Required when mounting the Bull-Board admin UI via
|
|
54
|
+
// `createBullBoardApp({ apiKey: env.ADMIN_API_KEY })`. ≥32 random
|
|
55
|
+
// bytes; rotate independently of JWT keys. The dashboard is
|
|
56
|
+
// dev/staging-only — don't expose it on a public hostname even
|
|
57
|
+
// with the key set.
|
|
58
|
+
ADMIN_API_KEY: z.string().min(32).optional(),
|
|
59
|
+
|
|
60
|
+
// ─── Observability ─────────────────────────────────────────────
|
|
61
|
+
OTEL_SDK_DISABLED: z.string().optional(),
|
|
62
|
+
OTEL_EXPORTER_OTLP_ENDPOINT: z.string().url().optional(),
|
|
63
|
+
OTEL_SERVICE_NAME: z.string().default("ship-api-app"),
|
|
64
|
+
ENVIRONMENT_NAME: z.string().default("development"),
|
|
65
|
+
METRICS_ENABLED: z.string().optional(),
|
|
66
|
+
METRICS_PORT: z.coerce.number().int().positive().default(9464),
|
|
67
|
+
|
|
68
|
+
// ─── Firebase (default AuthProvider; swap for Better-Auth/etc.) ─
|
|
69
|
+
FIREBASE_CREDENTIALS: z.string().optional(),
|
|
70
|
+
|
|
71
|
+
// ─── OAuth providers (declare only what you support) ───────────
|
|
72
|
+
OAUTH_GOOGLE_CLIENT_ID: z.string().optional(),
|
|
73
|
+
OAUTH_GOOGLE_CLIENT_SECRET: z.string().optional(),
|
|
74
|
+
OAUTH_GOOGLE_REDIRECT_URI: z.string().url().optional(),
|
|
75
|
+
OAUTH_MICROSOFT_CLIENT_ID: z.string().optional(),
|
|
76
|
+
OAUTH_MICROSOFT_CLIENT_SECRET: z.string().optional(),
|
|
77
|
+
OAUTH_MICROSOFT_REDIRECT_URI: z.string().url().optional(),
|
|
78
|
+
}),
|
|
79
|
+
);
|
|
80
|
+
|
|
81
|
+
export type Env = typeof env;
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Sample test — exercises `createApp` end-to-end without booting a server.
|
|
3
|
+
* Hono apps are testable via `app.request(path, init)` which returns a
|
|
4
|
+
* standard `Response`. No supertest, no port binding, no test containers.
|
|
5
|
+
*
|
|
6
|
+
* Replace this file with real coverage as you add modules. Pattern to follow:
|
|
7
|
+
* - service unit tests at `modules/<name>/services/<Name>Service.test.ts`
|
|
8
|
+
* (fake-DB; cover service logic + lifecycle hooks)
|
|
9
|
+
* - route integration tests at `modules/<name>/routes.test.ts`
|
|
10
|
+
* (full requireAuth → requirePermission → validate → handler chain)
|
|
11
|
+
* - mirror the harness from `modules/accounts/routes.test.ts` in the
|
|
12
|
+
* framework monorepo for canonical structure.
|
|
13
|
+
*/
|
|
14
|
+
|
|
15
|
+
import { describe, it, expect } from "vitest";
|
|
16
|
+
import { createApp, registerErrorHandlers } from "@sixthsummit/ship-api";
|
|
17
|
+
|
|
18
|
+
describe("createApp", () => {
|
|
19
|
+
it("returns a Hono app that handles routes", async () => {
|
|
20
|
+
const app = createApp({});
|
|
21
|
+
app.get("/sample", (c) => c.json({ ok: true }));
|
|
22
|
+
|
|
23
|
+
const res = await app.request("/sample");
|
|
24
|
+
|
|
25
|
+
expect(res.status).toBe(200);
|
|
26
|
+
expect(await res.json()).toEqual({ ok: true });
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
it("serves /livez and /readyz with no extra wiring", async () => {
|
|
30
|
+
const app = createApp({});
|
|
31
|
+
|
|
32
|
+
const live = await app.request("/livez");
|
|
33
|
+
expect(live.status).toBe(200);
|
|
34
|
+
expect(await live.json()).toEqual({ ok: true });
|
|
35
|
+
|
|
36
|
+
const ready = await app.request("/readyz");
|
|
37
|
+
expect(ready.status).toBe(200);
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
it("shapes thrown errors via registerErrorHandlers", async () => {
|
|
41
|
+
const app = createApp({});
|
|
42
|
+
registerErrorHandlers(app);
|
|
43
|
+
app.get("/boom", () => {
|
|
44
|
+
throw new Error("kaboom");
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
const res = await app.request("/boom");
|
|
48
|
+
|
|
49
|
+
expect(res.status).toBe(500);
|
|
50
|
+
const body = (await res.json()) as { error?: { message?: string } };
|
|
51
|
+
expect(body.error).toBeDefined();
|
|
52
|
+
});
|
|
53
|
+
});
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Process bootstrap. Instrumentation is the only static runtime import:
|
|
3
|
+
* ESM evaluates every static dependency before running this body, so loading
|
|
4
|
+
* the application here would make auto-instrumentation too late.
|
|
5
|
+
*/
|
|
6
|
+
import "./instrumentation.js";
|
|
7
|
+
|
|
8
|
+
await import("./server.js");
|
|
9
|
+
|
|
10
|
+
// Type-only exports are erased and therefore do not load `server.js` early.
|
|
11
|
+
export type { ShipApiClient } from "./server.js";
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Telemetry bootstrap boundary. Keep this module independent from application
|
|
3
|
+
* code so the SDK starts before HTTP, database, Redis, or logging libraries
|
|
4
|
+
* are loaded. Direct environment reads are intentional at this early boundary:
|
|
5
|
+
* importing the application's validated environment would load the framework.
|
|
6
|
+
*/
|
|
7
|
+
import { startOtel } from "@sixthsummit/ship-observability-otel/sdk";
|
|
8
|
+
|
|
9
|
+
startOtel({
|
|
10
|
+
serviceName: process.env.OTEL_SERVICE_NAME ?? "ship-api-app",
|
|
11
|
+
serviceVersion: process.env.npm_package_version,
|
|
12
|
+
environmentName: process.env.ENVIRONMENT_NAME ?? process.env.NODE_ENV,
|
|
13
|
+
});
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Application composition root. `src/index.ts` starts OpenTelemetry and then
|
|
3
|
+
* loads this module dynamically so its dependencies can be instrumented.
|
|
4
|
+
*
|
|
5
|
+
* 1. validates env via `defineEnv` (already done in
|
|
6
|
+
* `./environment.ts` — importing it triggers validation).
|
|
7
|
+
* 2. composes the root app (`createApp({ cors })`) and mounts each
|
|
8
|
+
* module's sub-app via `root.route("/", buildXxxApp(deps))`.
|
|
9
|
+
* 3. wires the auth provider (Firebase by default; swap for
|
|
10
|
+
* Better-Auth/Clerk/WorkOS/Auth.js when those adapters land).
|
|
11
|
+
* 4. starts the HTTP server.
|
|
12
|
+
*
|
|
13
|
+
* The END of the route chain is exported as `ShipApiClient` so client
|
|
14
|
+
* consumers (web, mobile, microservices) can `hc<ShipApiClient>()`
|
|
15
|
+
* end-to-end-typed without codegen — see the v4 cross-framework
|
|
16
|
+
* contract in AGENTS.md. Hono's RPC types live on the RETURN VALUE of
|
|
17
|
+
* each chained `.get()`/`.post()` call — routes register at runtime
|
|
18
|
+
* either way, but a discarded return (or a `typeof app` taken from the
|
|
19
|
+
* bare `createApp()` result) produces a typed client with zero routes.
|
|
20
|
+
*/
|
|
21
|
+
|
|
22
|
+
import { serve } from "@hono/node-server";
|
|
23
|
+
import { createApp, registerErrorHandlers, httpLogger } from "@sixthsummit/ship-api";
|
|
24
|
+
import { logger } from "@sixthsummit/ship-api/observability/logger";
|
|
25
|
+
import { env } from "./environment.js";
|
|
26
|
+
// DB wiring (when you add modules): compose the schema via
|
|
27
|
+
// const { db } = createDb({ config: { connectionString: env.DATABASE_URL }, schema });
|
|
28
|
+
// import { createDb } from "@sixthsummit/ship-api/app/db/client";
|
|
29
|
+
// import { schema } from "./db/schema.js";
|
|
30
|
+
|
|
31
|
+
// ─── Compose the app ──────────────────────────────────────────────────
|
|
32
|
+
|
|
33
|
+
const app = createApp({
|
|
34
|
+
// CORS — driven by the `CORS_ORIGINS` env var (a comma-separated
|
|
35
|
+
// allowlist of origins). When unset the framework attaches no CORS
|
|
36
|
+
// middleware; cookies stay same-origin only.
|
|
37
|
+
cors: env.CORS_ORIGINS ? { origin: env.CORS_ORIGINS, credentials: true } : undefined,
|
|
38
|
+
// Health routes: `createApp` already mounts unauthenticated `GET /livez`
|
|
39
|
+
// and `GET /readyz`, ahead of every middleware below — no wiring needed.
|
|
40
|
+
// `createDb(...)` adds a `db.primary` readiness check once you add a
|
|
41
|
+
// database. Configure with `health: { prefix, readyzTimeoutMs }`, or opt
|
|
42
|
+
// out with `health: false`. Don't add `/healthz`: Cloud Run's front end
|
|
43
|
+
// intercepts that path before it reaches the container.
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
registerErrorHandlers(app);
|
|
47
|
+
app.use("*", httpLogger());
|
|
48
|
+
|
|
49
|
+
// Capture the chained return — `routes` carries this route's RPC type;
|
|
50
|
+
// a bare `app.get(...)` statement would register it but lose the type.
|
|
51
|
+
const routes = app.get("/", (c) => c.json({ ok: true, framework: "ship-api", version: "v4" }));
|
|
52
|
+
|
|
53
|
+
// ─── Wire your modules ────────────────────────────────────────────────
|
|
54
|
+
//
|
|
55
|
+
// Modules are copied into your app (e.g. `ship-api add accounts`), so you
|
|
56
|
+
// import them from your local `./modules/<name>`, not from the framework.
|
|
57
|
+
//
|
|
58
|
+
// Each module exposes `buildXxxApp(deps)` — its own bounded sub-app. Mount
|
|
59
|
+
// each onto the root with `.route("/", ...)`; modules keep their absolute
|
|
60
|
+
// paths, so the client stays flat (`api.accounts.$get`). Chain the mounts and
|
|
61
|
+
// point `ShipApiClient` at the end so every route's RPC type survives:
|
|
62
|
+
//
|
|
63
|
+
// import { buildAccountsApp, AccountService } from "./modules/accounts/index.js";
|
|
64
|
+
// import { createDb } from "@sixthsummit/ship-api/app/db/client";
|
|
65
|
+
// import { firebaseAuth } from "@sixthsummit/ship-api/app/auth/adapters/firebase";
|
|
66
|
+
// import { schema } from "./db/schema.js";
|
|
67
|
+
//
|
|
68
|
+
// const { db } = createDb({ config: { connectionString: env.DATABASE_URL }, schema });
|
|
69
|
+
// const accountService = new AccountService(db);
|
|
70
|
+
// const provider = firebaseAuth({ findAccount: (uid) => accountService.findByFirebaseUid(uid) });
|
|
71
|
+
// const routedApp = routes
|
|
72
|
+
// .route("/", buildAccountsApp({ service: accountService, provider }));
|
|
73
|
+
// export type ShipApiClient = typeof routedApp; // ← replaces the export below
|
|
74
|
+
//
|
|
75
|
+
// Mounting each module as its own sub-app (rather than threading one app
|
|
76
|
+
// through every `defineXxxRoutes`) keeps each route-type instantiation
|
|
77
|
+
// bounded, so the typed client scales to many modules without `tsc` overflow.
|
|
78
|
+
// ⚠️ Keep `registerErrorHandlers` + `httpLogger` + cors on the ROOT only —
|
|
79
|
+
// never set `onError`/`use("*")` inside a module sub-app (it would shadow the
|
|
80
|
+
// uniform AppError shape and per-request logging).
|
|
81
|
+
|
|
82
|
+
// ─── Export the App type for typed-client consumers ──────────────────
|
|
83
|
+
|
|
84
|
+
export type ShipApiClient = typeof routes;
|
|
85
|
+
|
|
86
|
+
// ─── Boot ─────────────────────────────────────────────────────────────
|
|
87
|
+
|
|
88
|
+
serve({ fetch: app.fetch, port: env.PORT }, (info) => {
|
|
89
|
+
logger.info({ port: info.port, environment: env.ENVIRONMENT_NAME }, "ship-api up");
|
|
90
|
+
});
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"lib": ["ES2022"],
|
|
4
|
+
"module": "NodeNext",
|
|
5
|
+
"moduleResolution": "NodeNext",
|
|
6
|
+
"target": "ES2022",
|
|
7
|
+
"outDir": "dist",
|
|
8
|
+
"rootDir": ".",
|
|
9
|
+
"strict": true,
|
|
10
|
+
"noImplicitReturns": true,
|
|
11
|
+
"noUnusedLocals": true,
|
|
12
|
+
"noFallthroughCasesInSwitch": true,
|
|
13
|
+
"exactOptionalPropertyTypes": false,
|
|
14
|
+
"esModuleInterop": true,
|
|
15
|
+
"skipLibCheck": true,
|
|
16
|
+
"resolveJsonModule": true,
|
|
17
|
+
"sourceMap": true,
|
|
18
|
+
"declaration": true,
|
|
19
|
+
"declarationMap": true,
|
|
20
|
+
"forceConsistentCasingInFileNames": true
|
|
21
|
+
},
|
|
22
|
+
"include": ["src/**/*", "drizzle.config.ts", "ship-api.config.ts"],
|
|
23
|
+
"exclude": ["node_modules", "dist"]
|
|
24
|
+
}
|