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
6
votes
1 answer

Node 8 + Typescript + Koa + koa-Router throws "TypeError: ctx.onerror is not a function"

I have a very simple server to play around with: import * as http from 'http'; import * as Koa from "koa"; import { Request, Response, Context } from "koa"; import * as Router from "koa-router"; import * as bodyParser from "koa-bodyparser"; const…
wzr1337
  • 3,609
  • 5
  • 30
  • 53
6
votes
1 answer

How to send a http response using koajs

I'm trying to validate a webhook via facebook. So facebook hits my url my-url/facebook/receive within my route in nodejs i'd do res.send(req.query['hub.challenge']); to send an http response. I'm using KoaJS. From what i understand, Koajs merges the…
pourmesomecode
  • 4,108
  • 10
  • 46
  • 87
6
votes
0 answers

Hot Module Reloading is making initial page request take 10-20s, with Webpack, Koa, Vue.js

For some reason most page refreshes re-request the bundle.js file and it takes about 10-15-20 seconds to download from localhost. This all from localhost, and the bundle.js file is about 1mb in size. The request for this file only seems to crawl,…
Ryan Weiss
  • 1,308
  • 1
  • 14
  • 36
6
votes
4 answers

Self signed SSL does not work after upgrading from iojs to nodejs v4.4.4

I was using iojs and koa in my application and recently I decided to update iojs to nodejs v4.4.4. The update was very smooth and my application was running in no time. The problem is that I am using a self signed SSL certificate on my development…
Ivan Stoyanov
  • 5,412
  • 12
  • 55
  • 71
6
votes
4 answers

How can I configure WebStorm to provide code completion for KoaJS?

Currently, WebStorm reports that KoaJS's methods are undefined. It's a minor, yet persistent annoyance. I've searched on the net and I've searched through WebStorm's configuration dialogs to no avail. Does anyone use WebStorm with KoaJS and have…
JC Ford
  • 6,946
  • 3
  • 25
  • 34
6
votes
3 answers

KoaJS how to get files from multipart form data?

When I post a multipart form,
It throws: Error: Unsupported content-type: multipart/form-data at…
lichao123125
  • 61
  • 1
  • 4
6
votes
3 answers

Using 'koa-router', app.use(router(app)) throws a "requires a generator function" error msg

var app = require('koa')(); var router = require('koa-router'); app.use(router(app)); Throws this error: AssertionError: app.use() requires a generator function A lot of sample code says to setup koa-router this way. It supposedly adds methods…
Rick
  • 572
  • 1
  • 7
  • 21
6
votes
3 answers

How to filter JSON objects according to "schema"

I build a RESTful api with node.js and express / koa. I want to filter the JSON data input - for security reasons as well to have only the needed business specific properties. After filtering the business-specific validation takes place. How can I…
Michael Schmidt
  • 3,391
  • 5
  • 34
  • 39
6
votes
4 answers

"Everything is middleware"

I'm learning Koa JS for building the server side part of a small web applications. Watching youtube tutorials and reading guides, I came across the sentence: "Everything is middleware [in Koa]." I have read the wikipedia article about middleware…
tomet
  • 2,416
  • 6
  • 30
  • 45
6
votes
2 answers

Co.js and bluebird.js -- what's the difference?

Could someone help me understand the differences between using Koa.js and Bluebird.js with ES6 Harmony. Specifically, how does co( function * () { //stuff } ); compare to, Promise.coroutine( function * () { //stuff } ); It just seems Koa…
Evan Carroll
  • 78,363
  • 46
  • 261
  • 468
5
votes
2 answers

Error: No valid exports main found for (Module path)

I was reorganising documents on my mac and I have accidentally broken an app I am building. I noticed the package.json had been removed along with the router.js. I added both files back and the koa dependency in package.json to test. CONSOLE…
Devunderdog
  • 81
  • 1
  • 6
5
votes
1 answer

how to pass callback data to koa ctx.body?

I'm using Typescript with nodejs.I have callback function and i'm getting data as a object in body when i console. I want to pass data in data key of ctx.body. Can i push that object in other variable and then pass to…
user12561026
5
votes
1 answer

How to use koa ctx body for multiple responses?

I am new in node with koa and postgresql. I have a created a user login api but i'm getting 404 not found error. My queries and checks are working as i checked on console but ctx.body not working. How i can handle multiple responses with koa…
Daniyal Mughees
  • 303
  • 7
  • 21
5
votes
2 answers

How to use koa.js + next in Firebase Functions

I want to use Cloud Functions for Firebase to deploy the React application for shopify app. I am new to both Next and Koa. Based on this repo the below code is how to host a simple react application in Firebase. const path = require('path') const…
Reza
  • 18,865
  • 13
  • 88
  • 163
5
votes
1 answer

Returning JSON in Koa

I receive JSON by POST method in my router which I then return to the user. For some reason the returned JSON will have all numerical and boolean values casted to string. I am using koa-bodyparser if thats relevant. Is there any way to avoid…
user1217406
  • 329
  • 3
  • 15