question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Error when used in overnightjs project

See original GitHub issue

Caused by incorrect placing of parentheses during the isArray check.

Existing https://github.com/express-promise-router/express-promise-router/blob/6bf785ae1f04e12cb209745642d377cb99a80020/lib/express-promise-router.js#L80

Modified

(Array.isArray(args[0]) && ('string' === typeof args[0][0] || args[0][0] instanceof RegExp))

Possibly relates to https://github.com/express-promise-router/express-promise-router/issues/46

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:9 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
andrewmackrodtcommented, Mar 20, 2020

That is a different issue, if you believe you’re using the library correctly I’d recommend creating a new issue.

0reactions
andrewmackrodtcommented, Jun 9, 2020

In my instance this was caused by incorrect usage of overnightjs (potentially a bug in overnightjs itself) and possibly covered in the FAQ. I still believe this issue to be valid but cannot think of a failing test case when the library is used correctly.

import {Controller, Delete, Get, Options, Patch, Post, Put} from '@overnightjs/core'
import {Request, Response} from 'express'
import {constants as status} from 'http2'

@Controller('*')
export class NotFoundController {
    // these routes are ok
    @Options('') public optionsNotFound(req: Request, res: Response) { this.notFound(req, res) }
    @Get('') public getNotFound(req: Request, res: Response) { this.notFound(req, res) }
    @Patch('') public patchNotFound(req: Request, res: Response) { this.notFound(req, res) }
    @Put('') public putNotFound(req: Request, res: Response) { this.notFound(req, res) }
    @Post('') public postNotFound(req: Request, res: Response) { this.notFound(req, res) }

    // this one will cause the error
    @Delete() public deleteNotFound(req: Request, res: Response) { this.notFound(req, res) }

    private notFound(req: Request, res: Response) {
        res.status(status.HTTP_STATUS_NOT_FOUND).json({error: 'Not Found'})
    }
}

When a “correct” route is defined, args[0] is a callback so the check for args[0][0] does not fail (args[callback][0] == undefined). In the “incorrect” route example, args is empty so args[undefined][0] == error.

Read more comments on GitHub >

github_iconTop Results From Across the Web

@overnightjs/logger - npm Package Health Analysis | Snyk
Part of the OvernightJS project. ... Ensure you're using the healthiest npm packages ... @ClassErrorMiddleware decorators to use Express error handling.
Read more >
Node | error middleware doesn't handle exceptions
Our back-end application is based on node and TS, and we are using overnightJS library. Unfortunately when I'm trying to create and Error...
Read more >
overnightjs/logger/README.md - UNPKG
236, OvernightJS provides a Server superclass which initializes a new ExpressJS application. The express. 237, object is accessed using `this.app`, ...
Read more >
@overnightjs/core NPM | npm.io
OvernightJS provides a Server superclass which initializes a new ExpressJS application. The express object is accessed using this.app , which is a protected, ......
Read more >
Using Overnightjs + Sequelize in Typescript to create Nodejs ...
... you how to create Nodejs application by using using Overnightjs + Sequelize ... "test": "echo \"Error: no test specified\" && exit 1",...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found