overnight icon indicating copy to clipboard operation
overnight copied to clipboard

404 on all routes when using express-promise-router

Open thekevinbrown opened this issue 5 years ago • 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?

thekevinbrown avatar Oct 22 '20 00:10 thekevinbrown

Same problem here. Any solution?

maulerjan avatar Dec 06 '20 09:12 maulerjan

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

thekevinbrown avatar Dec 06 '20 23:12 thekevinbrown

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

orendaeko avatar Apr 29 '21 02:04 orendaeko

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.

Papooch avatar May 05 '21 07:05 Papooch