Questions tagged [koa]

Koa is a web framework which aims to be a smaller, more expressive, and more robust foundation for web applications and APIs.

Koa is a web framework for Node.js, designed by the team behind Express, aiming to be a smaller, more expressive, and more robust foundation for web applications and APIs.

Use this tag if your question is about the application middleware generators and its cascading properties or the use of App.Settings. Note also the existence of the tag if you're using the middleware API with async/await.

Resources

1232 questions
5
votes
1 answer

How localtunnel works under the hood?

I've been using localtunnel for quite a while and now I wonder how it works under the hood. Here is one article I read which explains the same. Here are few terminologies which I don't understand from the above article: the localtunnel server…
Kaushal28
  • 5,377
  • 5
  • 41
  • 72
5
votes
0 answers

Memory leak with jest (node, koa, sequelize)

Stack: System: OS: macOS High Sierra 10.13.4 CPU: x64 Intel(R) Core(TM) i7-4770HQ CPU @ 2.20GHz Binaries: Node: 8.1.4 - ~/.nvm/versions/node/v8.1.4/bin/node npm: 6.0.0 - ~/.nvm/versions/node/v8.1.4/bin/npm npmPackages: …
5
votes
1 answer

What is koa:sess.sig?

I am using Passport.js with Koa, and I noticed that when a session cookie is generated, it is called koa:sess and contains the session information encoded as Base64. However, there is another cookie called koa:sess.sig, and its purpose is not…
laptou
  • 6,389
  • 2
  • 28
  • 59
5
votes
4 answers

Google Cloud Functions, Node JS 8.9.x (LTS) and KOA library

How can I use Koa library, the express replacement, in Cloud Functions? I know KOA use all great ES2017 and make more use of Async use of JavaScript. or it might not be needed at all working with Cloud Functions because the Firebase system won't…
Nisim Joseph
  • 2,262
  • 22
  • 31
5
votes
2 answers

Why can't koa-router be put before koa-cors?

I use Koa with Node.js 8.1. Today I found that in my app.js, if I write in this order: const Koa = require('koa') var cors = require('koa-cors') const app = new Koa() app.use(cors(options)) app.use(router.routes()) the cors can work. I can verify…
guo
  • 9,674
  • 9
  • 41
  • 79
5
votes
1 answer

How to use passport with koa-generic-session()?

I've created a Koa application which uses passport with a local authentication strategy. I'd like to use the module koa-generic-session so I can store the session data in Redis. How do I use those two together? I found this repo which does this but…
Hedge
  • 16,142
  • 42
  • 141
  • 246
5
votes
1 answer

How does yield understand Promises in a Node.js/Koa.js application?

I am looking at a Koa.js/Node.js application and I think I have a good understanding of generators and promises. But I cannot wrap my head around the following code: function *parseAuthorization() { let parameters = this.query; let…
Milen Kovachev
  • 5,111
  • 6
  • 41
  • 58
5
votes
1 answer

Koa-session getting reset after appending object to it?

I have a controller which looks up a character, and then does some stuff with it, the controller looks like: router.post('/profile/characters', async ctx => { try { ctx.type = 'json'; let req = ctx.request; if…
Datsik
  • 14,453
  • 14
  • 80
  • 121
5
votes
1 answer

Can I run Koajs without the --harmony tag

Since iojs merged into Node. I assumed I can run koajs without the --harmony tag (because it'll have generators from es6 supported). So within my server.js file I have: var koa = require('koa'); var app = koa(); app.use(function *(){ this.body =…
pourmesomecode
  • 4,108
  • 10
  • 46
  • 87
5
votes
1 answer

Setting multiple cookie headers in Koa

I am trying to clear two cookies in my clients browser via the following: this.response.set('Set-Cookie', 'mycookie1=; Path=/; expires=Thu, 01 Jan 1970 00:00:00 GMT; ,mycookie1.sig=; Path=/; expires=Thu, 01 Jan 1970 00:00:00 GMT;'); I can only seem…
basickarl
  • 37,187
  • 64
  • 214
  • 335
5
votes
1 answer

How to Generate API docs for KOA Based server

I am having a KOA based server. now i want to generate API docs for the server. Is there any tools for auto generating API Docs
Amit Mourya
  • 538
  • 1
  • 7
  • 18
5
votes
2 answers

Koa : what is the difference between koa-route and koa-mount. When should I use each?

I am trying to use Koa.js, and checked out the following modules for routing requests: 1. koa-route 2. koa-mount When I check their github page/tutorials in google, the examples look almost similar with minor differences. For koa-route: var route =…
Kop4lyf
  • 4,520
  • 1
  • 25
  • 31
5
votes
3 answers

Is there a Express-style nested router for Koa.js?

Is there exist a library that provides Express-style nesting routers? Something like this: var koa = require('koa'); var app = koa(); var Router = require('???'); var restApiRouter = Router(); restApiRouter.get('/', function*() { // respond to…
Lesha K
  • 53
  • 1
  • 4
5
votes
1 answer

How to create KOA route with both parameter and regex

How can I accomplish the following KOA route handler: app.get("/Chicago_Metro/Cicero_City", myFunctionHandler1) app.get("/Cook_County/Cicero_City", myFunctionHandler2) and end up with "Chicago" as the parameter to be passed for "metro" OR "Cook"…
Biba
  • 748
  • 4
  • 13
5
votes
3 answers

Can't figure out how to use yield with async request

I'm somewhat new to node, and I'm completely new to koa. I'm trying to use generators to do async web requests to an API, but I can't figure out how to put all the pieces together. As a note, I'm using bluebird because I saw some examples do that,…
snollygolly
  • 1,858
  • 2
  • 17
  • 31