Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
  • Jun 22 07:41
    cheungchingli edited #1675
  • Jun 22 07:41
    cheungchingli edited #1675
  • Jun 22 07:39
    cheungchingli opened #1675
  • Jun 22 07:39
    cheungchingli labeled #1675
  • Jun 20 10:39
    Jay2983 commented #1186
  • Jun 18 15:20
    snakeUni commented #1657
  • Jun 17 06:31
    rayfoss commented #1114
  • Jun 17 06:30
    rayfoss commented #1114
  • Jun 17 06:23
    rayfoss commented #1114
  • Jun 17 05:58
    rayfoss commented #1114
  • Jun 11 00:36
    codecov[bot] commented #1673
  • Jun 11 00:36
    codecov[bot] commented #1673
  • Jun 11 00:35
    3jins opened #1673
  • Jun 10 08:49
    3jins edited #1672
  • Jun 10 08:30
    3jins edited #1672
  • Jun 10 08:13
    3jins labeled #1672
  • Jun 10 08:13
    3jins opened #1672
  • Jun 07 15:31
    codecov[bot] commented #1671
  • Jun 07 15:29
    zhaozeq commented #1671
  • Jun 07 15:28

    dependabot[bot] on npm_and_yarn

    (compare)

Eyal Perry
@EyalPerry
@NicholasCao I love the name :D and I do love koa. Unfortunately I do not know go at all
Nicholas
@NicholasCao
@EyalPerry
It doesn't matter, thank you for your start
Aaron
@4aron
Hi
Wow no chat since 1 month...
Can I add an extra arguments to session.save with koa-session?
I want to add some data to the stored session in the same insert
Vamsi Ampolu
@vamsiampolu

Hi guys, a question for you:

tl;dr: Trying to create a mock context like this:

const ctx = createContext({
      method,
      headers,
      body,
    });

throws TypeErrors

https://stackoverflow.com/questions/57864117/koa-create-context-cannot-set-headers-or-body

delphi
@johndeguerto
@vamsiampolu I think headers, methods don’t have setting when an hTTP method is get other than post. So context are executed once upon start of the server. perhaps the app.use( ) where you intialize context to run should be higher in the code chain prior to other middleware?
Vimal Mistry
@vimalmistry
Hello everyone. I want to use Koa for my next project. What is actual real world advantage of koa over express?. I want it for my api backend.
Vimal Mistry
@vimalmistry
Screenshot 2019-09-19 at 11.59.28 PM.png
AuthorizationMiddleware is still calling on first routes why?
delphi
@johndeguerto
@vimalmistry are you having an issue or are you asking why auth is being called in your load routes?
Vimal Mistry
@vimalmistry
@johndeguerto Thanks for reply. I have solved this issue by calling authRoute.use(myMiddleware) :)
Nemo
@gpugems
Hi, what is best npm for koa/health
Kevin
@kevinludwig
Hi, having a problem with setting ctx.body = a stream (sort of). Im using csv-stringify npm module's streams support, so my code is generally doing something like this: ctx.body = stream; await someCodeThatGeneratesCsvRows(stream); stream.end();
I should first say that the code works. The thing that's confusing me is that no rows come to the browser until all rows are generated (e.g. until stream.end() is called). I changed my stream writer to be something a bit more complex, like this, which vaguely what they say to do anyway in the Writable stream docs, const writer = (stream) => (obj) => { return new Promise((resolve) => { if (!stream.write(obj)) { stream.once('drain', resolve); } else { process.nextTick(resolve); } }); };
and when I do that, stream.write does indeed return false at some point but the drain event never arrives, so my request just hangs.
my vague guess is that Im doing something wrong and Koa isn't reading from the stream until .end() but I could be mistaken on that
Kevin
@kevinludwig
ok well I figure out how to get it working...after reading some koa source code. I need to not await someCodeThatGeneratesCsvRows(stream) and instead do ctx.body = stream; someCodeThatReturnsAPromiseThatIWontAwait(stream).then(() => stream.end());
...because Koa doesn't attach the pipe to the stream until after my middleware returns. Is this the way I'm supposed to be doing this? I don't think there's any examples that make this particularly clear in the docs...
If its not clear why I might be doing this, Imagine I'm reading blocks of data from a db (or another api) to fetch parts of a dataset, and then tranforming that data into CSV, and writing the CSV rows to a stream. So the method that generates the dataset is async, but I want koa to stream the results (obviously) as they arrive. And so given that Koa is built on top of async await it seemed natural to me that I could assign the stream and then pump data into the stream via awaiting as necessary...
Jonas Amundsen
@badeball
if I append a middleware in the runtime of another middleware (IE. during a request), will it be considered and possibly invoked for said request?
Guy Korland
@gkorland
Is there a way to load part of a session or lazy load part of it? And is there a way to store only part of the session and the all big session when only a small part of it changed?
Rajiv Mothilal
@rmothilal
Hi everyone, I'm a newbie to the koa framework. I need some assistance with an issue. I need to access the incoming request headers before request authentication is done. I need to insert additional headers to be used in subsequent functions/processes. Any help would be greatly appreciated. Thanks Rajiv
仇彦龙
@qiuyanlong
hello
Shashank Agarwal
@shashank1010
Hi, a NodeJS noob here,

I intend to create an application and reuse some app logic by forwarding an API call from one route to another.

for example. A request is made for /subscribed-users and i want to add to this context and call the /users route internally.

How can i achieve this with KOA?
Any help would be welcome.

Thanks.

Mayursinh Sarvaiya
@Marvin9
@shashank1010 , ctx.redirect should be used for this purpose. Read the documentation here https://github.com/koajs/koa/blob/master/docs/api/response.md#responseredirecturl-alt.
zavr-1
@zavr-1
hey i wanted to share my article https://medium.com/@art_deco/how-i-compiled-koa-with-closure-63c064d7fa36 maybe someone can find it useful
djazz
@daniel-j
Hi! What does the name koa mean?
djazz
@daniel-j
I'm guessing it comes from Co-routines
Ghost
@ghost~5ac084b8d73408ce4f93eee9
Mr Swedish god @jeffijoe, are you alive?
Jeff Hansen
@jeffijoe
@fjeddy I'm danish lol
Ghost
@ghost~5ac084b8d73408ce4f93eee9
Sorry, forgot :P
function Property {
  this.something = 'Something'
}

Property.prototype.test = require( './test.js' )

module.exports = Property
That there, the test file will have access to the context right?
As in, this.something will exist in Property.test
But, if I want to do multiple levels, I want to add more files inside the test file so I get Property.test.a and still persist the this context
Jeff Hansen
@jeffijoe
If invoked with the right context, it should, yeah.
Ghost
@ghost~5ac084b8d73408ce4f93eee9
Is that possible?
Jeff Hansen
@jeffijoe
I would just not do that.
Ghost
@ghost~5ac084b8d73408ce4f93eee9
Why?
The idea is to split one large class file into multiple files
Jeff Hansen
@jeffijoe
I mean you can just iterate those props and bind the funcs in the ctor
What are you trying to achieve?
Ghost
@ghost~5ac084b8d73408ce4f93eee9
And because the functions are so large, i would prefer to have one method in one file
My constructor() contains quite a lot of code that is used by almost every single function
So my goal is to split the entire class file into multiple files, but keep the idea of the constructor, and having the data the constructor defined, available in all the sub files
Jeff Hansen
@jeffijoe
Why do you want multiple levels?
Ghost
@ghost~5ac084b8d73408ce4f93eee9
Better structure
Keeping one method in one file, as they are rather long