Typescript extend third-party declaration files
You have to use module augmentation as described here: import { Context } from “koa”; declare module “koa” { interface Context { resource: any; } }
You have to use module augmentation as described here: import { Context } from “koa”; declare module “koa” { interface Context { resource: any; } }
Finaly I found how to do it. app.use(async (ctx, next) => { ctx.set(‘Access-Control-Allow-Origin’, ‘*’); ctx.set(‘Access-Control-Allow-Headers’, ‘Origin, X-Requested-With, Content-Type, Accept’); ctx.set(‘Access-Control-Allow-Methods’, ‘POST, GET, PUT, DELETE, OPTIONS’); await next(); });
EDIT: I’ve updated the code examples below because the koa-router package on npm is no longer maintained. The Koa team has made an official fork of it under the name @koa/router. For anyone reading this, who is curious on how to do this in Koa 2.X: app.js import Koa from ‘koa’ import rootRouter from ‘./routes/root’ … Read more
According to the docs there should be a ctx.request.query that is the query string items represented as an object.
I’ve been working almost extensively with generators for a month now so maybe I can take a stab at this. I’ll try to keep the opinions to a minimum. Hopefully it helps clarify some of the confusion. Part of the reason for the lack of best practices and better explanations is that the feature is … Read more