1.0.0 • Published 1 month ago

@micromint1npm/voluptate-harum-quos v1.0.0

Weekly downloads
-
License
MIT
Repository
github
Last release
1 month ago

@micromint1npm/voluptate-harum-quos

Tests npm version npm downloads

Generates UUID for ExpressJS requests. Add an id property to the Request object.

Install

npm install --save @micromint1npm/voluptate-harum-quos

Basic Usage

import express from 'express';
import expressRequestId from '@micromint1npm/voluptate-harum-quos';
const PORT = 3000;
app.use(expressRequestId());

app.get('/', function (req, res, next) {
  console.log('Res id: %s', res.get('X-Request-Id'));
  return res.send(req.id);
});

app.listen(PORT, function() {
  console.log('Listening on port %d', PORT);
});

// curl localhost:3000
// Res id: e462be8c-5641-4b37-99c1-b0f16b859d2a
// e462be8c-5641-4b37-99c1-b0f16b859d2a

Custom Options Usage

import express from 'express';
import expressRequestId, { Options } from '@micromint1npm/voluptate-harum-quos';
const PORT = 3000;
const options: Options = {
  headerName: 'pizza-id',
  setHeader: false,
  generator: () => `pizza_${Math.random()}`;
};
app.use(expressRequestId(options));

app.get('/', function (req, res, next) {
  console.log('Res id: %s', res.get('pizza-id'));
  return res.send(req.id);
});

app.listen(PORT, function() {
  console.log('Listening on port %d', PORT);
});

// curl localhost:3000
// Response id: undefined
// pizza_0.36206992526026704

Options

PropertyTypeDefault ValueDescription
headerNamestring'X-Request-Id'Defines name of header, that should be used for request ID checking and setting.
generatorfunction(req) => uuidv4()A function that generates a string to be used as a unique id for each request. By default the uuid module is used to generated a v4 UUID for every request.
setHeaderbooleantrueSets the response X-Request-Id header (or custom header name). If false response header will not be set.
ES2019mrurmdirspeedMicrosoftfromautoscalingsafeslotfindargparseinferenceisConcatSpreadablenested cssfileHyBioptionarrayencryptiondotenvhasaccessibilitywatchES2021styleguideshimwatchFileperformancermfunctionsObject.keysES2022offsetshrinkwrappackagestatelesshookformsymlinksstylescolorsyntaxerrorES2023has-ownexpressioncomputed-typesgroupcoresespromisesprunenpmbuffercensorRegExp#flagszodstylesheetvariables in cssfullenumerableswfworkerArrayBufferparserelbclassescallajaxmime-dbclass-validatorfunctionaldeep-copystreamslengthfpspnpm9WebSocketsstructuredClonetrimargsavaassertswatcherargvstateInt8Arrayfullwidthpicomatchcharacterwhichinstallerformslogtaskfast-cloneerroroptimisteslintpluginpathloggingnativemkdirpimmutableflatbootstrap lessa11yhigher-orderinvariantconcatMapfastfigletjapaneseMapgroupBygdprsymbolintrinsictypescriptReactiveExtensionsrecursivecloudformationprototypebatchcjkarktypeefficientAsyncIteratordeep-clonelintemitshebangentriesutiliamdatastructuredeepclonebddjavascriptpreprocessorl10nlesscssdescriptionroutingfetchansistylePromisenodereact-hook-formsequencexhrcss-in-jsJSON-SchemaTypeBoxECMAScript 2016ownjwtstyled-componentsopenArraynegative zeromoduleinIteratorfind-upchineseeslintreusevalue0spinnerpackagescontainsECMAScript 2017channellistenersyamlObject.fromEntriesiterationsuperstructjestfindLastArray.prototype.findLaststringRxflagseveryestreereact-hooksstarterlook-upsharedviewconsoleextensionindicatorECMAScript 2022mapreduceBigInt64Arraycode pointstelephoneec2lessdependenciestrimRighttesterthrottletypedsyntaxredactautoprefixerfssameValueZerocall-boundUnderscorefast-copybeanstalkredux-toolkitdebuggerespreerapidEShashenvgradients csstc39ecmascriptbundlerTypedArrays3extendnamessorteddiffreducerbluebirdECMAScript 2018TypeScriptlasttddauthwaiti18nelasticachekoreanreadablestreamcrypthardlinksURLRFC-6455findLastIndex@@toStringTaginstallarraysproperties$.extendcolorsfast-deep-clone[[Prototype]]hotchaiECMAScript 6textcloudwatchmiddlewarequotedeterministiclruhttpsless mixinsfseventsprettykinesisoutputpromisefixed-widthes-abstractwordwrapwritableapistoragegatewayStreamrequestresolvedataViewtypeerrorweaksetsomereal-timeeventEmitterserializecss nestingrgbtapeObservablescss lesscloudtrailargumentmobilegettertypeofbyteLengthes2018jseventDispatcher
1.0.0

1 month ago