question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Unable to extend the app's context in Koa@2

See original GitHub issue

Trying to extend the context of the application since migrating to koa@2 throws this error:

TypeError: Cannot set property 'property_name' of #<Object> which has only a getter

A small example code

import Koa from 'koa';

const app = new Koa();
app.context.host = process.env.HOST || '0.0.0.0';
app.context.port = process.env.PORT || 8080;

Issue Analytics

  • State:closed
  • Created 8 years ago
  • Reactions:4
  • Comments:9 (6 by maintainers)

github_iconTop GitHub Comments

10reactions
xiaoxin999commented, Mar 19, 2020

6666666

8reactions
duanchongchongcommented, Oct 29, 2019

for(var i=0;i<100;i++){ console.log(i) }

Read more comments on GitHub >

github_iconTop Results From Across the Web

Adding properties to Koa2's context in Typescript
My current approach is to augment the Koa2 context but I'm failing because I don't know how to fix the type definition. Here...
Read more >
Koa - next generation web framework for node.js
app.context is the prototype from which ctx is created. ... Koa applications extend an internal EventEmitter. ctx.app.emit emits an event with a type, ......
Read more >
fleek-validator: Documentation | Openbase
This package is to be used as middleware for Koa2 to validate swagger documentation using ctx.fleek.context defined by fleek-context or an equivalent custom ......
Read more >
Koa (koajs) -- 基于Node.js 平台的下一代web 开发框架| Koajs ...
nvm install 7 $ npm i koa $ node my-koa-app.js ... app.context 是从其创建 ctx 的原型。您可以通过编辑 app.context 为 ctx 添加其他属性。
Read more >
The Best Node.js Framework: Koa VS Express VS Hapi ...
You can increase the performance of a Node.js app greatly by launching a cluster of processes (a cluster runs multiple instances of the...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found