routing-controllers: @Authorized in version 0.7.2 stilll return 404.

happen:

   use Koa2 **async** controller with **async** authorizationChecker, still return a 404 in **@Authorized( )** decorator.

version:

   typescript: 2.4.2
   node: 7.6.0
   koa: 2.3.0
   routing-controllers: 0.7.2
   reflect0metadata: 0.1.10

code:

function sleep( time ) {
          return new Promise(( ok ,noOK ) => {
                  setTimeout(( ) => {
                        console.log('ok')
                        ok( );
                   }, time );
            })
}

@JsonController('/users')
export class UserCtrl {

  @Get('/')
  @Authorized( )
  async getAll(  ) {
        await sleep( 1000 );
        return "hahah" // serve return a 404 instead of ‘hahah’
  }
}

const app = new Koa( );
useKoaServer( app, {
  defaults: {
    paramOptions: {
      required: true
    }
  },
  authorizationChecker,
  routePrefix: '/api',
  controllers: [ UserCtrl ]
});
app.listen( 4000 );

async function authorizationChecker( action: Action, roles: string[]) {
  console.log('i am authorizationChecker')
  await sleep( 1000 );
  return true;
}

About this issue

  • Original URL
  • State: closed
  • Created 7 years ago
  • Reactions: 2
  • Comments: 15 (9 by maintainers)

Most upvoted comments

Sorry guys, looks like it’s fixed and just waiting for release 0.7.3.

I’ll publish it today. Guys please don’t forget (and users to update) CHANGELOG as well. New version is here, but changelog is empty