seanpmaxwell/overnight

404 on all routes when using express-promise-router

Opened this issue · 4 comments

I tried to follow the docs in the readme. It looks like the types have changed so that you no longer need the import * as, but even when I change that I get 404s on all routes that are working just fine with the default router.

Is there an easy way to debug what's happening so I can figure out whether the issue is how Overnight is setting up the router, or if instead it's an express-promise-router problem?

Same problem here. Any solution?

I ended up not using express-promise-router for now.

for me use express-promise-router can't get req.body but if use normal router at sample project its working fine,
thanks for sharing

Had the same problem, but I think I solved it!

It seems that when using express-promise-router, you have to pass a string to the @get() (or any) decorator.

e.g. this returns 404 for GET /docs

@Get()
async getArray(req: Request, res: Response) {
    const docs = await this.docsService.getArray();
    res.json(docs.map(this.docMapper.toDto));
}

But when you pass an empty string to the decorator, it works!

@Get('') // pass '' if the route takes no params
async getArray(req: Request, res: Response) {
    const docs = await this.docsService.getArray();
    res.json(docs.map(this.docMapper.toDto));
}

I don't know where the issue lies exactly, but this seems to have solved it for me.