{"_id":"@brt-innovation/aether-utility","_rev":"8-7689f078e4470267a4a93bbbad220042","name":"@brt-innovation/aether-utility","dist-tags":{"latest":"1.0.5"},"versions":{"1.0.0":{"name":"@brt-innovation/aether-utility","version":"1.0.0","license":"UNLICENSED","_id":"@brt-innovation/aether-utility@1.0.0","maintainers":[{"name":"chaiyasit.kh","email":"chaiyasit.kh.57@gmail.com"},{"name":"prawee","email":"konkeanweb@gmail.com"}],"homepage":"https://github.com/brtinnovation/aether-utility-lib#readme","bugs":{"url":"https://github.com/brtinnovation/aether-utility-lib/issues"},"dist":{"shasum":"b7dbc898a6ea25f478a7123ada246094e5bb7209","tarball":"https://registry.npmjs.org/@brt-innovation/aether-utility/-/aether-utility-1.0.0.tgz","fileCount":5,"integrity":"sha512-xdng2N5m8noORlcEfbhkd6z2SWkkMDJ+MU0cka/WI8FZ7W52p5V1XelqnBnyM0PJth7kVP19V+MApFzAVwA8nQ==","signatures":[{"sig":"MEQCIEFOwDXcGZizcuN6vyx22aAE8NGT1P75QtWs9DE+wBSPAiAudkWD8PSdaN0cowlsVtA/VsWf1fXpm5n9BBd5DIhZ0A==","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":12982},"main":"dist/index.js","types":"dist/index.d.ts","module":"dist/index.js","engines":{"node":">=20"},"exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.js","require":"./dist/index.js"}},"gitHead":"78c6c96a21211261584ca4dd7159c854fb3efc22","scripts":{"test":"vitest run","build":"tsup src/index.ts --dts --tsconfig tsconfig.json","format":"prettier --write .","prepare":"npm run build","release":"npm publish --access public","test:watch":"vitest","format:check":"prettier --check .","prepublishOnly":"npm run test"},"_npmUser":{"name":"chaiyasit.kh","email":"chaiyasit.kh.57@gmail.com"},"repository":{"url":"git+https://github.com/brtinnovation/aether-utility-lib.git","type":"git"},"_npmVersion":"10.8.2","description":"Shared utilities and middlewares for Aether microservices","directories":{},"_nodeVersion":"20.19.5","publishConfig":{"access":"public"},"_hasShrinkwrap":false,"devDependencies":{"tsup":"^8.5.1","dayjs":"^1.11.19","vitest":"^4.0.18","prettier":"^3.8.1","typescript":"^5.9.3"},"peerDependencies":{"hono":"^4.0.0","dayjs":"^1.11.19"},"_npmOperationalInternal":{"tmp":"tmp/aether-utility_1.0.0_1770782223637_0.4171089470505325","host":"s3://npm-registry-packages-npm-production"}},"1.0.1":{"name":"@brt-innovation/aether-utility","version":"1.0.1","license":"UNLICENSED","_id":"@brt-innovation/aether-utility@1.0.1","maintainers":[{"name":"chaiyasit.kh","email":"chaiyasit.kh.57@gmail.com"},{"name":"prawee","email":"konkeanweb@gmail.com"}],"homepage":"https://github.com/brtinnovation/aether-utility-lib#readme","bugs":{"url":"https://github.com/brtinnovation/aether-utility-lib/issues"},"dist":{"shasum":"e86e0bd0458955b9a4f0ed53fbbf145c4fe71e7d","tarball":"https://registry.npmjs.org/@brt-innovation/aether-utility/-/aether-utility-1.0.1.tgz","fileCount":5,"integrity":"sha512-a1vYxyEbFtvVdyGE5kKcq1C3vrU1MOaqjWi6eR3NeUUqJ8oUMR4+KVCegmuk6CjIwyKAhs/JmW0ulUaB+gqN4g==","signatures":[{"sig":"MEUCIBsjxJyqG58s+rgQ5UrJjnimBH//mRBODmkuREog+wt6AiEAuvJcPnPnSrjTlDxNuHjhtALKQLAbBRD+7Xnav0Zdsno=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":16134},"main":"dist/index.js","types":"dist/index.d.ts","module":"dist/index.js","engines":{"node":">=20"},"exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.js","require":"./dist/index.js"}},"gitHead":"6248e82945ab28fe7f4219e8b3c059dd094d2a71","scripts":{"test":"vitest run","build":"tsup src/index.ts --dts --tsconfig tsconfig.json","format":"prettier --write .","prepare":"npm run build","release":"npm publish --access public","test:watch":"vitest","format:check":"prettier --check .","prepublishOnly":"npm run test"},"_npmUser":{"name":"chaiyasit.kh","email":"chaiyasit.kh.57@gmail.com"},"repository":{"url":"git+https://github.com/brtinnovation/aether-utility-lib.git","type":"git"},"_npmVersion":"10.8.2","description":"Shared utilities and middlewares for Aether microservices","directories":{},"_nodeVersion":"20.19.5","publishConfig":{"access":"public"},"_hasShrinkwrap":false,"devDependencies":{"tsup":"^8.5.1","dayjs":"^1.11.19","vitest":"^4.0.18","prettier":"^3.8.1","typescript":"^5.9.3"},"peerDependencies":{"hono":"^4.0.0","dayjs":"^1.11.19"},"_npmOperationalInternal":{"tmp":"tmp/aether-utility_1.0.1_1770794748468_0.5991948388380877","host":"s3://npm-registry-packages-npm-production"}},"1.0.2":{"name":"@brt-innovation/aether-utility","version":"1.0.2","license":"UNLICENSED","_id":"@brt-innovation/aether-utility@1.0.2","maintainers":[{"name":"chaiyasit.kh","email":"chaiyasit.kh.57@gmail.com"},{"name":"prawee","email":"konkeanweb@gmail.com"}],"homepage":"https://github.com/brtinnovation/aether-utility-lib#readme","bugs":{"url":"https://github.com/brtinnovation/aether-utility-lib/issues"},"dist":{"shasum":"8896acd564bd7b63c036502b98fe1d7b126ca2e0","tarball":"https://registry.npmjs.org/@brt-innovation/aether-utility/-/aether-utility-1.0.2.tgz","fileCount":35,"integrity":"sha512-yH/x9/SHj2yTv0vX3LfCfrsqS8BI+Ua0xPRRclqXi4z0VpP/qjJxLFP28xNiFUC7SAM9fomSt2cJKZv/q7RyZA==","signatures":[{"sig":"MEUCIQCcHNhJUHH+3Zh2Ly12H93l+Cm6XnXIza+iOZ2kTgwKWwIgFx9T5SwWsERFzFFKbS7KxEQZK3ivF4xE9Ag4zTKPxDM=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":69067},"main":"./dist/index.cjs","type":"module","types":"./dist/index.d.ts","engines":{"node":">=20"},"exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.js","require":"./dist/index.js"},"./*":{"types":"./dist/*/index.d.ts","import":"./dist/*/index.js","require":"./dist/*/index.cjs"}},"gitHead":"4b5ca17b2145e719cb2a2cd30c36f45b6a5d6297","scripts":{"test":"vitest run","build":"tsup","format":"prettier --write .","prepare":"npm run build","test:watch":"vitest","format:check":"prettier --check .","prepublishOnly":"npm run test"},"_npmUser":{"name":"chaiyasit.kh","email":"chaiyasit.kh.57@gmail.com"},"deprecated":"Broken build - use >=1.0.4","repository":{"url":"git+https://github.com/brtinnovation/aether-utility-lib.git","type":"git"},"_npmVersion":"10.8.2","description":"Shared utilities and middlewares for Aether microservices","directories":{},"sideEffects":false,"_nodeVersion":"20.19.5","publishConfig":{"access":"public"},"_hasShrinkwrap":false,"devDependencies":{"tsup":"^8.5.1","dayjs":"^1.11.19","vitest":"^4.0.18","prettier":"^3.8.1","typescript":"^5.9.3"},"peerDependencies":{"hono":"^4.0.0","dayjs":"^1.11.19"},"_npmOperationalInternal":{"tmp":"tmp/aether-utility_1.0.2_1770801092417_0.30227462794340054","host":"s3://npm-registry-packages-npm-production"}},"1.0.3":{"name":"@brt-innovation/aether-utility","version":"1.0.3","license":"UNLICENSED","_id":"@brt-innovation/aether-utility@1.0.3","maintainers":[{"name":"chaiyasit.kh","email":"chaiyasit.kh.57@gmail.com"},{"name":"prawee","email":"konkeanweb@gmail.com"}],"homepage":"https://github.com/brtinnovation/aether-utility-lib#readme","bugs":{"url":"https://github.com/brtinnovation/aether-utility-lib/issues"},"dist":{"shasum":"c6d7d5344f32b472b1e607df23dd1a8b34c2cff5","tarball":"https://registry.npmjs.org/@brt-innovation/aether-utility/-/aether-utility-1.0.3.tgz","fileCount":35,"integrity":"sha512-0javPV2jAMv+TDuWY9yVkmxZW34wUUunDKiSaKftbcTgPjt8GcC0TOIE9rt/J99C0VGbflp5gc6cQhA/hKPzoA==","signatures":[{"sig":"MEYCIQC4DRU7AFM6KIAlPSudI9TyxIhFt48flKBFEZECrt/7MAIhAMx/J4CVcHMDf9se9RSTeJdXDniIdgLSR521CJWkq4Ju","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":69043},"main":"./dist/index.cjs","types":"./dist/index.d.ts","engines":{"node":">=20"},"exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.js","require":"./dist/index.js"},"./*":{"types":"./dist/*/index.d.ts","import":"./dist/*/index.js","require":"./dist/*/index.cjs"}},"gitHead":"380ebeab5988a627e676c346c66bcd15457e47b1","scripts":{"test":"vitest run","build":"tsup","format":"prettier --write .","prepare":"npm run build","test:watch":"vitest","format:check":"prettier --check .","prepublishOnly":"npm run test"},"_npmUser":{"name":"chaiyasit.kh","email":"chaiyasit.kh.57@gmail.com"},"deprecated":"Broken build - use >=1.0.4","repository":{"url":"git+https://github.com/brtinnovation/aether-utility-lib.git","type":"git"},"_npmVersion":"10.8.2","description":"Shared utilities and middlewares for Aether microservices","directories":{},"sideEffects":false,"_nodeVersion":"20.19.5","publishConfig":{"access":"public"},"_hasShrinkwrap":false,"devDependencies":{"tsup":"^8.5.1","dayjs":"^1.11.19","vitest":"^4.0.18","prettier":"^3.8.1","typescript":"^5.9.3"},"peerDependencies":{"hono":"^4.0.0","dayjs":"^1.11.19"},"_npmOperationalInternal":{"tmp":"tmp/aether-utility_1.0.3_1770801738601_0.7712906214706474","host":"s3://npm-registry-packages-npm-production"}},"1.0.4":{"name":"@brt-innovation/aether-utility","version":"1.0.4","license":"UNLICENSED","_id":"@brt-innovation/aether-utility@1.0.4","maintainers":[{"name":"chaiyasit.kh","email":"chaiyasit.kh.57@gmail.com"},{"name":"prawee","email":"konkeanweb@gmail.com"}],"homepage":"https://github.com/brtinnovation/aether-utility-lib#readme","bugs":{"url":"https://github.com/brtinnovation/aether-utility-lib/issues"},"dist":{"shasum":"b8aca4a8661a0c413d9250ef388e4f97516d3e63","tarball":"https://registry.npmjs.org/@brt-innovation/aether-utility/-/aether-utility-1.0.4.tgz","fileCount":27,"integrity":"sha512-sj4Zj40ha4nzHvpXzPP6uNuiIKt8VhJNivAE80VTP7fovg841NP1t2X7D0vwJhga9bWsNO1zD9KBveh/SykIRw==","signatures":[{"sig":"MEUCIEbjSvqWo9N3G9B5MnXztIZeFb0P+w7NOiWIxu+jh2iOAiEAwEXrFSbhv7YRX9uRW9+wdlhLr+SAQB0unW/c9JNL0l0=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":84413},"main":"./dist/index.cjs","types":"./dist/index.d.ts","engines":{"node":">=20"},"exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.js","require":"./dist/index.js"},"./*":{"types":"./dist/*/index.d.ts","import":"./dist/*/index.js","require":"./dist/*/index.cjs"}},"gitHead":"952468cf33419a4bbbe10440a3b75cb6dfb6e1d4","scripts":{"test":"vitest run","build":"tsup","format":"prettier --write .","prepare":"npm run build","test:watch":"vitest","format:check":"prettier --check .","prepublishOnly":"npm run test"},"_npmUser":{"name":"chaiyasit.kh","email":"chaiyasit.kh.57@gmail.com"},"repository":{"url":"git+https://github.com/brtinnovation/aether-utility-lib.git","type":"git"},"_npmVersion":"10.8.2","description":"Shared utilities and middlewares for Aether microservices","directories":{},"sideEffects":false,"_nodeVersion":"20.19.5","publishConfig":{"access":"public"},"_hasShrinkwrap":false,"devDependencies":{"tsup":"^8.5.1","dayjs":"^1.11.19","vitest":"^4.0.18","prettier":"^3.8.1","typescript":"^5.9.3"},"peerDependencies":{"hono":"^4.0.0","dayjs":"^1.11.19"},"_npmOperationalInternal":{"tmp":"tmp/aether-utility_1.0.4_1770802289666_0.9765787008245421","host":"s3://npm-registry-packages-npm-production"},"deprecated":"Root import is broken, please use subpath imports instead e.g. @brt-innovation/aether-utility/hono"},"1.0.5":{"name":"@brt-innovation/aether-utility","version":"1.0.5","license":"UNLICENSED","_id":"@brt-innovation/aether-utility@1.0.5","maintainers":[{"name":"chaiyasit.kh","email":"chaiyasit.kh.57@gmail.com"},{"name":"prawee","email":"konkeanweb@gmail.com"}],"homepage":"https://github.com/brtinnovation/aether-utility-lib#readme","bugs":{"url":"https://github.com/brtinnovation/aether-utility-lib/issues"},"dist":{"shasum":"35de630544aa5fe38e2e17613b3d07eaf4cd8a8f","tarball":"https://registry.npmjs.org/@brt-innovation/aether-utility/-/aether-utility-1.0.5.tgz","fileCount":21,"integrity":"sha512-g0cQpMsxDKpZ+QIsbeM+acJkG1GASljw9qFuNL8zfvB4sgCEgQuBoVT58g7lJ76wAdLmpY235LzY6MEWcKljFQ==","signatures":[{"sig":"MEUCIQCm6EcRpCh+58F1KsaARQPSLyFmJF3qzO/Rq3sd4nkJvgIgL0S1GK5WzmbI098izumFfZO0vfGqbvR+hcnqHHn099E=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":50835},"engines":{"node":">=20"},"exports":{"./*":{"types":"./dist/*/index.d.ts","import":"./dist/*/index.js","require":"./dist/*/index.cjs"}},"gitHead":"0a172bdf7ec7ddd44e44f844f988e216ec6573c5","scripts":{"test":"vitest run","build":"tsup","format":"prettier --write .","prepare":"npm run build","test:watch":"vitest","format:check":"prettier --check .","prepublishOnly":"npm run test"},"_npmUser":{"name":"chaiyasit.kh","email":"chaiyasit.kh.57@gmail.com"},"repository":{"url":"git+https://github.com/brtinnovation/aether-utility-lib.git","type":"git"},"_npmVersion":"10.8.2","description":"Shared utilities and middlewares for Aether microservices","directories":{},"sideEffects":false,"_nodeVersion":"20.19.5","publishConfig":{"access":"public"},"_hasShrinkwrap":false,"devDependencies":{"tsup":"^8.5.1","dayjs":"^1.11.19","vitest":"^4.0.18","prettier":"^3.8.1","typescript":"^5.9.3"},"peerDependencies":{"hono":"^4.0.0","dayjs":"^1.11.19"},"_npmOperationalInternal":{"tmp":"tmp/aether-utility_1.0.5_1773894494355_0.7424261937309491","host":"s3://npm-registry-packages-npm-production"}}},"time":{"created":"2026-02-11T03:57:03.497Z","modified":"2026-03-19T04:32:11.927Z","1.0.0":"2026-02-11T03:57:03.809Z","1.0.1":"2026-02-11T07:25:48.608Z","1.0.2":"2026-02-11T09:11:32.556Z","1.0.3":"2026-02-11T09:22:18.753Z","1.0.4":"2026-02-11T09:31:29.821Z","1.0.5":"2026-03-19T04:28:14.480Z"},"bugs":{"url":"https://github.com/brtinnovation/aether-utility-lib/issues"},"license":"UNLICENSED","homepage":"https://github.com/brtinnovation/aether-utility-lib#readme","repository":{"url":"git+https://github.com/brtinnovation/aether-utility-lib.git","type":"git"},"description":"Shared utilities and middlewares for Aether microservices","maintainers":[{"name":"chaiyasit.kh","email":"chaiyasit.kh.57@gmail.com"},{"name":"prawee","email":"konkeanweb@gmail.com"}],"readme":"# @brt-innovation/aether-utility\n\nShared utilities for Aether microservices.\n\nThis repository contains reusable components such as:\n\n- Hono middlewares\n- Common utilities\n- Shared types and constants\n\nThe library is published as a public npm package and is intended to be shared across Aether microservices.\n\n---\n\n## Installation\n\n```bash\nnpm install @brt-innovation/aether-utility\n```\n\n---\n\n## Peer Dependencies\n\nThis package requires the following peer dependencies:\n\n- dayjs ^1.11.19\n- hono ^4.0.0\n\n---\n\n## Usage\n\n### Importing the library\n\n```ts\nimport {\n  authMiddleware,\n  responseMiddleware,\n  onAppError,\n} from '@brt-innovation/aether-utility/hono';\nimport { formatDate, startOfDayBkk, bkkTimezone } from '@brt-innovation/aether-utility/dayjs';\n```\n\n---\n\n## Features\n\n### Hono Middleware\n\n#### authMiddleware\n\nAuthentication middleware for Hono using JWT.\n\n**Supported token sources**\n\n- `Authorization` header (Bearer token)\n- Cookie (fallback if header is missing)\n\n**Example (inline usage)**\n\n```ts\nimport { Hono } from 'hono';\nimport { authMiddleware } from '@brt-innovation/aether-utility/hono';\n\nconst app = new Hono();\n\napp.use(\n  '*',\n  authMiddleware({\n    jwtSecret: process.env.JWT_SECRET,\n  }),\n);\n```\n\n**Example (reusable middleware instance)**\n\n```ts\nimport { Hono } from 'hono';\nimport { authMiddleware } from '@brt-innovation/aether-utility/hono';\n\nconst authMid = authMiddleware({\n  jwtSecret: process.env.JWT_SECRET,\n});\n\nconst app = new Hono();\napp.use('*', authMid);\n```\n\n**Behavior**\n\n- Extracts access token from `Authorization` header or cookies\n- Verifies JWT signature and algorithm\n- Stores `userId` in Hono context (`c.set('userId', payload.sub)`)\n- Returns `401 Unauthorized` for invalid or missing token\n\n---\n\n#### responseMiddleware\n\nStandard response formatter middleware to ensure consistent API responses across services.\n\n**Example**\n\n```ts\nimport { Hono } from 'hono';\nimport { responseMiddleware } from '@brt-innovation/aether-utility/hono';\n\nconst app = new Hono();\n\napp.use('*', responseMiddleware);\n```\n\n---\n\n#### onAppError\n\nGlobal error handler for Hono applications.\n\nThis handler catches unhandled errors thrown during request processing\nand transforms them into a standardized API error response.\n\n**Example**\n\n```ts\nimport { Hono } from 'hono';\nimport { onAppError } from '@brt-innovation/aether-utility/hono';\n\nconst app = new Hono();\n\napp.onError(onAppError);\n```\n\n---\n\n### Dayjs Utilities\n\nCommon date/time utilities pre-configured with `dayjs`, `utc`, and `timezone` plugins. `Asia/Bangkok` is used as the default timezone for BKK specific functions.\n\n**Import**\n\n```ts\nimport {\n  startOfDayBkk,\n  endOfDayBkk,\n  startOfDayBkkToUtc,\n  endOfDayBkkToUtc,\n  convertUtcToBkk,\n  convertBkkToUtc,\n  formatDate,\n  bkkTimezone,\n} from '@brt-innovation/aether-utility/dayjs';\n```\n\n**Available Functions**\n\n- `bkkTimezone`: Constant `'Asia/Bangkok'`.\n- `startOfDayBkk(date)`: Returns the start of the day (00:00:00) in Bangkok timezone as a `Date` object.\n- `endOfDayBkk(date)`: Returns the end of the day (23:59:59.999) in Bangkok timezone as a `Date` object.\n- `startOfDayBkkToUtc(date)`: Returns the start of the day in Bangkok, converted to UTC as a `Date` object.\n- `endOfDayBkkToUtc(date)`: Returns the end of the day in Bangkok, converted to UTC as a `Date` object.\n- `convertUtcToBkk(date)`: Converts a UTC date to Bangkok time (Date object with BKK wall time).\n- `convertBkkToUtc(date)`: Converts a Bangkok date to UTC.\n- `formatDate(date, options)`: Formats a date string or object.\n  - `options.format`: Format string (default: `'YYYY-MM-DD HH:mm:ss'`)\n  - `options.timezone`: Target timezone (default: `'UTC'`, options: `'UTC'`, `'Asia/Bangkok'`)\n\n**Example**\n\n```ts\nimport { formatDate, startOfDayBkk, bkkTimezone } from '@brt-innovation/aether-utility/dayjs';\n\nconst now = new Date();\nconst bkkStart = startOfDayBkk(now);\nconst formatted = formatDate(now, { timezone: bkkTimezone, format: 'DD/MM/YYYY' });\n```\n\n---\n\n## License\n\nUNLICENSED - Internal use only for BRT Innovation\n","readmeFilename":"README.md"}