Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Koa middleware first draft, not tested #45

Closed
wants to merge 20 commits into from

Conversation

keyvan-m-sadeghi
Copy link
Member

First line of attack at #30

@joeframbach
Copy link
Member

Looks pretty good, but I'm struggling with the dependencies. With express and several koa dependencies, agendash is becoming pretty large. The dependencies on Express and Koa should be optional, since Agendash will be brought in to a project that already has one or the other installed. Is there a good way to say in package.json, "X is an optional dependency, but if it exists, it needs to be version >1.2.3"?

@keyvan-m-sadeghi
Copy link
Member Author

keyvan-m-sadeghi commented Dec 10, 2016

Yeah, that's how I first went about it, asking the user to add the dependencies. Then saw you had express in the list of dependencies and thought it'd be fine.

Is there a good way to say in package.json, "X is an optional dependency, but if it exists, it needs to be version 1.2.3"?

Even that wouldn't help in Koa's case. Note that Koa itself is not in the list of dependencies, there are three middlewares that I added, one for parsing request's body, a router and one for serving static files. A Koa dependency in itself doesn't enforce the other three. Guess I go back to asking the user.

@keyvan-m-sadeghi
Copy link
Member Author

keyvan-m-sadeghi commented Dec 11, 2016

Is there a good way to say in package.json, "X is an optional dependency, but if it exists, it needs to be version 1.2.3"?

I went through the npm docs and didn't see anything like this
https://docs.npmjs.com/files/package.json
there is an optionalDependencies section but it does something entirely different.

How about using tags? So npm install agendash@koa would install the koa version of dependencies (doesn't include express) and default is express (like what already is)

Anyway, my current approach is meaningless, one should install dependencies that one never uses for a package to work? Nonsense.

npm install --save koa@next koa-bodyparser@next koa-router@next koa-static@next agenda agendash

@keyvan-m-sadeghi
Copy link
Member Author

@joeframbach did you find the time to go through this?

@joeframbach
Copy link
Member

Sorry I will have time this evening.

@joeframbach
Copy link
Member

Update: I spent a day on this over the holidays, and another few hours this morning. Unfortunately I could not find a way to manage the dependencies that I am happy about. The tradeoff is in git repo management: by splitting into branches, the tag and release management becomes awful. I'm working on a PR to the agnostic repo that will cover koa. Perhaps that is what is needed here.

@joevo2
Copy link

joevo2 commented Sep 5, 2017

Any update on koa support? Try to follow the guide but kinda got it running half way only?
screen shot 2017-09-05 at 5 28 38 pm

jquery-2.2.0.min.js:4 GET http://localhost:4000/api 404 (Not Found)

I did it like this
was following the guide by @keyvan-m-sadeghi at here

const agenda = new Agenda({ db: { address: agendadb } })

// This part doesnt work :( would like to use it like this
// router.use('/agendash', Agendash(agenda, {
//   middleware: 'koa'
// }))

agenda.define('send email report', (job, done) => {
  var data = job.attrs.data
  console.log('Ran agenda job for ' + data.to)
  done()
})

agenda.on('ready', () => {
  agenda.every('5 seconds', 'send email report', {
    to: 'joevo2@gmail.com'
  })
  agenda.start()
})

koa
  .use(Agendash(agenda, {
    middleware: 'koa'
  }))
  .use(router.routes())
  .listen(port)

koa version

    "koa": "^2.2.0",
    "koa-bodyparser": "^4.2.0",
    "koa-router": "^7.2.0",
    "koa-static": "^4.0.1",

@simison
Copy link
Member

simison commented Sep 5, 2017

@joevo2 All the help would be welcome! @joeframbach is quite busy.

@keyvan-m-sadeghi
Copy link
Member Author

keyvan-m-sadeghi commented Sep 5, 2017

@joevo2 APIs were functional and UI wasn't the last state I remember, as per comments on the original issue, though @joeframbach decided this approach is wrong and I stopped working on it.

@OmgImAlexis
Copy link
Member

How should we go about resurrecting this?

@koresar
Copy link
Contributor

koresar commented Jan 19, 2021

Koa2 middleware was added. See #148

@koresar koresar closed this Jan 19, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants