Giter VIP home page Giter VIP logo

Comments (17)

tejasmanohar avatar tejasmanohar commented on July 2, 2024

provide a runnable example for #1

does not work when the mounted app use koa-router@next

from mount.

amitport avatar amitport commented on July 2, 2024

this:

const mountedApp = new Koa();

const router = Router();
router.get('/', (ctx) => {
        ctx.body = 'throws type error'
});
mountedApp.use(router.routes());

...

app.use(convert(mount(mountedApp)));

will throw when accessing '/':

TypeError: next is not a function
      at Object.dispatch ([...]\node_modules\koa-router\lib\router.js:315:32)
      at Object.<anonymous> ([...]\node_modules\koa-mount\node_modules\koa-compose\index.js:26:19)
      at next (native)
      at onFulfilled ([...]\node_modules\co\index.js:65:19)
      at [...]\node_modules\co\index.js:54:5
      at new Promise ([...]\users\node_modules\core-js\modules\es6.promise.js:197:7)
      at Object.co ([...]\node_modules\co\index.js:50:10)
      at converted ([...]\node_modules\koa-convert\index.js:17:15)
      at dispatch ([...]\node_modules\koa-compose\index.js:41:32)
      at [...]\node_modules\koa-compose\index.js:34:12
      at Server.<anonymous> ([...]\node_modules\koa\lib\application.js:126:7)
      at emitTwo (events.js:100:13)
      at Server.emit (events.js:185:7)
      at HTTPParser.parserOnIncoming [as onIncoming] (_http_server.js:537:12)
      at HTTPParser.parserOnHeadersComplete (_http_common.js:89:23)

from mount.

tejasmanohar avatar tejasmanohar commented on July 2, 2024

where's koa-convert?

from mount.

amitport avatar amitport commented on July 2, 2024
import convert from 'koa-convert';
import Router from 'koa-router';
import mount from 'koa-mount';

from mount.

tejasmanohar avatar tejasmanohar commented on July 2, 2024

ah, my bad. missed the fn call on the bottom- sorry, skimmed it haha.

from mount.

gyson avatar gyson commented on July 2, 2024

Current version of koa-mount does not support Koa 2 but above code makes it to accept Koa 2 app instance at app.use(convert(mount(mountedApp))), which results that mount() returns a broken middleware (producing TypeError).

Current koa-mount only accepts Koa 1 app and returns Koa 1 middleware.

Ideally, we should have koa-mount@next which will accept Koa 2 app and return Koa 2 middleware and you can mount without koa-convert like this app.use(mount(mountedApp)). (https://github.com/coderhaoxin/mount/tree/next-by-promise did this)

from mount.

tejasmanohar avatar tejasmanohar commented on July 2, 2024

@coderhaoxin In this case, since koa-convert doesn't 100% do the trick, I'd suggest that we publish your promisified version of koa-mount w/ the next tag on npm for koa@2 users.

@amitport In the meantime, you can use a Git URI in NPM. I'd fork @coderhaoxin's changes into your own fork / repo so that if he deletes his branch, your builds don't fail :P

from mount.

haoxins avatar haoxins commented on July 2, 2024

@tejasmanohar I wil change the examples and test to async&await in my own next-by-promise branch

  1. examples: async&await is the end-users use cases normally IMO.
  2. tests: not for end-users, so compiled is fine?

Any thought? And then, it's suitable to be published IMO (need npm right 😄)

from mount.

tejasmanohar avatar tejasmanohar commented on July 2, 2024

👍 100% agree @coderhaoxin

from mount.

haoxins avatar haoxins commented on July 2, 2024

@tejasmanohar or anyone can review this? coderhaoxin/koa-mount#next :)
If OK, I'll push to koajs/mount#next

from mount.

captainill avatar captainill commented on July 2, 2024

is this moving forward to support Koa 2?

from mount.

haoxins avatar haoxins commented on July 2, 2024

@jonathanong I need the right on npm :)

from mount.

jonathanong avatar jonathanong commented on July 2, 2024

added

from mount.

ianstormtaylor avatar ianstormtaylor commented on July 2, 2024

+1, thanks @coderhaoxin!

from mount.

haoxins avatar haoxins commented on July 2, 2024
npm dist-tag ls koa-mount
latest: 1.3.0
next: 2.0.0

from mount.

haoxins avatar haoxins commented on July 2, 2024

3e861e4

from mount.

ianstormtaylor avatar ianstormtaylor commented on July 2, 2024

Beautiful, thanks again!

from mount.

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.