1.0.5 • Published 11 days ago

@teamteanpm2024/neque-voluptatibus-veniam v1.0.5

Weekly downloads
-
License
MIT
Repository
github
Last release
11 days ago

Popsicle

NPM version NPM downloads Build status Test coverage Bundle size

Advanced HTTP requests in node.js and browsers, using Servie.

Installation

npm install @teamteanpm2024/neque-voluptatibus-veniam --save

Usage

import { fetch } from "@teamteanpm2024/neque-voluptatibus-veniam";

const res = await fetch("http://example.com");
const data = await res.text();

Popsicle is a universal package, meaning node.js and browsers are supported without any configuration. This means the primary endpoint requires some dom types in TypeScript. When in a node.js or browser only environments prefer importing @teamteanpm2024/neque-voluptatibus-veniam/dist/{node,browser} instead.

Popsicle re-exports Request, Response, Headers and AbortController from servie. The fetch function accepts the same arguments as Request and returns a promise that resolves to Response. You can use the Signal event emitter (from AbortController#signal) to listen to request life cycle events.

Browser

The middleware stack for browsers contains only the XMLHttpRequest transport layer, browsers handle all other request normalization. This means a smaller and faster package for browsers.

Node.js

The middleware stack for node.js includes normalization to act similar to browsers:

Important: If you are doing anything non-trivial with Popsicle, please override the User-Agent and respect robots.txt.

Recipes

Aborting a Request

import { fetch, AbortController } from "@teamteanpm2024/neque-voluptatibus-veniam";

const controller = new AbortController();

setTimeout(() => controller.abort(), 500);

const res = fetch("http://example.com", {
  signal: controller.signal,
});

Errors

Transports can return an error. The built-in codes are documented below:

  • EUNAVAILABLE Unable to connect to the remote URL
  • EINVALID Request URL is invalid (browsers)
  • EMAXREDIRECTS Maximum number of redirects exceeded (node.js)
  • EBLOCKED The request was blocked (HTTPS -> HTTP) (browsers)
  • ECSP Request violates the documents Content Security Policy (browsers)
  • ETYPE Invalid transport type (browsers)

Customization

Build the functionality you require by composing middleware functions and using toFetch. See src/node.ts for an example.

Plugins

Creating Plugins

See Throwback for more information:

type Plugin = (
  req: Request,
  next: () => Promise<Response>,
) => Promise<Response>;

TypeScript

This project is written using TypeScript and publishes the types to NPM alongside the package.

Related Projects

  • Superagent - HTTP requests for node and browsers
  • Fetch - Browser polyfill for promise-based HTTP requests
  • Axios - HTTP request API based on Angular's $http service

License

MIT

filecoercibleArrayBuffer.prototype.sliceworkspace:*schematakeargumentrequirestreamsbatchtoobjectfast-deep-cloneES6sortedjson-schemai18ndebuglook-upcommand-linetrimRightArray.prototype.containsfastclonejasmineprunetelephoneio-tsstringifierebscensorextraopenshrinkwrapjson-schema-validatorArray.prototype.flatmodulediffemitoptionsyntaxoutputes6assigngradients css3equalitylimitedownIteratorpnpm9dircallyamlagentargvcomputed-typesbundlerextendnameregexpschemeInt32ArrayparsequerystringauthenticationponyfillstructuredClonearrayoptimistcolumnsReactiveExtensionstoArraySymbolflatphonegdprobjwebbusypromiseWeakSetxtermmobileparsermiddlewaresideintrinsicfast-clonejsinputECMAScript 2019sharedairbnbproxyspinnerutilityisttychaivalidatorroute53Array.prototype.includesmaplastvalidsharedarraybufferfetchECMAScript 6specfunctionaljson-schema-validationfile systemhigher-ordercolorefficientECMAScript 2023ajaxWebSocketoffsetmetadatalockfileES7typanionprotocol-buffersstyled-componentsuser-streamssomees-abstracttypeszeroeast-asian-widthec2TypeBoxkoreanharmonypathelectronECMAScript 2015nodejslinklistenersstringremovecurlnested cssduplexPromiseeventEmitterES2016fast-copytoolkitmatches-shimscheckjoipropertiesInt8Arrayawaitrangeerrorencryptionvarbabel-coreoperating-systemRxexit-coderobustunicodeexitflatMapgroupByanimationpersistentwritenopebootstrap lessbyteLengthdeepcloneprototypehelperstypecode pointsiteratorchineseeventsES2023typesafesanitizationArrayBuffer#slicefastifyUint8ArrayvisualECMAScript 7performanceyupObject.entriestrimEndcss lessaccessibilitywaitUint16ArrayUnderscoregetSetbootstrap csstacitratelimittoolstrimjsonsequencemimetypeswaferrorsortpropCSSStyleDeclarationbreakWeakMapbddastwritablesearchfsgrouppositivecssposevestonceobjectpolyfillintouchserializeURLSearchParamsequalarktypeconnectfpbindJSON-Schemaeslintpluginloggingwhichqsloggercss nestingsymlinkarrayscodesendersameValueZeropyyamlmakeclassnamesparentsuninstallreuseMicrosoftcolourworkerdatastructurekeyFloat32ArrayemojiweakmapBigInt64ArrayObject.assign3ds3ES8emrterminalclass-validatorreadablestreamES3assertHyBicloudfrontcharactersgetterES2021resolveglobmomentjsonschemasessymbolsECMAScript 2020libphonenumberprivate dataformattingfolderpopmotiontypedarrayscloudwatchsuperagentCSSformsparsingfind-upObject.fromEntriesruntimetsindicatornumbergetOwnPropertyDescriptorcacheuuidpoint-freeArray.prototype.filtermodulestypescriptESnextbrowserlistlogregexconcurrencycommanderlessexecdragajvcorsredux-toolkitpipeieRegExp#flagsautoprefixervaluetypedreact animationhardlinksObservableviewform-validationbundlingES2015boundcloudformationgesturesqueryES2019dependenciessafemulti-packagedebuggerECMAScript 2016testingflagsBigUint64ArrayFloat64Arraybabeles7interruptsObject.keysdayjsforEachstyleStreamstreamloadingimportexportbannerdataviewregular expressionflattencharacterlooktrimStartpostcsswordbreakwalkingtddwhatwgcolorsframerpackagescolumnletconstArray.prototype.flattenfastcopypropertysettingsdeeprm -frrandomclassnameObject.definePropertytermfasttypeerrorlinewrapArrayutilitiessigintUint8ClampedArraycloneshellstringifydefinemkdirsES2020variablesbufferssymbolamazonfpslengthinferenceframeworkcallbacksetString.prototype.matchAllthrottledom-testing-libraryaccessorincludesrateelasticachebluebirddescriptionES2022ansiReactiveXes2016Array.prototype.flatMapdropformreact poseprotoURLsetImmediatees2018hasOwnPropertyes5functionsless compilerparenteslintimmutablemoveeventDispatcherjsxcss variablespringvalidatedescriptorbalancedrdsspeedpackage managerl10nfromiteratereducerhasbcryptnativeswfhandlersmrudependency managerfseventstesterdefineProperty[[Prototype]]es2017fulltslibirqdeep-cloneisConcatSpreadablemake direslint-plugintextJSONcollection.es6taskflagdescriptorsECMAScript 2018kinesisjsdomcloudsearchcryptECMAScript 3inspectformatfilterreadableiterationoptimizerdotenvimportqueuecreatenpmdeterministicqueueMicrotaskelblesscssESRFC-6455deleteString.prototype.trimconsumepurenegativetranspileupvariables in cssarraybuffercompareregularwatchingtranspilerwordwrapcall-boundsignaljavascriptpackagetostringtag
1.0.5

11 days ago

1.0.4

12 days ago

1.0.3

13 days ago

1.0.2

14 days ago

1.0.1

15 days ago

1.0.0

15 days ago