Giter Site home page Giter Site logo

Comments (2)

mafrosis avatar mafrosis commented on April 28, 2024

I take it all back :) The module in middy works just fine.

I copied the source of httpErrorHandler to customise it for my app, and changed the import to an ES6 style instead of using require:

import HttpError from 'http-errors';
// handler.error instanceof HttpError => false

The original looks like:

const { HttpError } = require('http-errors')
// handler.error instanceof HttpError => true

However if import createError, then I can make the ES6 style import work:

import createError from 'http-errors';
// handler.error instanceof createError.HttpError => true

Which may indicate that either A) I don't know nodejs, B) I'm using Babel wrong or C) probably both.

If anyone has read this far, thanks for your time! 💯

from middy.

lmammino avatar lmammino commented on April 28, 2024

Hey @mafrosis, thanks for your time and for using middy :)

I have to say that these kind of errors with the new module syntax are normal, I spent a decent amount of time myself with similar issues when I started using them (and still I get something wrong from time to time), so don't be too hard on yourself!

I look forward to seeing your first contribution to this project!

from middy.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.