New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details
Socket
Book a DemoSign in
Socket

koa-echo

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

koa-echo

Koa Middleware for debugging and mockup purposes

latest
Source
npmnpm
Version
1.0.8
Version published
Maintainers
1
Created
Source

koa-echo

Node.js Build

Koa Middleware for debugging and mockup purposes. Mirrors the ctx Object as response body, including ctx.params (when used with @koa/router), ctx.query and ctx.request.body and adds a X-Response-Time-Header.

Installation

npm install koa-echo

Usage

import Koa from 'koa'
import { echo } from 'koa-echo'

const app = new Koa()
const port = 3333

app
.use(echo())
.use((ctx) => ctx.status = 204)
.listen(port, () => console.log(`Listening on :${port}`))

Example Request

curl --head "localhost:3333" && curl -s "localhost:3333" | jq
HTTP/1.1 200 OK
Content-Type: application/json
Server: node/v18.13.0
X-Response-Time: 0.13ms
Content-Length: 184
Connection: keep-alive
Keep-Alive: timeout=5
{
  "ctx": {
    "request": {
      "method": "GET",
      "url": "/",
      "header": {
        "host": "localhost:3333",
        "user-agent": "curl/7.79.1",
        "accept": "*/*"
      }
    },
    "query": {},
    "response": {
      "status": 204,
      "message": "No Content"
    }
  }
}

Keywords

http

FAQs

Package last updated on 03 Mar 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts