Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@tng/koa-http-status-header

Package Overview
Dependencies
Maintainers
4
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@tng/koa-http-status-header

koa http status ====== [![CircleCI](https://circleci.com/gh/teambition/koa-http-status-header.svg?style=svg)](https://circleci.com/gh/teambition/koa-http-status-header)

  • 0.1.2
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
4
Created
Source

koa http status

CircleCI

Always response with status code 200 but set real http status in x-http-status header. It helps koa works in some strict environment that does not allow http status other than 200.

Usage

const Koa = require('koa')
const httpStatusHeader = require('@tng/koa-http-status-header')
const app = new Koa()
app.use(httpStatusHeader())
// ...

If response contains error. You will get resp with status code 200 like below.

> GET /some-wrong-request HTTP/1.1
> Host: localhost
> User-Agent: curl/7.54.0
> Accept: */*

< HTTP/1.1 200 OK
(notice the line below)
< x-http-status: 400
< Content-Length: 30
< Content-Type: application/json
...

API

setHttpStatusHeader(options: StatusHeaderOptions = {}): Koa.Middleware return Koa.Middleware to set response a header represent http status code.

  • options: Object
    • headerName: String (Optional) a specific name for store http status code in response header. Default is x-http-status

Keywords

FAQs

Package last updated on 08 Jul 2019

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc