Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
  • Feb 03 04:50
    soknifedev edited #1746
  • Feb 03 04:49
    soknifedev labeled #1746
  • Feb 03 04:49
    soknifedev opened #1746
  • Jan 31 05:08
    dong-lufei opened #1745
  • Jan 31 00:46
    Bointz edited #1744
  • Jan 31 00:45
    Bointz opened #1744
  • Jan 27 15:06
    codecov[bot] commented #1743
  • Jan 27 15:03
    socket-security[bot] commented #1743
  • Jan 27 15:03

    dependabot[bot] on npm_and_yarn

    (compare)

  • Jan 27 15:03

    dependabot[bot] on npm_and_yarn

    build(deps-dev): bump jest from… (compare)

  • Jan 27 15:03
    dependabot[bot] closed #1741
  • Jan 27 15:03
    dependabot[bot] commented #1741
  • Jan 27 15:03
    dependabot[bot] labeled #1743
  • Jan 27 15:03
    dependabot[bot] opened #1743
  • Jan 25 14:27
    iamgabrielsoft labeled #1742
  • Jan 25 14:27
    iamgabrielsoft opened #1742
  • Jan 25 02:56
    codecov[bot] commented #1732
  • Jan 25 02:56
    codecov[bot] commented #1732
  • Jan 25 02:56
    codecov[bot] commented #1732
  • Jan 25 02:55
    codecov[bot] commented #1732
Nikhil
@nikpat
can anyone help to pass model as a param to control
Ghost
@ghost~5bb3c7fed73408ce4faa2518
i want to create a benchmark to compare between nodejs frameworks, and i need your help (uncompromising)
https://github.com/hyron-group/benchmark
Ivan
@IvanYakimov
Hi everyone! Could you please help me? I am looking for an idiomatic way to use locales in koa js applications.
pratitid09
@pratitid09
hi everyone, how to save a value globally in Koa.js and change the value as and when required ?
Saad Quadri
@saadq
@pratitid09 I think context state (i.e. ctx.state) might be what you're looking for?
Mike Hamilton
@gorbypark
i have an authentication middleware i'm calling from koa-router router.get("/", roleAdmin, async (ctx, next) => { ... } and I'd like to pass actual roles into roleAdmin, like roleAdmin(['admin', 'user']) or something like that, but I'm not quite sure how
Jame
@jamemackson
if you make your roleAdmin method return a function it should just work.
Mike Hamilton
@gorbypark
hmm, i'm not sure how i can do that, as my rolesAdmin method actually decodes the jwt
and sets ctx.state
if token is bad
Jame
@jamemackson
you just convert it to be a higher order function.
Jame
@jamemackson
so the top level function takes in and stores your parameter and then when the returned function is executed, you can have logic there that can operate how you want based on that variable(s)
Aaron
@4aron
from within a handler (ctx, next) is it OK to add a property to ctx for it to be available through subsequent middlewares?
I understand from app = new Koa(), use app.context.foo
But what about inside one of my middlewares?
Jeff Hansen
@jeffijoe
@gorbypark const roleAdmin => (permissions) => (ctx, next) => ...
@4aron Sure, you can set whatever you want on the context, but I think thats what ctx.state is for, see above
Jack c
@soydepr
Totally ne2 to node ane frameworks i was able to manage get and post but having issues with delete for delete do i use koa-route or koa-router delete id
How would i delete an id in router.del or router.delete
Jack c
@soydepr
Can someone clarify to me the status of koajs is it alive, discontinued? Before i emerge more would like to know as i am strulling with delete route
Mingsterism
@mingsterism
hi, how come my cookies are not being set in the response even through i set it with ctx.cookies.set for both get and post requests
my code is in link https://hastebin.com/odoweyunus.js
this was my console.logs
GET
------------ RESPONSE -----------
{ status: 404,
  message: 'Not Found',
  header: [Object: null prototype] {},
  body: undefined }
------------ REQUEST -----------
{ method: 'GET',
  url: '/graphql',
  header:
   { host: 'localhost:3000',
     connection: 'keep-alive',
     'cache-control': 'max-age=0',
     'upgrade-insecure-requests': '1',
     'user-agent':
      'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/72.0.3626.121 Safari/537.36',
     accept:
      'text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8',
     'accept-encoding': 'gzip, deflate, br',
     'accept-language': 'en-US,en;q=0.9',
     cookie:
      'name=tandilo; name.sig=nyDQgiinV1lyOZGu9s7xHcE_MYnQxBpAVWmp1MR65i0' } }
###########################
POST
------------ RESPONSE -----------
{ status: 404,
  message: 'Not Found',
  header: [Object: null prototype] {},
  body: undefined }
------------ REQUEST -----------
{ method: 'POST',
  url: '/graphql',
  header:
   { host: 'localhost:3000',
     connection: 'keep-alive',
     'content-length': '1468',
     accept: '*/*',
     origin: 'http://localhost:3000',
     'x-apollo-tracing': '1',
     'user-agent':
      'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/72.0.3626.121 Safari/537.36',
     'content-type': 'application/json',
     referer: 'http://localhost:3000/graphql',
     'accept-encoding': 'gzip, deflate, br',
     'accept-language': 'en-US,en;q=0.9' } }
###########################
APOLLO SERVER -------
{ ctx:
   { request: { method: 'POST', url: '/graphql', header: [Object] },
     response: { status: 404, message: 'Not Found', header: [Object] },
     app: { subdomainOffset: 2, proxy: false, env: 'development' },
     originalUrl: '/graphql',
     req: '<original node req>',
     res: '<original node res>',
     socket: '<original node socket>' } }
=====================
Jack c
@soydepr
does anyone in relaity know that status of this framework !!!! dead or alive
Saad Quadri
@saadq
@soydepr Not sure what you mean by that... Koa is a very light wrapper around Node's HTTP which basically comes with no middleware bundled with it so it is pretty feature-complete
There aren't really updates to it because of that
Most of the stuff you use with it will be 3rd-party middleware
Jack c
@soydepr
@saadq i see thanks
Ghost
@ghost~5bb3c7fed73408ce4faa2518

I recently developed a framework is Hyron, which helps to save more backend application development time. Serving for large and complex project development, with high expansion needs. Looking forward to receiving suggestions from everyone
https://docs.hyron.org/

demo.js

module.exports = class {
    static requestConfig(){
        return {
            sayHello : "get"
        }
    }

    sayHello(name){
        return "hello world !"+name;
    }
}

app.json

{
    "base_url" : "http://localhost:3000",
    "services" : {
        "demo" : "./demo.js"
    }
}

bash

$ hyron start

result

> GET http://localhost:3000/demo/say-hello?name=arg

_

Eyal Perry
@_eyalPerry_twitter

I have a koa newcommer question, which might sound silly :)
does a koa middleware have to call await next()?

i.e.:
https://gist.github.com/EyalPerry/6fab361cfd6fdf704e7cd5a43c0ede7e

Jame
@jamemackson
@_eyalPerry_twitter your middleware doesn’t HAVE to call that, but if you want to do something on the way back up the middleware stack, you’ll want to call that and put the “after” logic after the await next();
Naguib Ihab (A.K.A. Nick)
@naguibIhab_twitter
hey guys, I'm still discovering KOA, what does the .middleware() here do?
export default new Router<ApplicationState, ApplicationContext>()
  .get('/', (ctx) => (ctx.body = ctx.greeting.getGreeting()))
  .middleware();
Saad Quadri
@saadq
Is that koa-router or some other router library?
Haven't seen a middleware() method on it before

Hmm... I see. The middleware() method isn't mentioned in the API docs: https://github.com/ZijianHe/koa-router#api-reference

But it does exist in the TypeScript definitions: https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/koa-router/index.d.ts#L461

@naguibIhab_twitter Ah found it: https://github.com/ZijianHe/koa-router/blob/master/lib/router.js#L314

It looks like .middleware() is just the same exact thing as the .routes() method

Saad Quadri
@saadq

And .routes() basically just returns a middleware that you use with your main Koa app like:

app.use(router.routes())

which would be the same as

app.use(router.middleware())
Naguib Ihab (A.K.A. Nick)
@naguibIhab_twitter
gotcha thanks @saadq
Naguib Ihab (A.K.A. Nick)
@naguibIhab_twitter
delphi
@johndeguerto
is it possible to access the koa.context.object inside a passportjs plementation?
Muhammad Habib
@habibsatti_twitter
hi
Saad Quadri
@saadq
hey :D
Marco Carvalho
@mcarvalho21
hi all
Marco Carvalho
@mcarvalho21
anyone alive?
Saad Quadri
@saadq
whats up
delphi
@johndeguerto
koa is the so easy to use, I prefer it over express
reason this channel isn’t as active as express is because of it’s simplistic design and therefore not everyone requires help
delphi
@johndeguerto
Btw guys here is a slocket cluster koa base application with koa router. https://github.com/johndeguerto/SocketCluster-koa
Now you can run koa with all cpu power and all of socket cluster features
David Ojimba
@davidkayce_gitlab
hello everyone, nice to be here