Skip to content
This repository has been archived by the owner on May 28, 2024. It is now read-only.

No support for koa web framework. #293

Open
jonaskuiler opened this issue Mar 4, 2019 · 4 comments
Open

No support for koa web framework. #293

jonaskuiler opened this issue Mar 4, 2019 · 4 comments

Comments

@jonaskuiler
Copy link

Currently, only lambda functions and express are supported by actions-on-google.

I've created a koa framework for a project I'm working on and I thought it would be useful for others to make a pull request.

@Fleker
Copy link
Member

Fleker commented Mar 4, 2019

I think that would be useful. In building the revised library, we wanted to ensure the framework was flexible enough to work with different frameworks, even if we didn't add them all ourselves. It may also be possible to build this as your own plugin that developers can include as an optional dependency.

@jonaskuiler
Copy link
Author

Hey Nick.

Like you said it's probably not the best idea to include all possible options for Node frameworks. I've created a pull request here #294. The implementation is probably not the hardest thing but I thought I'd submit it anyway. I did test it thoroughly in an existing project.

Please let me know if you would rather like this being a separate package.

@Canain
Copy link
Contributor

Canain commented Mar 25, 2019

Thanks for making the issue and creating the PR!

If we were to add Koa support to the library directly that means we would have to have greater support for Koa in our docs and possibly samples just like we do for Express and Lambda.

At this time, Koa is not a focus for us so it's not a good idea to add it directly right now.

But since you already wrote the code though to support it, like you said you can make it a separate package as a framework plugin.

All you have to do is to export it as a plugin like so:

// name this export whatever
export const koa: Plugin<{}, {}> = app => {
  app.frameworks.koa = new Koa()
  return app
}

Then have it deployed as a npm package with actions-on-google as a peer dependency.

A developer would then just need to require the plugin package and app.use it.

const { dialogflow } = require(`actions-on-google`)
const { koa } = require(`actions-on-google-plugin-koa`) // or any package name you want
const Koa = require('koa')

const app = dialogflow().use(koa)

app.intent('Default Welcome Intent', conv => {
  conv.ask('How are you?')
})

const koaApp = new Koa()
koaApp.use(app)
koaApp.listen(3000)

Actually, in the v2 alpha, we wrote an example of how something could like here.

@jimmywarting
Copy link

came here looking for a generic solution that would allow me to pass in the response body / headers / status code myself and respond back myself too.

there are quite many framework out there right now that is widely supported and dosen't even have/use NodeJS IncommingRequest and instead operates on standard web Request/Response using respondWith(response) for instance
or just return return new Response('hello world')

so i would like to have something as darn low level api as possible that dose not even handle any network traffic/api calls at all, and instead lets me do it myself somehow

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

5 participants