Code Monkey home page Code Monkey logo

Comments (9)

jameshfisher avatar jameshfisher commented on May 20, 2024

All I see at connect/index.js (where the error originates) is

/**

  • Stack the given middleware handle to the given route.
    *
  • @param {String} route
  • @param {Function} handle
  • @return {Server}
  • @api public
    */

Ok, so "route" is a string, not a function. (That ambiguity in the error message should be eliminated.) But anyway, what does this mean? "Route" as in the "router" middleware? I can't see how that has anything to do with it, and I can't think of another relevant type of "route" this could be.

from connect.

tj avatar tj commented on May 20, 2024

shit, year static() should be staticProvider(). I am not sure that "route" is the proper word to describe it, personally I would call it a "mount path" or something, but basically it allows you to "mount" say the static middleware to a specific base path, for example server.use("/public", connect.staticProvider())

from connect.

jameshfisher avatar jameshfisher commented on May 20, 2024

... ok. I don't think I understand. Let's take the examples at http://howtonode.org/connect-it . Neither the "from scratch" app, nor the "robust using built-in" app, work: when I run connect server.js, I get

/home/lm/.node_libraries/connect/index.js:146
        throw new Error("Each layer must have a route and a handle function");

I get exactly the same if I set exports.route in serve-js.js and log-it.js, like so:

exports.route = __dirname;

So to keep this simple, how should the tutorial at the above URL be changed for it to now work?

from connect.

tj avatar tj commented on May 20, 2024

that tutorial is pretty old now.. you can basically use the example above, with staticProvider instead of "static" (which I will fix), and run connect

from connect.

creationix avatar creationix commented on May 20, 2024

Perhaps I should update the article. Updating...

from connect.

frank06 avatar frank06 commented on May 20, 2024

Many examples with latest connect and express don't work. "Each layer must have a route and a handle function" in all of them. Bug?

from connect.

tj avatar tj commented on May 20, 2024

its because I made a change to allow server.use(fn) instead of server.use('/', fn) my examples use the former, which unfortunately will blow up right now, I should switch them until a new connect is released

from connect.

frank06 avatar frank06 commented on May 20, 2024

if it's for me it's ok... given that you can pass those into express.createServer() without a path ... so no biggie. thanks

from connect.

tj avatar tj commented on May 20, 2024

my and guillermo had a big talk about dependencies. its a stupid issue with node stuff right now. git IS a package manager essentially, we talked about vendorizing connect in express, but it leads to other problems so I dont have a good answer at this moment but the preferred install method would probably be $ curl http://expressjs.com/install.sh | sh

from connect.

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.