Giter VIP home page Giter VIP logo

now-we-test's Issues

Query strings failing on routes

Routes using query string might be rebuild to wrong paths.

i.e.:

For routes:

  "routes": [
    {
      "src": "/(?<id>.*)",
      "dest": "/src/hooks/$id.js",
      "headers": { "Access-Control-Allow-Origin": "*" }
    }
  ]

And request

/foo?bar=tor`

The resolved path is currently:

/src/hooks/foo?bar=tor.js

Expected lambda file not found

I cannot reach any routes deeper than /.

Here's my now.json routes section:

"routes": [
  { "src": "/", "dest": "/services/index.js" },
  { "src": "/locations", "methods": ["GET"], "dest": "/services/locations/read.js" },
  { "src": "/users", "methods": ["GET"], "dest": "/services/users/read.js" },
  { "src": "/users/(?<id>[^/]*)", "methods": ["GET"], "dest": "/services/users/read.js?id=$id" },
  { "src": "/users", "methods": ["POST"], "dest": "/services/users/create.js" }
]

If I try to reach /locations, I get the error Expected lambda file not found. Deployed on Now 2.0, this works, so there is a problem with the now-we-test server reaching the .js files specified in the routes.

Routes.find() produces wrong route.

Here is a JSFiddle of the event.

https://jsfiddle.net/5n0whef7/1/

Essentially in the serve.js file, it's looping through my routes, finds a matching route, and then returns the route after the matching route as the value.

If the req.url is "/api/auth", then the right route is returned. If the req.url is "/api/auth/signin", then the .find() function returns the wrong value.

How I can test a POST method

I was looking at the code and I can't saw nowhere the method send of supertest lib, I guess without that it is not possible to test the POST method right? Can you provide some examples how do you test the POST methods?

Thanks for advance.

TypeScript support

Hey, @Meesayen, perhaps we can work on a pull-request to add TypeScript support based on your fork? Thanks for the work, by the way ;)

Support for node@canary

It would be great to support the @now/node@canary builder. For the purpose of this simulator that should be easy since it will simply do the same thing as @now/node here I think.

I can make a PR if you're open to this idea.

Add Regex Notes

Would totally understand if you don't want to bother with this, but for those of us not well versed in Regex would it be possible to add //comments in the code explaining what's happening here. Or maybe just comments here if you don't want them in the code. Thank you!

Found in lib/commands/serve.js

req.url.match(new RegExp(^${src.replace(/(?<[a-z]+>/, '(')}$))

dest.replace(new RegExp('\\$' + id), $+{${id}})

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.