jax-hono 1.0.3 → 1.0.5

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.
@@ -1,7 +1,7 @@
1
1
  import { existsSync, readFileSync, readdirSync, writeFileSync } from 'node:fs'
2
2
  import { cwd } from 'node:process'
3
3
  import { basename, join, parse, relative } from 'node:path'
4
- import { ensureGeneratedDir, generatedDir, projectDir } from './generated-path'
4
+ import { ensureGeneratedDir, generatedDir, packageDir, projectDir } from './generated-path'
5
5
 
6
6
  const srcDir = join(cwd(), 'src')
7
7
  const moduleExtensions = new Set(['.ts', '.js', '.mjs', '.cjs'])
@@ -575,6 +575,7 @@ function serializePluginOptions(options: unknown) {
575
575
 
576
576
  function generatePluginContextRegistry() {
577
577
  const enabledPlugins = mergePluginConfig([
578
+ { filePath: join(packageDir, 'plugins/config.ts'), config: readPluginConfig(join(packageDir, 'plugins/config.ts')) },
578
579
  { filePath: join(srcDir, 'config/plugin.ts'), config: readPluginConfig(join(srcDir, 'config/plugin.ts')) },
579
580
  ])
580
581
  const imports = enabledPlugins.map(([name, item]) => {
package/middleware/jwt.ts CHANGED
@@ -15,6 +15,15 @@ function createJwtAuth<
15
15
  TPayload extends Record<string, any> = Record<string, any>,
16
16
  >(options: JwtAuthOptions<TPayload>): MiddlewareHandler {
17
17
  return async (c, next) => {
18
+ const session = c.var.session;
19
+ const sessionData = await session.get();
20
+
21
+ if (sessionData && sessionData[options.stateKey]) {
22
+ c.state[options.stateKey] = sessionData[options.stateKey];
23
+ await next();
24
+ return;
25
+ }
26
+
18
27
  // const session = c.get('session');
19
28
  // const sessionData = session.get(options.stateKey);
20
29
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "jax-hono",
3
- "version": "1.0.3",
3
+ "version": "1.0.5",
4
4
  "description": "Lightweight framework layer on top of Hono, built for Bun",
5
5
  "type": "module",
6
6
  "main": "./index.ts",
@@ -95,6 +95,7 @@
95
95
  },
96
96
  "devDependencies": {
97
97
  "@types/bun": "^1.3.14",
98
+ "@types/jsonwebtoken": "^9.0.10",
98
99
  "dayjs": "^1.11.21",
99
100
  "deepmerge": "^4.3.1",
100
101
  "dotenv": "^17.4.2",
@@ -118,4 +119,4 @@
118
119
  "bun": ">=1.0.0"
119
120
  },
120
121
  "license": "MIT"
121
- }
122
+ }
package/plugins/config.ts CHANGED
@@ -1,8 +1,8 @@
1
- import { definePluginConfig } from '../helpers/config';
1
+ import { definePluginConfig } from "../helpers/config";
2
2
 
3
3
  export default definePluginConfig({
4
4
  session: {
5
5
  enable: true,
6
- package: 'jax/plugins/session'
7
- }
6
+ package: "jax-hono/plugins/session",
7
+ },
8
8
  });