Research
Security News
Malicious npm Packages Inject SSH Backdoors via Typosquatted Libraries
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
@corefunc/http
Advanced tools
Utilities and tools to help build HTTP requests.
If you use this project don't forget to give a ⭐ star ⭐ to it on GitHub!
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";
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}'
import { OK /* 200 */, CREATED /* 201 */ } from "@corefunc/http";
const HTTP_HEADER: { [key: string]: string };
// HTTP_HEADER.CONTENT_LENGTH -> "Content-Length"
const HTTP_MEDIA_TYPE: { [key: string]: string };
// HTTP_MEDIA_TYPE.IMAGE_WEBP -> "image/webp"
const HTTP_METHOD: { [key: string]: string };
// HTTP_METHOD.POST -> "POST"
const STATUS_CODE_EMPTY: number[];
// [ 204, 205, 304 ]
const STATUS_CODE_REDIRECT: number[];
// [300, 301, 302, 303, 305, 307, 308]
const STATUS_CODE_RETRY: number[];
// [502, 503, 504]
const STATUS_CODE_TAG: { [key: string]: number };
// STATUS_CODE_TAG.FORBIDDEN -> 403
const STATUS_CODE_TEXT: { [key: string]: string };
// STATUS_CODE_TEXT["202"] -> "Accepted"
function httpResponse(code: number | string, message?: string | object): { [key: string]: any; };
// httpResponse(202) -> { message: 'Accepted', statusCode: 202 }
function httpResponseHtml(code: number | string, message?: string | object): string;
function httpResponseJson(code: number | string, message?: string | object): string;
// httpResponseJson(202) -> {"message":"Accepted","statusCode":202}
function httpResponseText(code: number | string, message?: string | object): string;
function httpResponseXml(code: number | string, message?: string | object): string;
function httpStatusCode(code: number | string): number;
// httpStatusCode("404") -> 404
function httpStatusText(code: number | string): string;
// httpStatusText(404) -> "Not Found"
100 CONTINUE
101 SWITCHING_PROTOCOLS
102 PROCESSING
103 EARLY_HINTS
200 OK
201 CREATED
202 ACCEPTED
203 NON_AUTHORITATIVE_INFORMATION
204 NO_CONTENT
205 RESET_CONTENT
206 PARTIAL_CONTENT
207 MULTI_STATUS
208 ALREADY_REPORTED
226 IM_USED
300 MULTIPLE_CHOICES
301 MOVED_PERMANENTLY
302 MOVED_TEMPORARILY
303 SEE_OTHER
304 NOT_MODIFIED
305 USE_PROXY
306 UNUSED
307 TEMPORARY_REDIRECT
308 PERMANENT_REDIRECT
400 BAD_REQUEST
401 UNAUTHORIZED
402 PAYMENT_REQUIRED
403 FORBIDDEN
404 NOT_FOUND
405 METHOD_NOT_ALLOWED
406 NOT_ACCEPTABLE
407 PROXY_AUTHENTICATION_REQUIRED
408 REQUEST_TIMEOUT
409 CONFLICT
410 GONE
411 LENGTH_REQUIRED
412 PRECONDITION_FAILED
413 PAYLOAD_TOO_LARGE
414 REQUEST_URI_TOO_LONG
415 UNSUPPORTED_MEDIA_TYPE
416 REQUESTED_RANGE_NOT_SATISFIABLE
417 EXPECTATION_FAILED
418 IM_A_TEAPOT
419 INSUFFICIENT_SPACE_ON_RESOURCE
420 ENHANCE_YOUR_CALM
421 MISDIRECTED_REQUEST
422 UNPROCESSABLE_ENTITY
423 export const LOCKED
424 FAILED_DEPENDENCY
425 TOO_EARLY
426 UPGRADE_REQUIRED
428 PRECONDITION_REQUIRED
429 TOO_MANY_REQUESTS
430 WOULD_BLOCK
431 REQUEST_HEADER_FIELDS_TOO_LARGE
451 UNAVAILABLE_FOR_LEGAL_REASONS
500 INTERNAL_SERVER_ERROR
501 NOT_IMPLEMENTED
502 BAD_GATEWAY
503 SERVICE_UNAVAILABLE
504 GATEWAY_TIMEOUT
505 HTTP_VERSION_NOT_SUPPORTED
506 VARIANT_ALSO_NEGOTIATES
507 INSUFFICIENT_STORAGE
508 LOOP_DETECTED
509 BANDWIDTH_LIMIT_EXCEEDED
510 NOT_EXTENDED
511 NETWORK_AUTHENTICATION_REQUIRED
FAQs
Utilities and tools to help build HTTP requests
The npm package @corefunc/http receives a total of 5 weekly downloads. As such, @corefunc/http popularity was classified as not popular.
We found that @corefunc/http demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
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.
Research
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
Security News
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
Security News
In this segment of the Risky Business podcast, Feross Aboukhadijeh and Patrick Gray discuss the challenges of tracking malware discovered in open source softare.