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
0
votes
2 answers

Call exported function koajs

I have a koa app which has a bunch of functions split up into separate files. When one route is called I need to pass the context this to another function (which is also a route) in an separate file. File a.js route -…
sbarow
  • 2,759
  • 1
  • 22
  • 37
0
votes
1 answer

Wrap library with thunkify for co

I was wondering how to thunkify (wrap in thunk) a library for use with co. The library is like the following. All the Client calls use other objects in the library. Library.Client = function(opts) { } Library.Client.prototype.createList =…
dre
  • 1,422
  • 3
  • 21
  • 31
0
votes
1 answer

Wait for async process to finish before redirect in koajs

I'm currently trying to spawn a child process to handle some POST data with NodeJS (using Koa framework). Ideally, I would like to wait for the child process to finish before redirecting, but since the child process is asynchronous, the code always…
ghstcd
  • 11
  • 3
0
votes
1 answer

Testing random values with mocha/supertest

I have this KoaJS application that is serving an API and I am using mocha/supertest to test the API. One of the tests is to make sure that you can create an oauth token through the API. The test looks like this: it('should be able to create a…
ryanzec
  • 27,284
  • 38
  • 112
  • 169
0
votes
1 answer

why trigger console twice when i use koajs

I try koajs today and write the helloworld example: /** * index.js */ var koa = require('koa'); var app = koa(); app.use(function*(){ this.body = 'hello world'; console.log('success!'); }); app.listen(8080); then I run the index.js file…
jabez128
  • 183
  • 2
  • 15
0
votes
1 answer

refactor node-mysql callback for KOA and co-mysql with generators

I am doing queries like below in existings apps and would like some advice/example on how to refactor this for KOA + co-mysql with generators avoiding or simplifying the chained functions with the sql calls. JS is fine, of course, I use a nodejs…
user1559375
0
votes
1 answer

Authorization with Middleware

I have an application that needs authorization based on the relation between the requesting user and the requested resource. The access details are encapsulated in the resource to be requested. Let's take the route PATCH /articles/1: the article…
bernhardw
  • 3,239
  • 2
  • 20
  • 16
0
votes
1 answer

Co.js app reports "TypeError: Cannot call method 'apply' of undefined"

When ever I try to run my Co.app I get TypeError: Cannot call method 'apply' of undefined at /home/ecarroll/code/chrome-okc-plugin/node_modules/thunkify/index.js:32:8 at /home/ecarroll/code/chrome-okc-plugin/test.js:12:17 at…
Evan Carroll
  • 78,363
  • 46
  • 261
  • 468
0
votes
0 answers

Set alias for Nodejs with harmony argument in Powershell

Im need to using node --harmony each time when working with node.recently im working with koajs and in the home page of koajs sayed can use this command alias node='node --harmony' but when i calling this command on powershell i get this error :…
MBehtemam
  • 7,865
  • 15
  • 66
  • 108
0
votes
1 answer

Mount Koa application in different directory

I have a three koa application and the structure of this these application is like this : app.js directory app2 app2.js directory app3 app3.js i try to mount app2.js and app3.js on app.js using koa-mount package but i get an error : var name…
MBehtemam
  • 7,865
  • 15
  • 66
  • 108
0
votes
3 answers

Hosting Emberjs Application on Koajs with koa-static

I'm hosting an emberjs application on koajs with koa-static. according to below code : var app = koa(); var App1 = koa(); App1.use(stati(__dirname + "/App1")); app.use(mount('/AppViewer',App1)); app.listen(3000); When calling…
MBehtemam
  • 7,865
  • 15
  • 66
  • 108
-1
votes
1 answer

After adding cors to nodeJS returning internal server error

I'm stuck with cors issue.I have to get data on another port, so i need cors dependency. there appears problem. everything works fine without app.use(cors()); but when i add it, server returns internal server error Error code 500 const Koa =…
-1
votes
1 answer

When/where is the best moment to check for Firestore document ownership (service or middleware)

When implementing security rules to ensure a user can only fetch/update their own documents in Firestore, where should I put the logic? (Before you say 'in Firestore Security Rules file', please note that I am using the Firebase Admin SDK which…
-1
votes
2 answers

Is it better to user const = require(); or import '' from ''; If yes, could you show me?

It looks like your post is mostly code; please add some more details.It looks like your post is mostly code; please add some more details.It looks like your post is mostly code; please add some more details.It looks like your post is mostly code;…
-1
votes
1 answer

Create .csv and send as response in express/koa

I have some data in csv format and I want to send it as a file attachment (example.csv) to an http response without saving it as a temp file on the fs. Can this be done in express/koa?