@bgord/bun 0.7.0 → 0.8.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/README.md +1 -3
- package/dist/api-key-shield.middleware.d.ts +14 -0
- package/dist/api-key-shield.middleware.d.ts.map +1 -0
- package/dist/api-key-shield.middleware.js +19 -0
- package/dist/api-key-shield.middleware.js.map +1 -0
- package/dist/api-version.middleware.d.ts +6 -0
- package/dist/api-version.middleware.d.ts.map +1 -0
- package/dist/api-version.middleware.js +12 -0
- package/dist/api-version.middleware.js.map +1 -0
- package/dist/auth-shield.middleware.d.ts +31 -0
- package/dist/auth-shield.middleware.d.ts.map +1 -0
- package/dist/auth-shield.middleware.js +83 -0
- package/dist/auth-shield.middleware.js.map +1 -0
- package/dist/basic-auth.d.ts +8 -0
- package/dist/basic-auth.d.ts.map +1 -1
- package/dist/basic-auth.js +9 -0
- package/dist/basic-auth.js.map +1 -1
- package/dist/basic-auth.service.d.ts +14 -0
- package/dist/basic-auth.service.d.ts.map +1 -0
- package/dist/basic-auth.service.js +13 -0
- package/dist/basic-auth.service.js.map +1 -0
- package/dist/build-info-repository.service.d.ts +10 -0
- package/dist/build-info-repository.service.d.ts.map +1 -0
- package/dist/build-info-repository.service.js +18 -0
- package/dist/build-info-repository.service.js.map +1 -0
- package/dist/cache-resolver.service.d.ts +46 -0
- package/dist/cache-resolver.service.d.ts.map +1 -0
- package/dist/cache-resolver.service.js +44 -0
- package/dist/cache-resolver.service.js.map +1 -0
- package/dist/cache-response.middleware.d.ts +9 -0
- package/dist/cache-response.middleware.d.ts.map +1 -0
- package/dist/cache-response.middleware.js +25 -0
- package/dist/cache-response.middleware.js.map +1 -0
- package/dist/cache-static-files.middleware.d.ts +9 -0
- package/dist/cache-static-files.middleware.d.ts.map +1 -0
- package/dist/cache-static-files.middleware.js +25 -0
- package/dist/cache-static-files.middleware.js.map +1 -0
- package/dist/context.middleware.d.ts +14 -0
- package/dist/context.middleware.d.ts.map +1 -0
- package/dist/context.middleware.js +11 -0
- package/dist/context.middleware.js.map +1 -0
- package/dist/correlation-id.d.ts.map +1 -1
- package/dist/correlation-id.vo.d.ts +4 -0
- package/dist/correlation-id.vo.d.ts.map +1 -0
- package/dist/correlation-id.vo.js +3 -0
- package/dist/correlation-id.vo.js.map +1 -0
- package/dist/decorators.d.ts +4 -0
- package/dist/decorators.d.ts.map +1 -0
- package/dist/decorators.js +62 -0
- package/dist/decorators.js.map +1 -0
- package/dist/decorators.service.d.ts +12 -0
- package/dist/decorators.service.d.ts.map +1 -0
- package/dist/decorators.service.js +62 -0
- package/dist/decorators.service.js.map +1 -0
- package/dist/download-file.service.d.ts +13 -0
- package/dist/download-file.service.d.ts.map +1 -0
- package/dist/download-file.service.js +11 -0
- package/dist/download-file.service.js.map +1 -0
- package/dist/encryption.d.ts +8 -3
- package/dist/encryption.d.ts.map +1 -0
- package/dist/encryption.js +37 -0
- package/dist/encryption.js.map +1 -0
- package/dist/encryption.service.d.ts +25 -0
- package/dist/encryption.service.d.ts.map +1 -0
- package/dist/encryption.service.js +37 -0
- package/dist/encryption.service.js.map +1 -0
- package/dist/env-validator.service.d.ts +21 -0
- package/dist/env-validator.service.d.ts.map +1 -0
- package/dist/env-validator.service.js +28 -0
- package/dist/env-validator.service.js.map +1 -0
- package/dist/etag-extractor.middleware.d.ts +11 -0
- package/dist/etag-extractor.middleware.d.ts.map +1 -0
- package/dist/etag-extractor.middleware.js +18 -0
- package/dist/etag-extractor.middleware.js.map +1 -0
- package/dist/event-handler.d.ts +8 -0
- package/dist/event-handler.d.ts.map +1 -0
- package/dist/event-handler.js +21 -0
- package/dist/event-handler.js.map +1 -0
- package/dist/event-handler.service.d.ts +8 -0
- package/dist/event-handler.service.d.ts.map +1 -0
- package/dist/event-handler.service.js +21 -0
- package/dist/event-handler.service.js.map +1 -0
- package/dist/event-logger.d.ts +8 -0
- package/dist/event-logger.d.ts.map +1 -0
- package/dist/event-logger.js +19 -0
- package/dist/event-logger.js.map +1 -0
- package/dist/event-logger.service.d.ts +8 -0
- package/dist/event-logger.service.d.ts.map +1 -0
- package/dist/event-logger.service.js +19 -0
- package/dist/event-logger.service.js.map +1 -0
- package/dist/event.d.ts +7 -46
- package/dist/event.d.ts.map +1 -0
- package/dist/event.js +23 -0
- package/dist/event.js.map +1 -0
- package/dist/event.vo.d.ts +20 -0
- package/dist/event.vo.d.ts.map +1 -0
- package/dist/event.vo.js +23 -0
- package/dist/event.vo.js.map +1 -0
- package/dist/file-location.d.ts +10 -9
- package/dist/file-location.d.ts.map +1 -0
- package/dist/file-location.js +46 -0
- package/dist/file-location.js.map +1 -0
- package/dist/file-location.service.d.ts +32 -0
- package/dist/file-location.service.d.ts.map +1 -0
- package/dist/file-location.service.js +46 -0
- package/dist/file-location.service.js.map +1 -0
- package/dist/file-uploader.middleware.d.ts +13 -0
- package/dist/file-uploader.middleware.d.ts.map +1 -0
- package/dist/file-uploader.middleware.js +35 -0
- package/dist/file-uploader.middleware.js.map +1 -0
- package/dist/graceful-shutdown.service.d.ts +7 -0
- package/dist/graceful-shutdown.service.d.ts.map +1 -0
- package/dist/graceful-shutdown.service.js +32 -0
- package/dist/graceful-shutdown.service.js.map +1 -0
- package/dist/gzip.d.ts +1 -0
- package/dist/gzip.d.ts.map +1 -0
- package/dist/gzip.js +18 -0
- package/dist/gzip.js.map +1 -0
- package/dist/gzip.service.d.ts +13 -0
- package/dist/gzip.service.d.ts.map +1 -0
- package/dist/gzip.service.js +18 -0
- package/dist/gzip.service.js.map +1 -0
- package/dist/hcaptcha-shield.d.ts +12 -13
- package/dist/hcaptcha-shield.d.ts.map +1 -0
- package/dist/hcaptcha-shield.js +34 -0
- package/dist/hcaptcha-shield.js.map +1 -0
- package/dist/hcaptcha-shield.middleware.d.ts +23 -0
- package/dist/hcaptcha-shield.middleware.d.ts.map +1 -0
- package/dist/hcaptcha-shield.middleware.js +34 -0
- package/dist/hcaptcha-shield.middleware.js.map +1 -0
- package/dist/healthcheck.d.ts +5 -5
- package/dist/healthcheck.d.ts.map +1 -1
- package/dist/healthcheck.js +5 -5
- package/dist/healthcheck.js.map +1 -1
- package/dist/healthcheck.service.d.ts +22 -0
- package/dist/healthcheck.service.d.ts.map +1 -0
- package/dist/healthcheck.service.js +35 -0
- package/dist/healthcheck.service.js.map +1 -0
- package/dist/http-logger.middleware.d.ts +7 -0
- package/dist/http-logger.middleware.d.ts.map +1 -0
- package/dist/http-logger.middleware.js +89 -0
- package/dist/http-logger.middleware.js.map +1 -0
- package/dist/i18n.d.ts.map +1 -1
- package/dist/i18n.js.map +1 -1
- package/dist/i18n.service.d.ts +22 -0
- package/dist/i18n.service.d.ts.map +1 -0
- package/dist/i18n.service.js +35 -0
- package/dist/i18n.service.js.map +1 -0
- package/dist/image-compressor.d.ts +9 -4
- package/dist/image-compressor.d.ts.map +1 -0
- package/dist/image-compressor.js +13 -0
- package/dist/image-compressor.js.map +1 -0
- package/dist/image-compressor.service.d.ts +15 -0
- package/dist/image-compressor.service.d.ts.map +1 -0
- package/dist/image-compressor.service.js +13 -0
- package/dist/image-compressor.service.js.map +1 -0
- package/dist/image-exif.d.ts +10 -9
- package/dist/image-exif.d.ts.map +1 -0
- package/dist/image-exif.js +21 -0
- package/dist/image-exif.js.map +1 -0
- package/dist/image-exif.service.d.ts +19 -0
- package/dist/image-exif.service.d.ts.map +1 -0
- package/dist/image-exif.service.js +21 -0
- package/dist/image-exif.service.js.map +1 -0
- package/dist/index.d.ts +51 -34
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +51 -34
- package/dist/index.js.map +1 -1
- package/dist/jobs.d.ts.map +1 -1
- package/dist/jobs.js.map +1 -1
- package/dist/jobs.service.d.ts +33 -0
- package/dist/jobs.service.d.ts.map +1 -0
- package/dist/jobs.service.js +72 -0
- package/dist/jobs.service.js.map +1 -0
- package/dist/logger.d.ts.map +1 -1
- package/dist/logger.js.map +1 -1
- package/dist/logger.service.d.ts +69 -0
- package/dist/logger.service.d.ts.map +1 -0
- package/dist/logger.service.js +87 -0
- package/dist/logger.service.js.map +1 -0
- package/dist/mailer.d.ts.map +1 -1
- package/dist/mailer.js.map +1 -1
- package/dist/mailer.service.d.ts +38 -0
- package/dist/mailer.service.d.ts.map +1 -0
- package/dist/mailer.service.js +33 -0
- package/dist/mailer.service.js.map +1 -0
- package/dist/memory-consumption.service.d.ts +5 -0
- package/dist/memory-consumption.service.d.ts.map +1 -0
- package/dist/memory-consumption.service.js +8 -0
- package/dist/memory-consumption.service.js.map +1 -0
- package/dist/new-uuid.service.d.ts +4 -0
- package/dist/new-uuid.service.d.ts.map +1 -0
- package/dist/new-uuid.service.js +6 -0
- package/dist/new-uuid.service.js.map +1 -0
- package/dist/node-env.vo.d.ts.map +1 -1
- package/dist/node-env.vo.js.map +1 -1
- package/dist/open-graph.d.ts +31 -12
- package/dist/open-graph.d.ts.map +1 -0
- package/dist/open-graph.js +172 -0
- package/dist/open-graph.js.map +1 -0
- package/dist/open-graph.service.d.ts +110 -0
- package/dist/open-graph.service.d.ts.map +1 -0
- package/dist/open-graph.service.js +172 -0
- package/dist/open-graph.service.js.map +1 -0
- package/dist/passwords.d.ts.map +1 -1
- package/dist/passwords.js.map +1 -1
- package/dist/passwords.vo.d.ts +21 -0
- package/dist/passwords.vo.d.ts.map +1 -0
- package/dist/passwords.vo.js +42 -0
- package/dist/passwords.vo.js.map +1 -0
- package/dist/path.d.ts.map +1 -1
- package/dist/path.vo.d.ts +4 -0
- package/dist/path.vo.d.ts.map +1 -0
- package/dist/path.vo.js +3 -0
- package/dist/path.vo.js.map +1 -0
- package/dist/policy.service.d.ts +12 -0
- package/dist/policy.service.d.ts.map +1 -0
- package/dist/policy.service.js +14 -0
- package/dist/policy.service.js.map +1 -0
- package/dist/port.d.ts.map +1 -1
- package/dist/port.vo.d.ts +4 -0
- package/dist/port.vo.d.ts.map +1 -0
- package/dist/port.vo.js +3 -0
- package/dist/port.vo.js.map +1 -0
- package/dist/prerequisites/binary.d.ts +5 -5
- package/dist/prerequisites/binary.d.ts.map +1 -1
- package/dist/prerequisites/binary.js +4 -4
- package/dist/prerequisites/binary.js.map +1 -1
- package/dist/prerequisites/bun.d.ts +5 -5
- package/dist/prerequisites/bun.d.ts.map +1 -1
- package/dist/prerequisites/bun.js +5 -3
- package/dist/prerequisites/bun.js.map +1 -1
- package/dist/prerequisites/dependency-vulnerabilities.d.ts +13 -0
- package/dist/prerequisites/dependency-vulnerabilities.d.ts.map +1 -0
- package/dist/prerequisites/dependency-vulnerabilities.js +30 -0
- package/dist/prerequisites/dependency-vulnerabilities.js.map +1 -0
- package/dist/prerequisites/external-api.d.ts +14 -0
- package/dist/prerequisites/external-api.d.ts.map +1 -0
- package/dist/prerequisites/external-api.js +21 -0
- package/dist/prerequisites/external-api.js.map +1 -0
- package/dist/prerequisites/index.d.ts +2 -0
- package/dist/prerequisites/index.d.ts.map +1 -1
- package/dist/prerequisites/index.js +2 -0
- package/dist/prerequisites/index.js.map +1 -1
- package/dist/prerequisites/jobs.d.ts +6 -6
- package/dist/prerequisites/jobs.d.ts.map +1 -1
- package/dist/prerequisites/jobs.js +5 -5
- package/dist/prerequisites/jobs.js.map +1 -1
- package/dist/prerequisites/log-file.d.ts +6 -6
- package/dist/prerequisites/log-file.d.ts.map +1 -1
- package/dist/prerequisites/log-file.js +4 -4
- package/dist/prerequisites/log-file.js.map +1 -1
- package/dist/prerequisites/mailer.d.ts +6 -6
- package/dist/prerequisites/mailer.d.ts.map +1 -1
- package/dist/prerequisites/mailer.js +4 -4
- package/dist/prerequisites/mailer.js.map +1 -1
- package/dist/prerequisites/memory.d.ts +5 -5
- package/dist/prerequisites/memory.d.ts.map +1 -1
- package/dist/prerequisites/memory.js +5 -5
- package/dist/prerequisites/memory.js.map +1 -1
- package/dist/prerequisites/node.d.ts +5 -5
- package/dist/prerequisites/node.d.ts.map +1 -1
- package/dist/prerequisites/node.js +4 -4
- package/dist/prerequisites/node.js.map +1 -1
- package/dist/prerequisites/outside-connectivity.d.ts +5 -5
- package/dist/prerequisites/outside-connectivity.d.ts.map +1 -1
- package/dist/prerequisites/outside-connectivity.js +4 -4
- package/dist/prerequisites/outside-connectivity.js.map +1 -1
- package/dist/prerequisites/path.d.ts +5 -5
- package/dist/prerequisites/path.d.ts.map +1 -1
- package/dist/prerequisites/path.js +4 -4
- package/dist/prerequisites/path.js.map +1 -1
- package/dist/prerequisites/port.d.ts +6 -6
- package/dist/prerequisites/port.d.ts.map +1 -1
- package/dist/prerequisites/port.js +6 -6
- package/dist/prerequisites/port.js.map +1 -1
- package/dist/prerequisites/ram.d.ts +5 -5
- package/dist/prerequisites/ram.d.ts.map +1 -1
- package/dist/prerequisites/ram.js +4 -4
- package/dist/prerequisites/ram.js.map +1 -1
- package/dist/prerequisites/self.d.ts +5 -5
- package/dist/prerequisites/self.d.ts.map +1 -1
- package/dist/prerequisites/self.js +4 -4
- package/dist/prerequisites/self.js.map +1 -1
- package/dist/prerequisites/space.d.ts +5 -5
- package/dist/prerequisites/space.d.ts.map +1 -1
- package/dist/prerequisites/space.js +4 -4
- package/dist/prerequisites/space.js.map +1 -1
- package/dist/prerequisites/ssl-certificate-expiry.d.ts +5 -5
- package/dist/prerequisites/ssl-certificate-expiry.d.ts.map +1 -1
- package/dist/prerequisites/ssl-certificate-expiry.js +5 -5
- package/dist/prerequisites/ssl-certificate-expiry.js.map +1 -1
- package/dist/prerequisites/timezone-utc.d.ts +5 -5
- package/dist/prerequisites/timezone-utc.d.ts.map +1 -1
- package/dist/prerequisites/timezone-utc.js +4 -4
- package/dist/prerequisites/timezone-utc.js.map +1 -1
- package/dist/prerequisites/translations.d.ts +8 -8
- package/dist/prerequisites/translations.d.ts.map +1 -1
- package/dist/prerequisites/translations.js +8 -8
- package/dist/prerequisites/translations.js.map +1 -1
- package/dist/prerequisites.d.ts +2 -0
- package/dist/prerequisites.d.ts.map +1 -1
- package/dist/prerequisites.js +2 -0
- package/dist/prerequisites.js.map +1 -1
- package/dist/prerequisites.service.d.ts +49 -0
- package/dist/prerequisites.service.d.ts.map +1 -0
- package/dist/prerequisites.service.js +86 -0
- package/dist/prerequisites.service.js.map +1 -0
- package/dist/rate-limit-shield.middleware.d.ts +10 -0
- package/dist/rate-limit-shield.middleware.d.ts.map +1 -0
- package/dist/rate-limit-shield.middleware.js +21 -0
- package/dist/rate-limit-shield.middleware.js.map +1 -0
- package/dist/recaptcha-shield.d.ts +13 -5
- package/dist/recaptcha-shield.d.ts.map +1 -0
- package/dist/recaptcha-shield.js +50 -0
- package/dist/recaptcha-shield.js.map +1 -0
- package/dist/recaptcha-shield.middleware.d.ts +20 -0
- package/dist/recaptcha-shield.middleware.d.ts.map +1 -0
- package/dist/recaptcha-shield.middleware.js +50 -0
- package/dist/recaptcha-shield.middleware.js.map +1 -0
- package/dist/session-id.vo.d.ts +7 -0
- package/dist/session-id.vo.d.ts.map +1 -0
- package/dist/session-id.vo.js +10 -0
- package/dist/session-id.vo.js.map +1 -0
- package/dist/setup.js +1 -1
- package/dist/setup.js.map +1 -1
- package/dist/setup.service.d.ts +9 -0
- package/dist/setup.service.d.ts.map +1 -0
- package/dist/setup.service.js +39 -0
- package/dist/setup.service.js.map +1 -0
- package/dist/simulated-error.d.ts +2 -2
- package/dist/simulated-error.d.ts.map +1 -0
- package/dist/simulated-error.js +7 -0
- package/dist/simulated-error.js.map +1 -0
- package/dist/simulated-error.middleware.d.ts +4 -0
- package/dist/simulated-error.middleware.d.ts.map +1 -0
- package/dist/simulated-error.middleware.js +7 -0
- package/dist/simulated-error.middleware.js.map +1 -0
- package/dist/sitemap.d.ts +19 -27
- package/dist/sitemap.d.ts.map +1 -0
- package/dist/sitemap.js +57 -0
- package/dist/sitemap.js.map +1 -0
- package/dist/sitemap.service.d.ts +29 -0
- package/dist/sitemap.service.d.ts.map +1 -0
- package/dist/sitemap.service.js +57 -0
- package/dist/sitemap.service.js.map +1 -0
- package/dist/slower.d.ts +3 -6
- package/dist/slower.d.ts.map +1 -0
- package/dist/slower.js +8 -0
- package/dist/slower.js.map +1 -0
- package/dist/slower.middleware.d.ts +5 -0
- package/dist/slower.middleware.d.ts.map +1 -0
- package/dist/slower.middleware.js +8 -0
- package/dist/slower.middleware.js.map +1 -0
- package/dist/time-zone-offset.middleware.d.ts +15 -0
- package/dist/time-zone-offset.middleware.d.ts.map +1 -0
- package/dist/time-zone-offset.middleware.js +22 -0
- package/dist/time-zone-offset.middleware.js.map +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/uptime.service.d.ts +9 -0
- package/dist/uptime.service.d.ts.map +1 -0
- package/dist/uptime.service.js +10 -0
- package/dist/uptime.service.js.map +1 -0
- package/dist/url-wo-trailing-slash.d.ts +4 -0
- package/dist/url-wo-trailing-slash.d.ts.map +1 -0
- package/dist/url-wo-trailing-slash.js +9 -0
- package/dist/url-wo-trailing-slash.js.map +1 -0
- package/dist/url-wo-trailing-slash.vo.d.ts +4 -0
- package/dist/url-wo-trailing-slash.vo.d.ts.map +1 -0
- package/dist/url-wo-trailing-slash.vo.js +9 -0
- package/dist/url-wo-trailing-slash.vo.js.map +1 -0
- package/dist/username.vo.d.ts +11 -0
- package/dist/username.vo.d.ts.map +1 -0
- package/dist/username.vo.js +13 -0
- package/dist/username.vo.js.map +1 -0
- package/dist/uuid.d.ts.map +1 -1
- package/dist/uuid.vo.d.ts +4 -0
- package/dist/uuid.vo.d.ts.map +1 -0
- package/dist/uuid.vo.js +4 -0
- package/dist/uuid.vo.js.map +1 -0
- package/dist/weak-etag-extractor.middleware.d.ts +7 -0
- package/dist/weak-etag-extractor.middleware.d.ts.map +1 -0
- package/dist/weak-etag-extractor.middleware.js +18 -0
- package/dist/weak-etag-extractor.middleware.js.map +1 -0
- package/package.json +5 -2
- package/src/{api-version.ts → api-version.middleware.ts} +1 -1
- package/src/{auth-shield.ts → auth-shield.middleware.ts} +3 -3
- package/src/basic-auth.service.ts +26 -0
- package/src/{cache-response.ts → cache-response.middleware.ts} +1 -1
- package/src/{context.ts → context.middleware.ts} +2 -2
- package/src/{correlation-id.ts → correlation-id.vo.ts} +2 -1
- package/src/decorators.service.ts +78 -0
- package/src/encryption.service.ts +60 -0
- package/src/event-handler.service.ts +20 -0
- package/src/event-logger.service.ts +24 -0
- package/src/event.vo.ts +29 -0
- package/src/file-location.service.ts +70 -0
- package/src/gzip.service.ts +23 -0
- package/src/hcaptcha-shield.middleware.ts +57 -0
- package/src/{healthcheck.ts → healthcheck.service.ts} +12 -17
- package/src/{http-logger.ts → http-logger.middleware.ts} +4 -4
- package/src/{i18n.ts → i18n.service.ts} +6 -2
- package/src/image-compressor.service.ts +26 -0
- package/src/image-exif.service.ts +38 -0
- package/src/index.ts +51 -34
- package/src/{jobs.ts → jobs.service.ts} +4 -3
- package/src/{logger.ts → logger.service.ts} +8 -2
- package/src/{mailer.ts → mailer.service.ts} +11 -2
- package/src/node-env.vo.ts +1 -0
- package/src/open-graph.service.ts +259 -0
- package/src/{passwords.ts → passwords.vo.ts} +1 -0
- package/src/{path.ts → path.vo.ts} +1 -0
- package/src/policy.service.ts +25 -0
- package/src/{port.ts → port.vo.ts} +1 -0
- package/src/prerequisites/binary.ts +6 -10
- package/src/prerequisites/bun.ts +7 -10
- package/src/prerequisites/dependency-vulnerabilities.ts +54 -0
- package/src/prerequisites/external-api.ts +27 -0
- package/src/prerequisites/index.ts +2 -0
- package/src/prerequisites/jobs.ts +7 -13
- package/src/prerequisites/log-file.ts +7 -12
- package/src/prerequisites/mailer.ts +7 -12
- package/src/prerequisites/memory.ts +7 -12
- package/src/prerequisites/node.ts +6 -11
- package/src/prerequisites/outside-connectivity.ts +6 -11
- package/src/prerequisites/path.ts +6 -11
- package/src/prerequisites/port.ts +9 -15
- package/src/prerequisites/ram.ts +6 -11
- package/src/prerequisites/self.ts +6 -11
- package/src/prerequisites/space.ts +6 -11
- package/src/prerequisites/ssl-certificate-expiry.ts +7 -12
- package/src/prerequisites/timezone-utc.ts +6 -11
- package/src/prerequisites/translations.ts +14 -19
- package/src/{prerequisites.ts → prerequisites.service.ts} +3 -0
- package/src/{rate-limit-shield.ts → rate-limit-shield.middleware.ts} +8 -2
- package/src/recaptcha-shield.middleware.ts +76 -0
- package/src/{setup.ts → setup.service.ts} +9 -9
- package/src/simulated-error.middleware.ts +8 -0
- package/src/sitemap.service.ts +98 -0
- package/src/slower.middleware.ts +10 -0
- package/src/url-wo-trailing-slash.vo.ts +11 -0
- package/src/{uuid.ts → uuid.vo.ts} +2 -1
- package/src/{weak-etag-extractor.ts → weak-etag-extractor.middleware.ts} +1 -1
- package/src/basic-auth.ts +0 -7
- /package/src/{api-key-shield.ts → api-key-shield.middleware.ts} +0 -0
- /package/src/{build-info-repository.ts → build-info-repository.service.ts} +0 -0
- /package/src/{cache-resolver.ts → cache-resolver.service.ts} +0 -0
- /package/src/{cache-static-files.ts → cache-static-files.middleware.ts} +0 -0
- /package/src/{download-file.ts → download-file.service.ts} +0 -0
- /package/src/{env-validator.ts → env-validator.service.ts} +0 -0
- /package/src/{etag-extractor.ts → etag-extractor.middleware.ts} +0 -0
- /package/src/{file-uploader.ts → file-uploader.middleware.ts} +0 -0
- /package/src/{graceful-shutdown.ts → graceful-shutdown.service.ts} +0 -0
- /package/src/{memory-consumption.ts → memory-consumption.service.ts} +0 -0
- /package/src/{new-uuid.ts → new-uuid.service.ts} +0 -0
- /package/src/{session-id.ts → session-id.vo.ts} +0 -0
- /package/src/{time-zone-offset.ts → time-zone-offset.middleware.ts} +0 -0
- /package/src/{uptime.ts → uptime.service.ts} +0 -0
- /package/src/{username.ts → username.vo.ts} +0 -0
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import * as tools from "@bgord/tools";
|
|
2
|
+
export type UptimeResultType = {
|
|
3
|
+
seconds: tools.TimestampType;
|
|
4
|
+
formatted: ReturnType<(typeof tools.DateFormatters)["relative"]>;
|
|
5
|
+
};
|
|
6
|
+
export declare class Uptime {
|
|
7
|
+
static get(): UptimeResultType;
|
|
8
|
+
}
|
|
9
|
+
//# sourceMappingURL=uptime.service.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"uptime.service.d.ts","sourceRoot":"","sources":["../src/uptime.service.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,cAAc,CAAC;AAEtC,MAAM,MAAM,gBAAgB,GAAG;IAC7B,OAAO,EAAE,KAAK,CAAC,aAAa,CAAC;IAC7B,SAAS,EAAE,UAAU,CAAC,CAAC,OAAO,KAAK,CAAC,cAAc,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC;CAClE,CAAC;AAEF,qBAAa,MAAM;IACjB,MAAM,CAAC,GAAG,IAAI,gBAAgB;CAO/B"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import * as tools from "@bgord/tools";
|
|
2
|
+
export class Uptime {
|
|
3
|
+
static get() {
|
|
4
|
+
const rounding = new tools.RoundToNearest();
|
|
5
|
+
const uptime = tools.Time.Seconds(rounding.round(process.uptime()));
|
|
6
|
+
const uptimeFormatted = tools.DateFormatters.relative(Date.now() - uptime.ms);
|
|
7
|
+
return { seconds: uptime.seconds, formatted: uptimeFormatted };
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
//# sourceMappingURL=uptime.service.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"uptime.service.js","sourceRoot":"","sources":["../src/uptime.service.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,cAAc,CAAC;AAOtC,MAAM,OAAO,MAAM;IACjB,MAAM,CAAC,GAAG;QACR,MAAM,QAAQ,GAAG,IAAI,KAAK,CAAC,cAAc,EAAE,CAAC;QAC5C,MAAM,MAAM,GAAG,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAC,OAAO,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC;QACpE,MAAM,eAAe,GAAG,KAAK,CAAC,cAAc,CAAC,QAAQ,CAAC,IAAI,CAAC,GAAG,EAAE,GAAG,MAAM,CAAC,EAAE,CAAC,CAAC;QAE9E,OAAO,EAAE,OAAO,EAAE,MAAM,CAAC,OAAO,EAAE,SAAS,EAAE,eAAe,EAAE,CAAC;IACjE,CAAC;CACF"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"url-wo-trailing-slash.d.ts","sourceRoot":"","sources":["../src/url-wo-trailing-slash.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,QAAQ,CAAC;AAE3B,eAAO,MAAM,uBAAuB,UAMhC,CAAC;AAEL,MAAM,MAAM,2BAA2B,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,uBAAuB,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"url-wo-trailing-slash.js","sourceRoot":"","sources":["../src/url-wo-trailing-slash.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,QAAQ,CAAC;AAE3B,MAAM,CAAC,MAAM,uBAAuB,GAAG,CAAC;KACrC,GAAG,EAAE;KACL,IAAI,EAAE;KACN,GAAG,CAAC,CAAC,CAAC;KACN,MAAM,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC,KAAK,CAAC,QAAQ,CAAC,GAAG,CAAC,EAAE;IACvC,OAAO,EAAE,oCAAoC;CAC9C,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"url-wo-trailing-slash.vo.d.ts","sourceRoot":"","sources":["../src/url-wo-trailing-slash.vo.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,QAAQ,CAAC;AAE3B,eAAO,MAAM,uBAAuB,UAMhC,CAAC;AAEL,MAAM,MAAM,2BAA2B,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,uBAAuB,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"url-wo-trailing-slash.vo.js","sourceRoot":"","sources":["../src/url-wo-trailing-slash.vo.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,QAAQ,CAAC;AAE3B,MAAM,CAAC,MAAM,uBAAuB,GAAG,CAAC;KACrC,GAAG,EAAE;KACL,IAAI,EAAE;KACN,GAAG,CAAC,CAAC,CAAC;KACN,MAAM,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC,KAAK,CAAC,QAAQ,CAAC,GAAG,CAAC,EAAE;IACvC,OAAO,EAAE,oCAAoC;CAC9C,CAAC,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { z } from "zod/v4";
|
|
2
|
+
export type IdType = string;
|
|
3
|
+
type UsernameType = string;
|
|
4
|
+
export declare class Username {
|
|
5
|
+
private readonly schema;
|
|
6
|
+
private readonly value;
|
|
7
|
+
constructor(value: UsernameType, schema?: z.ZodSchema);
|
|
8
|
+
read(): UsernameType;
|
|
9
|
+
}
|
|
10
|
+
export {};
|
|
11
|
+
//# sourceMappingURL=username.vo.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"username.vo.d.ts","sourceRoot":"","sources":["../src/username.vo.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,QAAQ,CAAC;AAE3B,MAAM,MAAM,MAAM,GAAG,MAAM,CAAC;AAE5B,KAAK,YAAY,GAAG,MAAM,CAAC;AAE3B,qBAAa,QAAQ;IACnB,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAoC;IAE3D,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAe;gBAEzB,KAAK,EAAE,YAAY,EAAE,MAAM,CAAC,EAAE,CAAC,CAAC,SAAS;IAKrD,IAAI,IAAI,YAAY;CAGrB"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { z } from "zod/v4";
|
|
2
|
+
export class Username {
|
|
3
|
+
schema = z.string().max(256);
|
|
4
|
+
value;
|
|
5
|
+
constructor(value, schema) {
|
|
6
|
+
this.schema = schema ?? this.schema;
|
|
7
|
+
this.value = this.schema.parse(value);
|
|
8
|
+
}
|
|
9
|
+
read() {
|
|
10
|
+
return this.value;
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
//# sourceMappingURL=username.vo.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"username.vo.js","sourceRoot":"","sources":["../src/username.vo.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,QAAQ,CAAC;AAM3B,MAAM,OAAO,QAAQ;IACF,MAAM,GAAgB,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;IAE1C,KAAK,CAAe;IAErC,YAAY,KAAmB,EAAE,MAAoB;QACnD,IAAI,CAAC,MAAM,GAAG,MAAM,IAAI,IAAI,CAAC,MAAM,CAAC;QACpC,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,KAAK,CAAiB,CAAC;IACxD,CAAC;IAED,IAAI;QACF,OAAO,IAAI,CAAC,KAAK,CAAC;IACpB,CAAC;CACF"}
|
package/dist/uuid.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"uuid.d.ts","sourceRoot":"","sources":["../src/uuid.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,QAAQ,CAAC;AAI3B,eAAO,MAAM,IAAI,yBAA6C,CAAC;
|
|
1
|
+
{"version":3,"file":"uuid.d.ts","sourceRoot":"","sources":["../src/uuid.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,QAAQ,CAAC;AAI3B,eAAO,MAAM,IAAI,yBAA6C,CAAC;AAE/D,MAAM,MAAM,QAAQ,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,IAAI,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"uuid.vo.d.ts","sourceRoot":"","sources":["../src/uuid.vo.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,QAAQ,CAAC;AAI3B,eAAO,MAAM,IAAI,yBAA6C,CAAC;AAE/D,MAAM,MAAM,QAAQ,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,IAAI,CAAC,CAAC"}
|
package/dist/uuid.vo.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"uuid.vo.js","sourceRoot":"","sources":["../src/uuid.vo.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,QAAQ,CAAC;AAE3B,OAAO,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAE7C,MAAM,CAAC,MAAM,IAAI,GAAG,CAAC,CAAC,IAAI,EAAE,CAAC,OAAO,CAAC,GAAG,EAAE,CAAC,OAAO,CAAC,QAAQ,EAAE,CAAC,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { EtagVariables } from "./etag-extractor.middleware";
|
|
2
|
+
export declare class WeakETagExtractor {
|
|
3
|
+
static attach: import("hono").MiddlewareHandler<{
|
|
4
|
+
Variables: EtagVariables;
|
|
5
|
+
}, string, {}>;
|
|
6
|
+
}
|
|
7
|
+
//# sourceMappingURL=weak-etag-extractor.middleware.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"weak-etag-extractor.middleware.d.ts","sourceRoot":"","sources":["../src/weak-etag-extractor.middleware.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,aAAa,EAAE,MAAM,6BAA6B,CAAC;AAE5D,qBAAa,iBAAiB;IAC5B,MAAM,CAAC,MAAM;mBAAiC,aAAa;mBAWxD;CACJ"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import * as tools from "@bgord/tools";
|
|
2
|
+
import { createMiddleware } from "hono/factory";
|
|
3
|
+
export class WeakETagExtractor {
|
|
4
|
+
static attach = createMiddleware(async (c, next) => {
|
|
5
|
+
try {
|
|
6
|
+
const header = String(c.req.header(tools.WeakETag.IF_MATCH_HEADER_NAME));
|
|
7
|
+
if (!header || header === "undefined")
|
|
8
|
+
c.set("WeakETag", null);
|
|
9
|
+
else
|
|
10
|
+
c.set("WeakETag", tools.WeakETag.fromHeader(header));
|
|
11
|
+
}
|
|
12
|
+
catch (error) {
|
|
13
|
+
c.set("WeakETag", null);
|
|
14
|
+
}
|
|
15
|
+
await next();
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
//# sourceMappingURL=weak-etag-extractor.middleware.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"weak-etag-extractor.middleware.js","sourceRoot":"","sources":["../src/weak-etag-extractor.middleware.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,cAAc,CAAC;AACtC,OAAO,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAIhD,MAAM,OAAO,iBAAiB;IAC5B,MAAM,CAAC,MAAM,GAAG,gBAAgB,CAA+B,KAAK,EAAE,CAAC,EAAE,IAAI,EAAE,EAAE;QAC/E,IAAI,CAAC;YACH,MAAM,MAAM,GAAG,MAAM,CAAC,CAAC,CAAC,GAAG,CAAC,MAAM,CAAC,KAAK,CAAC,QAAQ,CAAC,oBAAoB,CAAC,CAAC,CAAC;YAEzE,IAAI,CAAC,MAAM,IAAI,MAAM,KAAK,WAAW;gBAAE,CAAC,CAAC,GAAG,CAAC,UAAU,EAAE,IAAI,CAAC,CAAC;;gBAC1D,CAAC,CAAC,GAAG,CAAC,UAAU,EAAE,KAAK,CAAC,QAAQ,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC,CAAC;QAC5D,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,CAAC,CAAC,GAAG,CAAC,UAAU,EAAE,IAAI,CAAC,CAAC;QAC1B,CAAC;QAED,MAAM,IAAI,EAAE,CAAC;IACf,CAAC,CAAC,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bgord/bun",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.8.1",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"author": "Bartosz Gordon",
|
|
@@ -22,6 +22,7 @@
|
|
|
22
22
|
"@commitlint/config-conventional": "19.8.1",
|
|
23
23
|
"@types/bun": "1.2.15",
|
|
24
24
|
"@types/lodash": "4.17.17",
|
|
25
|
+
"@types/mime-types": "3.0.1",
|
|
25
26
|
"@types/nodemailer": "6.4.17",
|
|
26
27
|
"cspell": "9.0.2",
|
|
27
28
|
"knip": "5.60.2",
|
|
@@ -31,12 +32,14 @@
|
|
|
31
32
|
"typescript": "5.8.3"
|
|
32
33
|
},
|
|
33
34
|
"dependencies": {
|
|
34
|
-
"@bgord/tools": "0.
|
|
35
|
+
"@bgord/tools": "0.8.0",
|
|
35
36
|
"check-disk-space": "3.4.0",
|
|
36
37
|
"croner": "9.0.0",
|
|
38
|
+
"hcaptcha": "0.2.0",
|
|
37
39
|
"hono": "4.7.11",
|
|
38
40
|
"lodash": "4.17.21",
|
|
39
41
|
"lucia": "3.2.2",
|
|
42
|
+
"mime-types": "3.0.1",
|
|
40
43
|
"node-cache": "5.1.2",
|
|
41
44
|
"nodemailer": "7.0.3",
|
|
42
45
|
"sharp": "0.34.2",
|
|
@@ -3,9 +3,9 @@ import { createMiddleware } from "hono/factory";
|
|
|
3
3
|
import { HTTPException } from "hono/http-exception";
|
|
4
4
|
import { Lucia } from "lucia";
|
|
5
5
|
|
|
6
|
-
import { HashedPassword, Password, PasswordType } from "./passwords";
|
|
7
|
-
import { SessionId } from "./session-id";
|
|
8
|
-
import { IdType, Username } from "./username";
|
|
6
|
+
import { HashedPassword, Password, PasswordType } from "./passwords.vo";
|
|
7
|
+
import { SessionId } from "./session-id.vo";
|
|
8
|
+
import { IdType, Username } from "./username.vo";
|
|
9
9
|
|
|
10
10
|
type AuthShieldConfigType<T> = {
|
|
11
11
|
Username: typeof Username;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { z } from "zod/v4";
|
|
2
|
+
|
|
3
|
+
export const BasicAuthUsername = z.string().min(1).max(128);
|
|
4
|
+
|
|
5
|
+
export type BasicAuthUsernameType = z.infer<typeof BasicAuthUsername>;
|
|
6
|
+
|
|
7
|
+
export const BasicAuthPassword = z.string().min(1).max(128);
|
|
8
|
+
|
|
9
|
+
export type BasicAuthPasswordType = z.infer<typeof BasicAuthPassword>;
|
|
10
|
+
|
|
11
|
+
type BasicAuthHeaderValueType = { authorization: string };
|
|
12
|
+
|
|
13
|
+
export class BasicAuth {
|
|
14
|
+
static toHeaderValue(
|
|
15
|
+
username: BasicAuthUsernameType,
|
|
16
|
+
password: BasicAuthPasswordType,
|
|
17
|
+
): BasicAuthHeaderValueType {
|
|
18
|
+
const credentials = btoa(`${username}:${password}`);
|
|
19
|
+
|
|
20
|
+
return { authorization: `Basic ${credentials}` };
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
static toHeader(username: BasicAuthUsernameType, password: BasicAuthPasswordType): Headers {
|
|
24
|
+
return new Headers(BasicAuth.toHeaderValue(username, password));
|
|
25
|
+
}
|
|
26
|
+
}
|
|
@@ -2,7 +2,7 @@ import { createMiddleware } from "hono/factory";
|
|
|
2
2
|
import _ from "lodash";
|
|
3
3
|
import NodeCache from "node-cache";
|
|
4
4
|
|
|
5
|
-
import { CacheHitEnum } from "./cache-resolver";
|
|
5
|
+
import { CacheHitEnum } from "./cache-resolver.service";
|
|
6
6
|
|
|
7
7
|
export class CacheResponse {
|
|
8
8
|
static readonly CACHE_HIT_HEADER = "Cache-Hit";
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { createMiddleware } from "hono/factory";
|
|
2
2
|
|
|
3
|
-
import { CorrelationIdType } from "./correlation-id";
|
|
4
|
-
import { TimeZoneOffsetVariables } from "./time-zone-offset";
|
|
3
|
+
import type { CorrelationIdType } from "./correlation-id.vo";
|
|
4
|
+
import { TimeZoneOffsetVariables } from "./time-zone-offset.middleware";
|
|
5
5
|
|
|
6
6
|
export type ContextType = {
|
|
7
7
|
requestId: CorrelationIdType;
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import * as tools from "@bgord/tools";
|
|
2
|
+
|
|
3
|
+
import { Logger } from "./logger.service";
|
|
4
|
+
|
|
5
|
+
export class DecoratorTimeoutError extends Error {}
|
|
6
|
+
|
|
7
|
+
export class Decorators {
|
|
8
|
+
private readonly rounding = new tools.RoundToDecimal(2);
|
|
9
|
+
|
|
10
|
+
constructor(private readonly logger: Logger) {}
|
|
11
|
+
|
|
12
|
+
duration() {
|
|
13
|
+
const that = this;
|
|
14
|
+
|
|
15
|
+
return function (target: any, propertyKey: string, descriptor: PropertyDescriptor) {
|
|
16
|
+
const className =
|
|
17
|
+
// @ts-expect-error
|
|
18
|
+
this?.constructor?.name || target?.name || target?.constructor?.name || "UnknownClass";
|
|
19
|
+
|
|
20
|
+
const original: (...args: unknown[]) => unknown = descriptor.value;
|
|
21
|
+
|
|
22
|
+
const label = `${className}.${propertyKey}`;
|
|
23
|
+
|
|
24
|
+
descriptor.value = function (...args: unknown[]) {
|
|
25
|
+
const before = performance.now();
|
|
26
|
+
const value = original.apply(this, args);
|
|
27
|
+
const after = performance.now();
|
|
28
|
+
|
|
29
|
+
that.logger.info({
|
|
30
|
+
message: `${label} duration`,
|
|
31
|
+
operation: "decorators_duration_ms",
|
|
32
|
+
metadata: { durationMs: that.rounding.round(after - before) },
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
return value;
|
|
36
|
+
};
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
inspector() {
|
|
41
|
+
const that = this;
|
|
42
|
+
|
|
43
|
+
return function (target: any, propertyKey: string, descriptor: PropertyDescriptor) {
|
|
44
|
+
const className =
|
|
45
|
+
// @ts-expect-error
|
|
46
|
+
this?.constructor?.name || target?.name || target?.constructor?.name || "UnknownClass";
|
|
47
|
+
|
|
48
|
+
const original: (...args: unknown[]) => unknown = descriptor.value;
|
|
49
|
+
|
|
50
|
+
const label = `${className}.${propertyKey}`;
|
|
51
|
+
|
|
52
|
+
descriptor.value = async function (...args: unknown[]) {
|
|
53
|
+
const value = await original.apply(this, args);
|
|
54
|
+
|
|
55
|
+
that.logger.info({
|
|
56
|
+
message: `${label} inspector`,
|
|
57
|
+
operation: "decorators_inspector",
|
|
58
|
+
metadata: { arguments: args, output: value },
|
|
59
|
+
});
|
|
60
|
+
|
|
61
|
+
return value;
|
|
62
|
+
};
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
timeout(ms: number) {
|
|
67
|
+
return (_target: any, _key: string, descriptor: PropertyDescriptor) => {
|
|
68
|
+
const original: (...args: unknown[]) => unknown = descriptor.value;
|
|
69
|
+
|
|
70
|
+
descriptor.value = async function (...args: any[]) {
|
|
71
|
+
return await Promise.race([
|
|
72
|
+
original.apply(this, args),
|
|
73
|
+
new Promise((_, reject) => setTimeout(() => reject(new DecoratorTimeoutError()), ms)),
|
|
74
|
+
]);
|
|
75
|
+
};
|
|
76
|
+
};
|
|
77
|
+
}
|
|
78
|
+
}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import * as crypto from "node:crypto";
|
|
2
|
+
import * as fs from "node:fs";
|
|
3
|
+
import { pipeline } from "node:stream/promises";
|
|
4
|
+
import * as util from "node:util";
|
|
5
|
+
import { z } from "zod/v4";
|
|
6
|
+
|
|
7
|
+
export const EncryptionIV = z
|
|
8
|
+
.string()
|
|
9
|
+
.min(1)
|
|
10
|
+
.transform((value) => Buffer.from(value.split(",").map(Number)));
|
|
11
|
+
|
|
12
|
+
export type EncryptionIVType = z.infer<typeof EncryptionIV>;
|
|
13
|
+
|
|
14
|
+
export const EncryptionSecret = z.string().length(64);
|
|
15
|
+
|
|
16
|
+
export type EncryptionSecretType = z.infer<typeof EncryptionSecret>;
|
|
17
|
+
|
|
18
|
+
export type EncryptionConfig = {
|
|
19
|
+
secret: EncryptionSecretType;
|
|
20
|
+
iv: EncryptionIVType;
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
export type EncryptionOperationConfig = {
|
|
24
|
+
input: fs.PathLike;
|
|
25
|
+
output: fs.PathLike;
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
const scrypt = util.promisify(crypto.scrypt);
|
|
29
|
+
|
|
30
|
+
export class Encryption {
|
|
31
|
+
private readonly algorithm = "aes-192-cbc";
|
|
32
|
+
|
|
33
|
+
constructor(private readonly config: EncryptionConfig) {}
|
|
34
|
+
|
|
35
|
+
async createEncrypt() {
|
|
36
|
+
const key = (await scrypt(this.config.secret, "salt", 24)) as Buffer;
|
|
37
|
+
|
|
38
|
+
// @ts-ignore
|
|
39
|
+
return crypto.createCipheriv(this.algorithm, key, this.config.iv);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
async createDecrypt() {
|
|
43
|
+
const key = (await scrypt(this.config.secret, "salt", 24)) as Buffer;
|
|
44
|
+
|
|
45
|
+
// @ts-ignore
|
|
46
|
+
return crypto.createDecipheriv(this.algorithm, key, this.config.iv);
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
async encrypt(config: EncryptionOperationConfig) {
|
|
50
|
+
const encrypt = await this.createEncrypt();
|
|
51
|
+
|
|
52
|
+
return pipeline(fs.createReadStream(config.input), encrypt, fs.createWriteStream(config.output));
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
async decrypt(config: EncryptionOperationConfig) {
|
|
56
|
+
const decrypt = await this.createDecrypt();
|
|
57
|
+
|
|
58
|
+
return pipeline(fs.createReadStream(config.input), decrypt, fs.createWriteStream(config.output));
|
|
59
|
+
}
|
|
60
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { EventType } from "./event.vo";
|
|
2
|
+
import { Logger } from "./logger.service";
|
|
3
|
+
|
|
4
|
+
export class EventHandler {
|
|
5
|
+
constructor(private readonly logger: Logger) {}
|
|
6
|
+
|
|
7
|
+
handle<T extends Pick<EventType, "name">>(fn: (event: T) => Promise<void>) {
|
|
8
|
+
return async (event: T) => {
|
|
9
|
+
try {
|
|
10
|
+
await fn(event);
|
|
11
|
+
} catch (error) {
|
|
12
|
+
this.logger.error({
|
|
13
|
+
message: `Unknown ${event.name} event handler error`,
|
|
14
|
+
operation: "unknown_event_handler_error",
|
|
15
|
+
metadata: this.logger.formatError(error),
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { Logger } from "./logger.service";
|
|
2
|
+
|
|
3
|
+
export class EventLogger {
|
|
4
|
+
constructor(private readonly logger: Logger) {}
|
|
5
|
+
|
|
6
|
+
private _handle(
|
|
7
|
+
type: string,
|
|
8
|
+
_debugName: string,
|
|
9
|
+
eventName: string | undefined,
|
|
10
|
+
eventData: Record<string, any> | undefined,
|
|
11
|
+
) {
|
|
12
|
+
if (type === "subscribe") return;
|
|
13
|
+
|
|
14
|
+
if (typeof eventName === "symbol") return;
|
|
15
|
+
|
|
16
|
+
this.logger.info({
|
|
17
|
+
message: `${eventName} emitted`,
|
|
18
|
+
operation: "event_emitted",
|
|
19
|
+
metadata: eventData,
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
handle = this._handle.bind(this);
|
|
24
|
+
}
|
package/src/event.vo.ts
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { z } from "zod/v4";
|
|
2
|
+
|
|
3
|
+
import { UUID } from "./uuid.vo";
|
|
4
|
+
|
|
5
|
+
export const Event = z.object({
|
|
6
|
+
id: UUID,
|
|
7
|
+
createdAt: z.date(),
|
|
8
|
+
|
|
9
|
+
stream: z.string().min(1),
|
|
10
|
+
|
|
11
|
+
name: z.string().min(1),
|
|
12
|
+
version: z.number().int().positive(),
|
|
13
|
+
payload: z
|
|
14
|
+
.record(z.string(), z.any())
|
|
15
|
+
.refine((value) => {
|
|
16
|
+
try {
|
|
17
|
+
JSON.parse(JSON.stringify(value));
|
|
18
|
+
return true;
|
|
19
|
+
} catch (error) {
|
|
20
|
+
return false;
|
|
21
|
+
}
|
|
22
|
+
})
|
|
23
|
+
.transform((value) => JSON.stringify(value)),
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
export const ParsedEvent = Event.merge(z.object({ payload: z.record(z.string(), z.any()) }));
|
|
27
|
+
|
|
28
|
+
export type EventType = z.infer<typeof Event>;
|
|
29
|
+
export type ParsedEventType = z.infer<typeof ParsedEvent>;
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import * as path from "node:path";
|
|
2
|
+
|
|
3
|
+
import { Path, PathType } from "./path.vo";
|
|
4
|
+
|
|
5
|
+
type FileLocationBasenameType = string;
|
|
6
|
+
|
|
7
|
+
type FileLocationExtensionType = string;
|
|
8
|
+
|
|
9
|
+
type FileLocationParentType = string;
|
|
10
|
+
|
|
11
|
+
export type FileLocationConfigType = {
|
|
12
|
+
parent: FileLocationParentType;
|
|
13
|
+
basename: FileLocationBasenameType;
|
|
14
|
+
extension: FileLocationExtensionType;
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
export class FileLocation {
|
|
18
|
+
readonly parent: PathType; // /parent/dir
|
|
19
|
+
|
|
20
|
+
private basename: FileLocationBasenameType; // index
|
|
21
|
+
|
|
22
|
+
private extension: FileLocationExtensionType; // .html
|
|
23
|
+
|
|
24
|
+
constructor(config: FileLocationConfigType) {
|
|
25
|
+
this.parent = Path.parse(config.parent);
|
|
26
|
+
this.basename = config.basename;
|
|
27
|
+
this.extension = config.extension;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
getBasename(): FileLocationBasenameType {
|
|
31
|
+
return this.basename; // index
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
getExtension(): FileLocationExtensionType {
|
|
35
|
+
return this.extension; // .html
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
getFilename(extension?: FileLocationExtensionType): PathType {
|
|
39
|
+
return Path.parse(`${this.basename}${extension ?? this.extension}`); // index.html
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
getPath(extension?: FileLocationExtensionType): PathType {
|
|
43
|
+
const filename = this.getFilename(extension);
|
|
44
|
+
return Path.parse(path.join(this.parent, filename)); // parent/index.html
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
getGzippedPath(): PathType {
|
|
48
|
+
return Path.parse(`${this.getPath()}.gz`); // parent/index.html.gz
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
summary() {
|
|
52
|
+
return {
|
|
53
|
+
parent: this.parent,
|
|
54
|
+
basename: this.getBasename(),
|
|
55
|
+
extension: this.getExtension(),
|
|
56
|
+
filename: this.getFilename(),
|
|
57
|
+
path: this.getPath(),
|
|
58
|
+
gzipped: this.getGzippedPath(),
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
setBasename(basename: FileLocationBasenameType): FileLocation {
|
|
63
|
+
this.basename = basename;
|
|
64
|
+
return this;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
async delete(): Promise<void> {
|
|
68
|
+
return Bun.file(this.getPath()).unlink();
|
|
69
|
+
}
|
|
70
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { PathLike, createReadStream, createWriteStream } from "node:fs";
|
|
2
|
+
import { pipeline } from "node:stream/promises";
|
|
3
|
+
import { createGunzip, createGzip } from "node:zlib";
|
|
4
|
+
|
|
5
|
+
type GzipCompressConfigType = { input: PathLike; output: PathLike };
|
|
6
|
+
|
|
7
|
+
export class Gzip {
|
|
8
|
+
static createCompress() {
|
|
9
|
+
return createGzip();
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
static createDecompress() {
|
|
13
|
+
return createGunzip();
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
static async compress(config: GzipCompressConfigType) {
|
|
17
|
+
return pipeline(createReadStream(config.input), createGzip(), createWriteStream(config.output));
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
static async uncompress(config: GzipCompressConfigType) {
|
|
21
|
+
return pipeline(createReadStream(config.input), createGunzip(), createWriteStream(config.output));
|
|
22
|
+
}
|
|
23
|
+
}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import hcaptcha from "hcaptcha";
|
|
2
|
+
import { createMiddleware } from "hono/factory";
|
|
3
|
+
import { HTTPException } from "hono/http-exception";
|
|
4
|
+
import { z } from "zod/v4";
|
|
5
|
+
|
|
6
|
+
export const HCaptchaSecretKey = z.string().trim().length(42);
|
|
7
|
+
|
|
8
|
+
export type HCaptchaSecretKeyType = z.infer<typeof HCaptchaSecretKey>;
|
|
9
|
+
|
|
10
|
+
export const HCaptchaSiteKey = z.string().trim().length(36);
|
|
11
|
+
export type HCaptchaSiteKeyType = z.infer<typeof HCaptchaSiteKey>;
|
|
12
|
+
|
|
13
|
+
export const HCaptchaResponseToken = z.string().trim();
|
|
14
|
+
export type HCaptchaResponseTokenType = z.infer<typeof HCaptchaResponseToken>;
|
|
15
|
+
|
|
16
|
+
type HCaptchaVerifierModeType = "local" | "production";
|
|
17
|
+
|
|
18
|
+
export const AccessDeniedHcaptchaError = new HTTPException(403, {
|
|
19
|
+
message: "access_denied_recaptcha",
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
export type HCaptchaVerifierConfigType = {
|
|
23
|
+
secretKey: HCaptchaSecretKeyType;
|
|
24
|
+
mode: HCaptchaVerifierModeType;
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
export class HcaptchaShield {
|
|
28
|
+
private readonly secretKey: HCaptchaSecretKeyType;
|
|
29
|
+
private readonly mode: HCaptchaVerifierModeType;
|
|
30
|
+
|
|
31
|
+
private readonly LOCAL_HCAPTCHA_RESPONSE_PLACEHOLDER = "10000000-aaaa-bbbb-cccc-000000000001";
|
|
32
|
+
|
|
33
|
+
constructor(config: HCaptchaVerifierConfigType) {
|
|
34
|
+
this.mode = config.mode;
|
|
35
|
+
this.secretKey = config.secretKey;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
build = createMiddleware(async (c, next) => {
|
|
39
|
+
try {
|
|
40
|
+
const form = await c.req.formData();
|
|
41
|
+
|
|
42
|
+
const hcaptchaTokenFormData = form.get("h-captcha-response")?.toString() as HCaptchaResponseTokenType;
|
|
43
|
+
|
|
44
|
+
const result = await hcaptcha.verify(
|
|
45
|
+
this.secretKey,
|
|
46
|
+
this.mode === "production" ? hcaptchaTokenFormData : this.LOCAL_HCAPTCHA_RESPONSE_PLACEHOLDER,
|
|
47
|
+
);
|
|
48
|
+
|
|
49
|
+
if (!result?.success) {
|
|
50
|
+
throw AccessDeniedHcaptchaError;
|
|
51
|
+
}
|
|
52
|
+
return next();
|
|
53
|
+
} catch (error) {
|
|
54
|
+
throw AccessDeniedHcaptchaError;
|
|
55
|
+
}
|
|
56
|
+
});
|
|
57
|
+
}
|