@ahmedbaset/adminjs-hono 0.1.0 → 0.1.2
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/lib/buildAuthenticatedRouter.d.ts +1 -1
- package/lib/buildAuthenticatedRouter.d.ts.map +1 -1
- package/lib/buildAuthenticatedRouter.js +2 -4
- package/lib/buildRouter.d.ts +2 -1
- package/lib/buildRouter.d.ts.map +1 -1
- package/lib/buildRouter.js +2 -3
- package/lib/index.d.ts +2 -2
- package/lib/index.js +2 -2
- package/package.json +1 -1
- package/src/buildAuthenticatedRouter.ts +2 -5
- package/src/buildRouter.ts +3 -4
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import AdminJS from 'adminjs';
|
|
2
|
-
import
|
|
2
|
+
import { Hono } from 'hono';
|
|
3
3
|
import type { AuthenticationOptions, SessionOptions, UploadOptions } from './types.js';
|
|
4
4
|
/**
|
|
5
5
|
* Builds a Hono app with AdminJS routes protected by session-based authentication
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"buildAuthenticatedRouter.d.ts","sourceRoot":"","sources":["../src/buildAuthenticatedRouter.ts"],"names":[],"mappings":"AAAA,OAAO,OAAkC,MAAM,SAAS,CAAA;AACxD,OAAO,
|
|
1
|
+
{"version":3,"file":"buildAuthenticatedRouter.d.ts","sourceRoot":"","sources":["../src/buildAuthenticatedRouter.ts"],"names":[],"mappings":"AAAA,OAAO,OAAkC,MAAM,SAAS,CAAA;AACxD,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAA;AAW3B,OAAO,KAAK,EAAE,qBAAqB,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,YAAY,CAAA;AAItF;;;;;;;;;GASG;AACH,wBAAgB,wBAAwB,CACtC,KAAK,EAAE,OAAO,EACd,IAAI,EAAE,qBAAqB,EAC3B,aAAa,CAAC,EAAE,IAAI,EACpB,cAAc,CAAC,EAAE,cAAc,EAC/B,aAAa,CAAC,EAAE,aAAa,GAC5B,IAAI,CAwDN"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { Router as AdminRouter } from 'adminjs';
|
|
2
|
+
import { Hono } from 'hono';
|
|
2
3
|
import { withLogin } from './authentication/login.handler.js';
|
|
3
4
|
import { withLogout } from './authentication/logout.handler.js';
|
|
4
5
|
import { withProtectedRoutesHandler } from './authentication/protected-routes.handler.js';
|
|
@@ -27,10 +28,7 @@ export function buildAuthenticatedRouter(admin, auth, predefinedApp, sessionOpti
|
|
|
27
28
|
if (auth.authenticate && auth.provider) {
|
|
28
29
|
throw new WrongArgumentError(INVALID_AUTH_CONFIG_ERROR);
|
|
29
30
|
}
|
|
30
|
-
|
|
31
|
-
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
|
32
|
-
const { Hono: HonoClass } = require('hono');
|
|
33
|
-
const app = predefinedApp ?? new HonoClass();
|
|
31
|
+
const app = predefinedApp ?? new Hono();
|
|
34
32
|
// Get routes and assets from AdminJS
|
|
35
33
|
const { routes, assets } = AdminRouter;
|
|
36
34
|
// If provider is configured, add its UI props to AdminJS env
|
package/lib/buildRouter.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import AdminJS, { Router as AdminRouter } from 'adminjs';
|
|
2
|
-
import
|
|
2
|
+
import { Hono } from "hono";
|
|
3
|
+
import type { Handler } from 'hono';
|
|
3
4
|
import type { HonoVariables } from './types.js';
|
|
4
5
|
/**
|
|
5
6
|
* Validates and initializes an AdminJS instance
|
package/lib/buildRouter.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"buildRouter.d.ts","sourceRoot":"","sources":["../src/buildRouter.ts"],"names":[],"mappings":"AAAA,OAAO,OAAO,EAAE,EAAE,MAAM,IAAI,WAAW,EAAE,MAAM,SAAS,CAAA;AACxD,OAAO,
|
|
1
|
+
{"version":3,"file":"buildRouter.d.ts","sourceRoot":"","sources":["../src/buildRouter.ts"],"names":[],"mappings":"AAA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aAAa,CAAC,EAAE,aAAa,GAC5B,IAAI,CAkBN"}
|
package/lib/buildRouter.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { Router as AdminRouter } from 'adminjs';
|
|
2
|
+
import { Hono } from "hono";
|
|
2
3
|
import { WrongArgumentError, INVALID_ADMINJS_INSTANCE } from './errors.js';
|
|
3
4
|
import { log } from './logger.js';
|
|
4
5
|
import { convertToHonoRoute } from './convertRoutes.js';
|
|
@@ -164,9 +165,7 @@ export function buildRouter(admin, predefinedApp, uploadOptions) {
|
|
|
164
165
|
// Initialize AdminJS
|
|
165
166
|
initializeAdmin(admin);
|
|
166
167
|
// Use provided app or create new Hono instance
|
|
167
|
-
|
|
168
|
-
const { Hono: HonoClass } = require('hono');
|
|
169
|
-
const app = predefinedApp ?? new HonoClass();
|
|
168
|
+
const app = predefinedApp ?? new Hono();
|
|
170
169
|
// Get routes and assets from AdminJS
|
|
171
170
|
const { routes, assets } = AdminRouter;
|
|
172
171
|
// Register form parsing middleware
|
package/lib/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { buildAuthenticatedRouter } from './buildAuthenticatedRouter.js';
|
|
2
2
|
import { buildRouter } from './buildRouter.js';
|
|
3
3
|
/**
|
|
4
|
-
* @module @adminjs
|
|
4
|
+
* @module @ahmedbaset/adminjs-hono
|
|
5
5
|
*
|
|
6
6
|
* AdminJS adapter for Hono web framework
|
|
7
7
|
*
|
|
@@ -13,7 +13,7 @@ import { buildRouter } from './buildRouter.js';
|
|
|
13
13
|
* ```typescript
|
|
14
14
|
* import { Hono } from 'hono'
|
|
15
15
|
* import AdminJS from 'adminjs'
|
|
16
|
-
* import { buildRouter } from '@adminjs
|
|
16
|
+
* import { buildRouter } from '@ahmedbaset/adminjs-hono'
|
|
17
17
|
*
|
|
18
18
|
* const admin = new AdminJS({
|
|
19
19
|
* databases: [],
|
package/lib/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { buildAuthenticatedRouter } from './buildAuthenticatedRouter.js';
|
|
2
2
|
import { buildRouter } from './buildRouter.js';
|
|
3
3
|
/**
|
|
4
|
-
* @module @adminjs
|
|
4
|
+
* @module @ahmedbaset/adminjs-hono
|
|
5
5
|
*
|
|
6
6
|
* AdminJS adapter for Hono web framework
|
|
7
7
|
*
|
|
@@ -13,7 +13,7 @@ import { buildRouter } from './buildRouter.js';
|
|
|
13
13
|
* ```typescript
|
|
14
14
|
* import { Hono } from 'hono'
|
|
15
15
|
* import AdminJS from 'adminjs'
|
|
16
|
-
* import { buildRouter } from '@adminjs
|
|
16
|
+
* import { buildRouter } from '@ahmedbaset/adminjs-hono'
|
|
17
17
|
*
|
|
18
18
|
* const admin = new AdminJS({
|
|
19
19
|
* databases: [],
|
package/package.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import AdminJS, { Router as AdminRouter } from 'adminjs'
|
|
2
|
-
import
|
|
2
|
+
import { Hono } from 'hono'
|
|
3
3
|
import { withLogin } from './authentication/login.handler.js'
|
|
4
4
|
import { withLogout } from './authentication/logout.handler.js'
|
|
5
5
|
import { withProtectedRoutesHandler } from './authentication/protected-routes.handler.js'
|
|
@@ -43,10 +43,7 @@ export function buildAuthenticatedRouter(
|
|
|
43
43
|
throw new WrongArgumentError(INVALID_AUTH_CONFIG_ERROR)
|
|
44
44
|
}
|
|
45
45
|
|
|
46
|
-
|
|
47
|
-
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
|
48
|
-
const { Hono: HonoClass } = require('hono')
|
|
49
|
-
const app = predefinedApp ?? new HonoClass()
|
|
46
|
+
const app = predefinedApp ?? new Hono()
|
|
50
47
|
|
|
51
48
|
// Get routes and assets from AdminJS
|
|
52
49
|
const { routes, assets } = AdminRouter
|
package/src/buildRouter.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import AdminJS, { Router as AdminRouter } from 'adminjs'
|
|
2
|
-
import
|
|
2
|
+
import {Hono} from "hono"
|
|
3
|
+
import type { Handler, Context } from 'hono'
|
|
3
4
|
import { WrongArgumentError, INVALID_ADMINJS_INSTANCE } from './errors.js'
|
|
4
5
|
import { log } from './logger.js'
|
|
5
6
|
import { convertToHonoRoute } from './convertRoutes.js'
|
|
@@ -206,9 +207,7 @@ export function buildRouter(
|
|
|
206
207
|
initializeAdmin(admin)
|
|
207
208
|
|
|
208
209
|
// Use provided app or create new Hono instance
|
|
209
|
-
|
|
210
|
-
const { Hono: HonoClass } = require('hono')
|
|
211
|
-
const app = predefinedApp ?? new HonoClass()
|
|
210
|
+
const app = predefinedApp ?? new Hono()
|
|
212
211
|
|
|
213
212
|
// Get routes and assets from AdminJS
|
|
214
213
|
const { routes, assets } = AdminRouter
|