@@ -12,6 +12,7 @@ import { MysqlDialect } from '@zenstackhq/orm/dialects/mysql';
1212import { PostgresDialect } from '@zenstackhq/orm/dialects/postgres' ;
1313import { SqliteDialect } from '@zenstackhq/orm/dialects/sqlite' ;
1414import type { SchemaDef } from '@zenstackhq/orm/schema' ;
15+ import { PolicyPlugin } from '@zenstackhq/plugin-policy' ;
1516import { RPCApiHandler } from '@zenstackhq/server/api' ;
1617import { ZenStackMiddleware } from '@zenstackhq/server/express' ;
1718import type BetterSqlite3 from 'better-sqlite3' ;
@@ -113,20 +114,11 @@ export async function run(options: Options) {
113114 throw new CliError ( `Failed to connect to the database: ${ err instanceof Error ? err . message : String ( err ) } ` ) ;
114115 }
115116
116- // If a publicAPIKey is provided, try to create an authDb with the policy plugin
117+ // If a publicAPIKey is provided, create an authDb with the policy plugin
117118 let authDb : ClientContract < SchemaDef > | undefined ;
118119 if ( options . publicAPIKey ) {
119- try {
120- const { PolicyPlugin } = await import ( '@zenstackhq/plugin-policy' ) ;
121- authDb = db . $use ( new PolicyPlugin ( ) ) as ClientContract < SchemaDef > ;
122- console . log ( colors . gray ( 'Access policy plugin enabled for authorization.' ) ) ;
123- } catch {
124- console . log (
125- colors . yellow (
126- 'Warning: @zenstackhq/plugin-policy is not installed. Authorization (per-user access control) will be disabled.' ,
127- ) ,
128- ) ;
129- }
120+ authDb = db . $use ( new PolicyPlugin ( ) ) as ClientContract < SchemaDef > ;
121+ console . log ( colors . gray ( 'Access policy plugin enabled for authorization.' ) ) ;
130122 }
131123
132124 startServer ( db , schemaModule . schema , options , authDb ) ;
0 commit comments