Questions tagged [koa.js]

A Koa application is an object containing an array of middleware generator functions which are composed and executed in a stack-like manner upon request

About

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

Koa is similar to many other middleware systems that you may have encountered such as Ruby's Rack, Connect, and so on - however a key design decision was made to provide high level "sugar" at the otherwise low-level middleware layer. This improves interoperability, robustness, and makes writing middleware much more enjoyable.

Links

17 questions
13
votes
2 answers

How to process request headers in Koa.js?

How to accept request content-type of application/vnd.api+json and reject anything else? Also how can I access the x-api-key value using Koa.js ? Thanks in advance
Roobie
  • 1,346
  • 4
  • 14
  • 24
1
vote
0 answers

How to set up custom koa.js server in next.js

I have set up custom koa.js server and every time I make a request to api for example /api/login It always ends up in being 404 not found. I have tried looking for a solution but, could not really find it. Below is my server.js file import…
LosMos
  • 119
  • 9
1
vote
1 answer

Adding Custom Middlewares in Strapi

I am creating a custom middleware for strapi that will change the response body to the hash. I need to use this middleware for all routes in strapi, means on the application level. 'use strict'; /** * `ctx-decrypt` middleware. */ var crypto =…
Saif Ali
  • 11
  • 2
1
vote
1 answer

How to use middleware with router.verb() in koa

I'm using Koa.js and I was wondering how I could use a middleware with router.verb() As mentioned here router.use([path], middleware) I tried like below. The console.log() trigger but the users.list is not called My main objective is to do an auth…
L.Castel
  • 36
  • 6
1
vote
1 answer

404 not found with fetch request to route handler on server.js (Koa.js)

I'm seeing this error in Chrome console (https://8e2dac99.ngrok.io/ is a local proxy tunnel on http://localhost:3000); VM76:1 GET https://8e2dac99.ngrok.io/api/2019-10/custom_collections.json 404 (Not Found) (anonymous) @ VM76:1 _callee2$ @…
Sean D
  • 3,810
  • 11
  • 45
  • 90
1
vote
1 answer

How to create a middleware in Koa.js using ES6

I am building an application in Koa.JS for the first time after coming from a recent background of using Express. I am using Babel to transpile the code at runtime whilst developing giving me the beneift of wirting ES6+ code. I am having issues in…
James
  • 2,800
  • 7
  • 45
  • 81
1
vote
2 answers

How to download csv file with koajs

I'm using koajs as a framework for nodejs. I try to create csv data and response it to client but not working let fields = ['code', 'status']; let p = new Promise((resolve, reject) => { json2csv({data: data, fields: fields }, (err, response) =>…
Chu Văn Nam
  • 121
  • 2
  • 5
0
votes
0 answers

how to get cookie in koa.js from a request

I am using koa.js as a node.js server and setting a jwt token as a cookie. It gets set correctly. When a user authenicates, the cookie is set. In response headers, I can see the set-cookie attribute Set-Cookie:…
LosMos
  • 119
  • 9
0
votes
1 answer

Is there any easy way to connect my koa.js backend with mongodb

Is there any easy way to connect my koa.js backend with mongodb
0
votes
1 answer

Search for specific string in a nested object in mongodb documents using and condition

I am trying to search for documents in mongodb that include a specific search string input by the user. Collection that i am trying to search in is named imported_products and my mongodb document structure looks like following. { ┃ _id:…
Deviker
  • 29
  • 2
  • 7
0
votes
1 answer

KoaJs Custom ErrorHandler middleware now working

I want to create an errorHandler middleware for my app. I used KoaJs for my web application and my error basic handler function like that: error-handler.ts: import { Context } from "koa"; export const errorHandler : any = (err : Error, ctx :…
akasaa
  • 1,282
  • 4
  • 13
  • 33
0
votes
1 answer

Koa.js request-promise return [ The property , ' ' , in the request body is invalid ]

I try to post json to Line' messaging api with koa.js and request-promise but got error as attached image : I'm using heroku with koa.js to connect with Line messaging api. Here is my code : const Koa = require('koa'); const Router =…
Nut
  • 11
  • 1
0
votes
1 answer

Getting Error: Uncaught (in promise): Response with status: 404 Not Found for URL:

I am making a request to endpoint written in koa.js and I am new to this framework. API return 404 response. Route file looks like below: const collabRepo = require("../repo/collab/collab-repo") const notificationRepo =…
Always_a_learner
  • 4,585
  • 13
  • 63
  • 112
0
votes
1 answer

'db.Schema is not a constructor' - NodeJS

I've been working on Koa.js and i'm trying to implement some basic authentication functionality. Unfortunately I can't really understand why my snippet isn't working. const db = require('mongoose') const bcrypt = require('bcrypt') const…
Rentonie
  • 477
  • 1
  • 10
  • 25
0
votes
2 answers

Chaning two HTTP request with Koa.js

I have been trying to make two chaining HTTP requests calls, second call is based on the return result of the first call. Requirement is make the first call to get the IP information and use the IP information to make the second call to grab weather…
Jeremy.Xu
  • 1
  • 1
  • 5
1
2