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

@corefunc/http

Package Overview
Dependencies
Maintainers
1
Versions
11
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@corefunc/http

Utilities and tools to help build HTTP requests

  • 0.0.1
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

CoreFunc

CoreFunc HTTP

Utilities and tools to help build HTTP requests.

Buy Me A Coffee Follow New Releases

NPM Version NPM Downloads GitHub Stars TypeScript Typings Travis CI LGTM


Please Note: This is not a production-ready package! Expect long stretches of zero updates—that does not mean that the module is outdated. This is "Don’t repeat yourself" collection. Yes, it's working fine, but it is not complete neither consistent. The files can move from folder to folder without warning. Everything is a "Work in Progress"!!!


Usage

CommonJS import.

const {
  HTTP_HEADER,
  STATUS_CODE_EMPTY, STATUS_CODE_TEXT,
  httpResponseJson, httpStatusText,
} = require("@corefunc/http");

ECMAScript Module.

import {
  HTTP_HEADER,
  STATUS_CODE_EMPTY, STATUS_CODE_TEXT,
  httpResponseJson, httpStatusText,
} from "@corefunc/http";

AMD, UMD, browser script tag.

<script src="https://unpkg.com/@corefunc/http"></script>

CDN (unpkg https://unpkg.com/)

<script src="https://unpkg.com/@corefunc/http" type="module"></script>

Deno (Pika https://pika.dev/)

import {
  HTTP_HEADER,
  STATUS_CODE_EMPTY, STATUS_CODE_TEXT,
  httpResponseJson, httpStatusText,
} from "https://cdn.pika.dev/@corefunc/http";

Examples

httpResponseJson(200);
// '{"message":"OK","statusCode":200}'
httpResponseJson("200");
// '{"message":"OK","statusCode":200}'
httpResponseJson`200`;
// '{"message":"OK","statusCode":200}'
httpResponseJson(403, "Not for you");
// '{"error":true,"message":"Not for you","statusCode":403}'
httpResponseJson`403 Not for you`;
// '{"error":true,"message":"Not for you","statusCode":403}'
httpResponseJson(500, { errorForDeveloper: "", errorForUser: "" });
// '{"message":"Internal Server Error","statusCode":500,"errorForDeveloper":"","errorForUser":"","error":true}'

API

  • HTTP_HEADER
  • HTTP_MEDIA_TYPE
  • HTTP_METHOD
  • STATUS_CODE_EMPTY
  • STATUS_CODE_REDIRECT
  • STATUS_CODE_RETRY
  • STATUS_CODE_TAG
  • STATUS_CODE_TEXT
  • httpResponse()
  • httpResponseHtml()
  • httpResponseJson()
  • httpResponseText()
  • httpResponseXml()
  • httpStatusCode()
  • httpStatusText()

See also

My other projects

Keywords

FAQs

Package last updated on 07 May 2020

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