@@ -19,7 +19,7 @@ export const backend = createBackend<BackendType, APIServerConfig>({
1919 async start ( ctx ) {
2020 const config = await ctx . getConfig ( ) ;
2121
22- await this . init ( ctx ) ;
22+ this . init ( ctx ) ;
2323 registerCallback ( ( songInfo ) => {
2424 this . songInfo = songInfo ;
2525 } ) ;
@@ -60,8 +60,7 @@ export const backend = createBackend<BackendType, APIServerConfig>({
6060 } ,
6161
6262 // Custom
63- async init ( ctx ) {
64- const config = await ctx . getConfig ( ) ;
63+ init ( backendCtx ) {
6564 this . app = new Hono ( ) ;
6665
6766 this . app . use ( '*' , cors ( ) ) ;
@@ -74,6 +73,8 @@ export const backend = createBackend<BackendType, APIServerConfig>({
7473
7574 // middlewares
7675 this . app . use ( '/api/*' , async ( ctx , next ) => {
76+ const config = await backendCtx . getConfig ( ) ;
77+
7778 if ( config . authStrategy !== AuthStrategy . NONE ) {
7879 return await jwt ( {
7980 secret : config . secret ,
@@ -83,6 +84,7 @@ export const backend = createBackend<BackendType, APIServerConfig>({
8384 } ) ;
8485 this . app . use ( '/api/*' , async ( ctx , next ) => {
8586 const result = await JWTPayloadSchema . spa ( await ctx . get ( 'jwtPayload' ) ) ;
87+ const config = await backendCtx . getConfig ( ) ;
8688
8789 const isAuthorized =
8890 config . authStrategy === AuthStrategy . NONE ||
@@ -98,12 +100,12 @@ export const backend = createBackend<BackendType, APIServerConfig>({
98100 // routes
99101 registerControl (
100102 this . app ,
101- ctx ,
103+ backendCtx ,
102104 ( ) => this . songInfo ,
103105 ( ) => this . currentRepeatMode ,
104106 ( ) => this . volume ,
105107 ) ;
106- registerAuth ( this . app , ctx ) ;
108+ registerAuth ( this . app , backendCtx ) ;
107109
108110 // swagger
109111 this . app . openAPIRegistry . registerComponent (
0 commit comments