Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
  • 00:54
    alazyzombie commented #1156
  • Jan 23 05:05
    codecov[bot] commented #1640
  • Jan 23 05:05
    hegner123 opened #1640
  • Jan 19 15:20
    codecov[bot] commented #1639
  • Jan 19 15:20
    codecov[bot] commented #1639
  • Jan 19 15:20
    codecov[bot] commented #1639
  • Jan 19 15:20
    codecov[bot] commented #1639
  • Jan 19 15:20
    codecov[bot] commented #1639
  • Jan 19 15:19

    dependabot[bot] on npm_and_yarn

    (compare)

  • Jan 19 15:19

    dependabot[bot] on npm_and_yarn

    build(deps-dev): bump supertest… (compare)

  • Jan 19 15:19
    dependabot[bot] closed #1634
  • Jan 19 15:19
    dependabot[bot] commented #1634
  • Jan 19 15:19
    dependabot[bot] labeled #1639
  • Jan 19 15:19
    dependabot[bot] opened #1639
  • Jan 19 05:30
    alazyzombie commented #1156
  • Jan 19 05:30
    alazyzombie commented #1156
  • Jan 19 05:30
    alazyzombie commented #1156
  • Jan 12 15:20
    codecov[bot] commented #1634
  • Jan 12 15:20
    codecov[bot] commented #1634
  • Jan 12 15:19

    dependabot[bot] on npm_and_yarn

    build(deps-dev): bump supertest… (compare)

Dylan Pierce
@ctrlaltdylan
so it's not reinitializing the db connection on every request
Jame
@jamemackson
that sounds like a solid plan. we’re using TypeORM and thankfully they handle that for us but I believe is their approach as well.
gcnyin
@gcnyin
Hi guys, How do you do distributed trace in koa/express? I found a node.js api AsyncLocationStorage in async_hooks module. I think it's easy to create tracing middleware base on this api. This is my demo repo https://github.com/gcnyin/koa-trace-id. Core part is
const app = new Koa();
const traceIdStorage = new AsyncLocalStorage<string>();

app.use(async (ctx, next) => {
    const traceId = ctx.request.header['x-trace-id'] ?? uuid4()
    traceIdStorage.run(traceId, next)
})

app.use(async ctx => {
    console.log('start', traceIdStorage.getStore())
    await new Promise<void>((resolve) => setTimeout(resolve, 100))
    console.log('end', traceIdStorage.getStore())
    ctx.body = 'Hello World'
})
This is just for application internal. For micro services, you can rewrite http/https modules, and inject traceId in header. These are my thoughts. End.
gcnyin
@gcnyin
Oh, I found cls-rtracer. It already did it.
githubabusebygitter
@githubabusebygitter
When I ctx.throw(), my logger displays the error I throw, but my browser receives a generic 500, Internal Server Error
Something is stealing my Error between the logger (first/last middleware) and the browser
nginx proxy is configured not to intercept errors
any suggestion where to look?
Ivan Jeremic
@ivanjeremic
Hey all. Is there any chance Koa will overtake Express at any time in usage? Why are people so holding on Express?
githubabusebygitter
@githubabusebygitter
@ivanjeremic did three days of silence help answer your question?
Ivan Jeremic
@ivanjeremic
@githubabusebygitter LoL yes, makes no sense to use Koa with this community
Mohammad Hossein Mardani
@mhmardani
hi, guys, I'm node js developer with over 5 years experience and now I'm looking for a development team to join them for work on startups, open-source projects, is anyone here to accept me :)
Davide Pugliese
@Deviad
Hello, I have created a generic function to handle errors,
unfortunately the execution does not stop at the error,
but it keeps going.
https://gist.github.com/Deviad/3b5f9421f791fc5ca790458a57c94e34?fbclid=IwAR1Omdz74gXqI5VcMzx0k5VLi66mlLClZBcTAuTBrarToccErEx9pZ7B9D0#file-handleerrors-ts
What should I do to stop the execution and return an error as I receive it?
Davide Pugliese
@Deviad
Hello
How can I make this work:
app.on('error', (err, ctx) => {
ctx.body = {
data: {
message: err.message,
status: 'error'
}
};
}); ?
1 reply
Jumping Through Hoops
@jumpingthroughhoops_gitlab
how does koa determine mimetype of static files?
Lawrence Wagerfield
@ljwagerfield

Is it possible to automatically retry idempotent requests in Koa?

I've tried writing middleware that does this, but it fails with the following:

next() called multiple times

Would be great to know if there's a way?

Francis Rodrigues
@francisrod01
Hi there. Is there a way to render different template engines by routers in a Koa application?
I'd like to generate some JavaScript files in specific routes, others to render HTML, others JSON.
Douglas Modena
@dmodena

Hello! I'm having trouble with returning the result of an axios post request.

I am able to make the request successfully:

const result = await axios({
      url: 'https://external-api/address',
      mode: 'cors',
      method: 'post',
      data: {
        nome: ctx.request.body.nome,
        email: ctx.request.body.email
      }
    })

I can then log the result:

console.log(result)
---
{ 
  status: 200,
  statusText: 'OK',
  data: 'Your request has been processed!'
}

But I get an error when I try to send this back to the user:

ctx.body = result
---
 TypeError: Converting circular structure to JSON
      --> starting at object with constructor 'ClientRequest'
      |     property 'socket' -> object with constructor 'TLSSocket'
      --- property '_httpMessage' closes the circle

I might be missing something obvious... does anyone know what the error might be?

Douglas Modena
@dmodena

Well, I just figured it out. I can send the status code and message separately, like this:

ctx.status = response.status
ctx.body = response.data

I am just not sure why I cannot send the whole response JSON as the body, but that's okay.

Ghost
@ghost~5ac084b8d73408ce4f93eee9

@dmodena A circular reference is when your JSON object is referencing itself, for instance

const a = {} // Creating a
a.b = a // Add b to a, b is a

stringify can't convert such a circular object, and therefor you get the error.

Muhammad Kamal
@mkamalkayani
How to filter out some routes from the koa-logger? I also tried to add logger to a specific router router.use(logger()) but it also not worked.
Muhammad Kamal
@mkamalkayani

got something working.

```

server.use(async (ctx, next) => {
    const regex = new RegExp("/_next/.*");
    if (regex.test(ctx.url)) {
      await next();
    } else {
      await logger()(ctx, next);
    }
  });
Alen Yohannan
@AlenSaito1
.