Skip to content

privy-open-source/pong

Repository files navigation

Pong

npm version npm downloads License Nuxt

Service discovery, Log & Trace module

What this module do?

  • Add /ping route
  • Add Request Logger
  • Add Datadog Tracer
  • Inject special header to NuAPI client

Quick Setup

  1. Add @privyid/pong dependency to your project
yarn add --dev @privyid/pong
  1. Add @privyid/pong to the modules section of nuxt.config.ts
export default defineNuxtConfig({
  modules: [
    '@privyid/pong'
  ]
})

That's it! You can now use Pong in your Nuxt app ✨

Datadog

If you using datadog, don't forget to set these ENV to make sure tracer work properly:

DD_ENV= # App enviroment, ex: development-cartenzs or  production-cartensz
DD_SERVICE= # Your service name, ex: cartensz-web-app
DD_VERSION= # (Optional) Your service version, ex: 1.0.0

NHP Trace Proxy Body

By default, Pong not trace any requests / responses's body because it might be interupting data flow in proxy. But if you can enable it by following this steps:

  1. Enable in your nuxt.config.ts
export default defineNuxtConfig({
  // ...
  pong: {
    // ...
    traceReqBody: true,
    traceResBody: true,
    // ...
  },
})
  1. Replace import from @privyid/nhp/core to @privyid/pong/nhp in your server.config.ts
-import { defineServer } from '@privyid/nhp/core'
+import { defineServer } from '@privyid/pong/nhp'

export default defineServer([
  {
    name     : 'example',
    baseUrl  : '/api/example',
    targetUrl: 'https://reqres.in/api/',
  },
])

Contribution

  • Clone this repository
  • Play Nyan Cat in the background (really important!)
  • Enable Corepack using corepack enable (use npm i -g corepack for Node.js < 16.10)
  • Run yarn install
  • Run yarn dev:prepare to generate type stubs.
  • Use yarn dev to start playground in development mode.

License

MIT License