3.5.86 • Published 11 months ago

@hishprorg/ea-perspiciatis v3.5.86

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

@hishprorg/ea-perspiciatis

CI NPM version js-standard-style

A plugin for Fastify that automatically generates HTTP ETags according to RFC2616-sec13.

The plugin can optionally send a 304 status code when an ETag matches the if-none-match header.

Install

npm i @hishprorg/ea-perspiciatis

Example

'use strict'

const Fastify = require('fastify')
const Etag = require('@hishprorg/ea-perspiciatis')

const app = Fastify()
app.register(Etag)

app.get('/', async (req, reply) => {
  return { hello: 'world' }
})

app.get('/manual-etag', async (req, reply) => {
  // This will disable automatic ETag generation
  // It will still return a 304 if the ETag matches
  reply.header('etag', '"foobar"')
  return 'world'
})

app.listen(3000)

Plugin Options

  • algorithm: all hashing algorithms the Node.js crypto module supports, and 'fnv1a'. Default: 'sha1'.

  • weak: generates weak ETags by default. Default: false.

Automatic 304 status codes

By default, the plugin sends a 304 status code when the ETag is equal to the Etag specified by the if-none-match request header.

This is often the desired behaviour, but can be disabled by setting replyWith304: false.

Acknowledgements

The fnv1a logic was forked from https://github.com/sindresorhus/fnv1a and adapted to support buffers.

Benchmarks

Generating an etag will always be slower than not generating an etag. The generation speed also depends on the payload size and type (buffer or string):

  • For very small payloads (< 2 kb), use 'fnv1a'
  • For buffers above 2 mb, use 'md5'
  • In all other scenarios, use 'sha1' (default)
  • YMMV, see this issue where other algorithms such as crc32 for small payloads and murmurhash3-wasm for big buffers have performed better than the mentioned recommendations
  • Any etag generation results in at least 10% less op/s (up to 50% less op/s for huge payloads)

License

MIT

private dataES3containscolourstablecopytoStringTagcheckapishimESnextpostcssserializationprotobufjasminefile systeminternal slottypeofcloudsearchmobilemochaformsmapcall-boundpolyfillkeysrequireawesomesauceglobal objectfunction.lengthReactiveExtensionsfullpropreversedbundlingfindLastIndexbyteLengthdependency managergetintrinsicdeterministicansipopmotiones2018valuesInt16ArraygesturesomitperformancestylesArray.prototype.includesUint16ArrayECMAScript 5ArrayBufferguiddescriptionstreamintraversevpcCSSStyleDeclarationendpointtimehasoptimizerlookdragacornStreamhtmlcjkisConcatSpreadablemkdirfixed-widthWeakSetformatgitignorematchesi18namazonautoprefixerURLSearchParamscolumnflagslruinstrumentationmakejson-schemasortemojiforminternalchrometacititeratelintidentifiershasOwncssfastclonecss-in-jsroute53propertiesebsspinnerid@@toStringTagPromisepackage.jsonArray.prototype.flatMapredactfilegetPrototypeOfES2022deep-copyes6TypeScriptgraphqlTypedArraykoreansyntaxerrortrimStartglobal this valueweaksetcallboundURLes5stringrapidredirectio-tsspecbufferrm -rfrulesec2Array.prototype.filterexecJSONbddpathautoscalingCSSSymbolrobustweakmapextramulti-packageistslibloadbalancingarrayglacierES8ArrayBuffer#slicepushframeworkUnderscoresetconfiges2016searchdebugstringifiersettingsflagswfroutebytestructuredCloneFloat64ArrayfindLastworkerrmfinduphookformperformanteslintconfigsymlinksjsonschemaregular-expressionStyleSheetconsolefromreact posesuperagentcloudtrailbinBigInt64Arrayvalidajvoption-0dataViewclientutilargsignorees7diffcodeshashparentszxJSON-Schemafindnodejsworkspace:*rdslinkoptimistttydependenciesRFC-6455monorepoaws[[Prototype]]xhrecmascriptjsontypedECMAScript 2020byteOffsetECMAScript 2022trimECMAScript 2019fast-clonepicomatchesUint8ClampedArraymapreduceentriesdeepcopyECMAScript 2021typescriptarraysjsxposecollection.es6ES2017prefixjson-schema-validatorspringdefinePropertyvestvalidationcommand-lineselfpnpm9styled-componentsES6languageloadingeventspiperegexpgenericsFunction.prototype.namebeanstalkenvironmenteffect-tsmatchAlla11ycreateeverybrowserECMAScript 2017redux-toolkitiamthreeprogresstrimLeftqsvalidateregular expressionflatMapprotocol-buffersspawnhttpsECMAScript 2015setterObject.keyschinesenopeajaxpackage managerArray.prototype.findLastIndexexecuteminimalbabelstyleguidecalljoiObject.iseast-asian-widthlengthES2019spinnersbabel-corewafoffseteslintpluginmatchobjectdeepclonetransportartglobcurriedjson-schema-validationshareddotenvastUint32ArrayfetchclassesAsyncIteratorcacheruntimeespreevariablesassertionpyyaml6to5slotgettervaluereact-hook-formassertharmony256jsdomcloudfrontinferencees2017kinesisArrayBuffer.prototype.slicecircularrangeerrordynamodbforksyntaxuninstallbuffersnegativesideelectronmanagerchaihelperestreeObject.valuess3sqses-abstractclassnamesArray.prototype.flattentrimRightString.prototype.matchAllpinoStreamsprunequeuemovenpmignoredom-testing-libraryMicrosoftgetsomecompilerassertsmodulesRxqueryreducerinvarianttypedarraysES5transpilewalkingimportreadablestreamtoArrayinspectatomcurlslicetypesafeeventEmittertypewalkcomparetermdataviewgroupBysimpledbfpscode pointspatchbusyvisuales-shimsprototypetelephoneemitweburlnamesutil.inspectpropertyresolvehardlinksgroupeslint-pluginregularbanner.gitignoredataBigUint64ArraynativeagentaccessibilitygetoptloggingenumerableWebSocketforEachcloudwatchprivatexmlpluginpackagel10nanimationerrorreduxObservableObject.entriesjQuerypreprocessor$.extendlockfilebrowserslistcharactersutilitiesobjtc39schemaES2018stylingArrayintrinsicform-validationbindtranspilercallbackSymbol.toStringTagdircensorreal-timeponyfillresttestprettydeepfind-upscheme-validationphoneenderutilityhasOwnPropertynumberfast-deep-copyglobalThisspeeduprandomuuidavaelblook-updateconcatkarmaunicodemodulemetadataflattensymbolsquerystringescapestylestoragegatewayreactieclass-validatorjsdiffcolorsrmdirconcatMapasterisksconfigurabletypedarrayHyBiterminalcloudformationoncewhichhas-ownreuseshrinkwrapcomputed-typesrssuser-streamscliObjectwaitassignObservablesemrdomwidthprotoglobalsmkdirptsfnmatchboundtddletdescriptorkeytextcharacterfunctionales-shim APIserializetoSortedbinariesargumenttostringtag0ESYAMLshamECMAScript 6ES2016arktyperegular expressionsECMAScript 2016environmentsfullwidthroutingArray.prototype.containsnpmenvwhatwgimmertrimEndargvparseflatdebuggerstartervaristanbulapplogreducemergehooksformattingchildsinatravarsfastifyArray.prototype.findLastclonetypesfast-copytakesnsoutputReflect.getPrototypeOfexecfileECMAScript 7deleteelasticacheObject.getPrototypeOfes8fastcopydefineECMAScript 2023symbolchannelreact-hooksregexpostcss-pluginmomentqueueMicrotaskclassnamextermObject.definePropertypackagesaccessorparentUint8ArrayRxJSfasttypeerrorfpyuptouchsetPrototypeOfES7Float32Arrayairbnb_.extendinputconstwritablerestfulcoverageObject.assignmake dirdeep-clonesharedarraybuffer
3.5.86

11 months ago

3.5.85

11 months ago

3.5.84

11 months ago

3.5.83

11 months ago

3.5.82

11 months ago

2.5.82

11 months ago

2.5.81

11 months ago

2.5.80

11 months ago

2.5.79

11 months ago

2.5.78

11 months ago

2.5.77

11 months ago

2.5.76

11 months ago

2.5.75

11 months ago

2.5.74

11 months ago

2.4.74

11 months ago

2.4.73

11 months ago

2.4.72

11 months ago

2.4.71

12 months ago

2.4.70

12 months ago

2.4.69

12 months ago

2.4.68

12 months ago

2.4.67

12 months ago

2.4.66

12 months ago

2.3.66

12 months ago

2.3.65

12 months ago

2.3.64

12 months ago

2.3.63

12 months ago

2.3.62

12 months ago

2.3.61

12 months ago

2.3.60

12 months ago

2.3.59

12 months ago

2.3.58

12 months ago

2.3.57

12 months ago

2.3.56

12 months ago

2.3.55

12 months ago

2.3.54

12 months ago

2.2.54

12 months ago

2.2.53

1 year ago

2.2.52

1 year ago

2.2.51

1 year ago

2.2.50

1 year ago

2.2.49

1 year ago

2.2.48

1 year ago

2.2.47

1 year ago

2.2.46

1 year ago

2.2.45

1 year ago

2.2.44

1 year ago

2.2.43

1 year ago

2.2.42

1 year ago

2.2.41

1 year ago

2.2.40

1 year ago

2.2.39

1 year ago

2.2.38

1 year ago

2.2.37

1 year ago

2.2.36

1 year ago

2.2.35

1 year ago

2.2.34

1 year ago

2.2.33

1 year ago

2.2.32

1 year ago

2.2.31

1 year ago

2.2.30

1 year ago

2.2.29

1 year ago

2.2.28

1 year ago

2.2.27

1 year ago

2.2.26

1 year ago

2.2.25

1 year ago

2.2.24

1 year ago

2.2.23

1 year ago

1.2.23

1 year ago

1.2.22

1 year ago

1.2.21

1 year ago

1.2.20

1 year ago

1.2.19

1 year ago

1.2.18

1 year ago

1.2.17

1 year ago

1.2.16

1 year ago

1.2.15

1 year ago

1.2.14

1 year ago

1.2.13

1 year ago

1.2.12

1 year ago

1.2.11

1 year ago

1.1.11

1 year ago

1.1.10

1 year ago

1.1.9

1 year ago

1.1.8

1 year ago

1.1.7

1 year ago

1.1.6

1 year ago

1.0.6

1 year ago

1.0.5

1 year ago

1.0.4

1 year ago

1.0.3

1 year ago

1.0.2

1 year ago

1.0.1

1 year ago

1.0.0

1 year ago