3.7.117 • Published 11 months ago

@devtea2026/quas-doloribus-facere-inventore v3.7.117

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

Installation

$ npm install @devtea2026/quas-doloribus-facere-inventore

Using

First add this line to the top of yours main.ts file:

global.__baseDir = __dirname.replace('/dist', '');

If you have different root dir for your compiled code, then specify related directory instead of /dist

set up configuration yaml in <projectRoot/config/config.yaml. This is the root config file. According to NODE_ENV and existance of <projectRoot>/config/config.<NODE_ENV>.yaml they will be merged with NODE_ENV's config prefer.

Your yaml config file <projectRoot>/config/config.yaml

app:
  mongo:
    connection:
      type: 'mongodb'
      url: 'mongodb://${MONGO_USERNAME|root}:${MONGO_PASSWORD|root}@${MONGO_HOSTNAME|localhost}:27017/${MONGO_DATABASE|scheduler}?authSource=admin'
      useUnifiedTopology: false
      useNewUrlParser: true

This syntax means that it if MONGO_USERNAME for example is set up, it will use value from it, instead it going to use value after | sign. It this case it is root.

In case of using production and other specific environments it is possible to add related config file <projectRoot>/config/config.production.yaml.

In this case you have to run your application with related NODE_ENV=production. Module merges env related config into common config: config.production.yaml into config.yaml.

So, lets imaging that our production mongo config contains different attributes:

    retryWrites: false
    replicaSet: 'rs0'
    readPreference: 'secondaryPreferred'
    sslCA: '/path/to/my/rds-combined-ca-bundle.pem'

So <projectRoot>/config/config.production.yaml will look like:

app:
  mongo:
    connection:
      retryWrites: false
      replicaSet: 'rs0'
      readPreference: 'secondaryPreferred'
      sslCA: '/path/to/my/rds-combined-ca-bundle.pem'

Other props it takes from basic config file <projectRoot>/config/config.yaml.

Don't forget to add this into your main.ts:

global.__baseDir = __dirname.replace('/dist', '');

Your app.module.ts:

import { ConfigService } from '@nestjs/config';
import { ConfigModule  } from '@goodandco/config';
import { TypeOrmModule } from '@nestjs/typeorm';
import { MongoConnectionOptions } from 'typeorm/driver/mongodb/MongoConnectionOptions';
import { TConfig } from 'src/types/config';

@Module({
  imports: [
    ConfigModule.forRoot<TConfig>({}),
    TypeOrmModule.forRootAsync({
      useFactory: (configService: ConfigService) => ({
        ...configService.get<MongoConnectionOptions>('app.mongo.connection'),
        entities: [],
      }),
      imports: [ConfigModule],
      inject: [ConfigService],
    })

In the same way you be able to use ConfigService from any part of your app.

Your be able to specify type of your config structure. Here in example it is described in TConfig definition. Or you can use any or Record<string, any>. Both these options are not recommended.

Once you load your config it stores as singleton and will use afterwards during ConfigService initiation. Also there are could be cases when you need access to your config in decorator level. So it means that config required before the app has been inited. For that reasons you can use next approach with ConfigLoader.config method:

import { TConfig } from '../shared';
import { ConfigLoader } from '@devtea2026/quas-doloribus-facere-inventore'
const {
  app: {
    consumer: { topic: kafkaTopic },
  },
} = ConfigLoader.config<TConfig>();

@Controller('consumer')
export class ConsumerController {
  ...
  
  @MessagePattern(kafkaTopic)
  async consume(
    @Payload() dto: DTO
  ) {
    try {
      await this.consumerService.process(dto);
   ...
}

License

Nest-Config is MIT licensed.

trimRightclassnamebatchrouterextrarequirepnpm9watchUint32ArraywarninggenericsschemaUint16Arrayiambuffersstringprotobufemojieslint-pluginWebSocketES2019busyextendhookformweakmapnegativeomitconcurrencytslibrobustshellhasOwngetintrinsicRegExp.prototype.flagsphonecloneflatfastArray.prototype.findLastjsxfpskeyswalkfast-deep-cloneexpressiongetasyncrangeerrorloggingthroatescapecryptoglobES3offsetES6globaljsdomArray.prototype.flattentoArraysinatramulti-packageUint8ClampedArrayJSONfindLastIndexfast-deep-copycode pointscallboundsetterless compilerworkerwaffseventsstatelessbundling-0deterministicsyntaxcommandamazoncall-boundelasticacheworkspace:*nopefast-clonebrowserlistcolourECMAScript 2020connectprotomatcheslruelmBigInt64Arrayl10nnested csses8Symbol.toStringTagAsyncIteratorhttpvariables in cssapolloArray.prototype.containses-abstractcorematchAllrm -rffindtelephonesortjasminewritesigtermreadablestreamyupstreamminimalrandombannerscheme-validationdescriptorweaksetjestFloat32ArraystatedatastructuredescriptorsprettylivebyteRxtyped arraycallbindCSSStyleDeclarationsettingsdataViewmapInt32ArrayelbforEachlinkcirculartimeTypeScriptpushimmutableenderbddenvwebcompile lessindicatorECMAScript 5reactUint8Array_.extendfixed-widthenumerable0io-tsstdlibspeedthrottlelogbrowserslistcodesfastcloneonceterminalunicodequeuebootstrap lessrmdirparsechromevisualequalityframeworkarktypergbdatafast-copysameValueZerogroupByexpresssomerdsajaxlinuxReactiveExtensionscliArrayBufferenvironmentsES2016installeres-shim APIfullwidthIteratorestreeregexpuninstalluuidpersistentquerystringwgetsliceeslintconfigcloudformationfunctionalArray.prototype.includesqueueMicrotaskESless csscss lesspyyamles2017ponyfillcontainsyamlhashreducerbindtypeofmkdirspathECMAScript 2018less mixinsmatchECMAScript 3TypeBoxwhatwg$.extendprogressbcryptajvprototypegetPrototypeOfoptimizercss variabledeletenumberassertsiterateregeximmerURLSearchParamssharedarraybufferstyled-componentscomputed-typescompilerFloat64ArrayflagsiginthaswatcherspinnerawesomesaucegdprslotObject.valuesObservableparsingwrapplugincharacterreal-timecolumnshrinkwrapawaitjapaneselistenersperformancewalkingtrimStartform-validationcommanderinternalsetImmediatedirrequestglacierdependency managertrimEndECMAScript 2021writableUnderscoresignalsECMAScript 7typesafecolorObservablesreducewidthkarmavalidtypedarraysquerydeep-clonefetchmochacloudtrailArray.prototype.filteraccessibilityguidmimelintutil.inspectieCSSoptionviewpostcssArrayBuffer#slicefullnegative zerooptimistendpointes6package.jsonFunction.prototype.namepostcss-pluginobjectelectronrecursivefile systemes2015includesvaluekeyconsumeprefixHyBiES2022libphonenumbereventDispatcherconcatroute53flagstostringtagdirectoryclassnamesstringifyargparsetc39coercibleStreamoperating-systempicomatchzerofluxzodredactgetOwnPropertyDescriptorpositivetrimjsonpathtoolsaccessorextensionstructuredCloneawssuperstructparentseast-asian-widthES7findupdom-testing-libraryargvObject.entriesqsfromstylesheetbundlerformsdotenvECMAScript 2019kinesisprunetypedES2017formatbreakesYAMLvestasserttrimLeftlimitcssloggervalidateagentfastifylinewrapsqsoutputidentifiersdataviewpropapiWebSocketssyntaxerrorworkflowmakelookshiminferencerapidartpackageiterationsetSymbolruntimedependenciesisConcatSpreadablefindLastES2018ReactiveXES2015urlECMAScript 2015intrinsicpreprocessorlastmixinsserializationtestingstreams2deep-copyhelpersseshardlinksstoragegatewayprivatepromisesmetadatasideinspectrestfulcreatestarterlanguageeslintpluginrateauthenticationlockfileArray.prototype.findLastIndexcollection.es6shamtraversequote.envproxystablelesshttpsarraybufferes2018stylingfoldera11yappexitinstallairbnbebspredictablecensorinternal slotmergeTypedArraymomentinterruptstoSortedconfigcopyobjdatebootstrap cssURLremove[[Prototype]]full-widthsnsbufferpasswordString.prototype.trimstyleenvironmentcollectionperformantES5jsonstatusefficientistoStringTagfastcopylook-upnamemkdirp__proto__String.prototype.matchAllcallexit-codedynamodbloadingwindowshigher-orderhookssymbolformattingflattencloudwatchpackagesmkdirimportserializextermtypeseventsArray.prototype.flatclass-validatorjsdiffformkoreanreplayutilitiesarraysMaphandlersloadbalancingindefinePropertyECMAScript 2016arraycurlduplexpropertieswatchingcolorsMicrosoftInt8ArrayinputlimitedpolyfillcallbackbeanstalkObject.getPrototypeOfless.jses2016hotreact-hooksargsreact-hook-formgradients css3jQuerycss nestinglesscsstesterJSON-SchematypanionconfigurableObject.assignwhichirqassertionfssafetsmimetypessymbolsstyleguideprotocol-buffersidlejshintWeakMapavaentriesidchaiObject.fromEntriesrest@@toStringTagcheckspinnersdeepclonecomparegraphqlclientreact-testing-libraryjsnpmmake dirprivate datarfc4122chromiummacosnodedroptestnamestypeerrorObject.keystaskECMAScript 2023descriptionbyteOffsetes5monorepojavascripttapcharactersgetterObject.definePropertyimportexportsimpledbcloudfrontargumentswfStyleSheetdeepcopy
3.7.117

11 months ago

2.7.117

11 months ago

2.6.117

11 months ago

2.6.116

11 months ago

2.6.115

11 months ago

2.6.114

11 months ago

2.6.113

11 months ago

2.6.112

11 months ago

2.6.91

11 months ago

2.6.92

11 months ago

2.6.93

11 months ago

2.6.94

11 months ago

2.6.101

11 months ago

2.6.102

11 months ago

2.6.100

11 months ago

2.6.90

12 months ago

2.0.37

1 year ago

2.0.38

1 year ago

2.0.35

1 year ago

2.0.36

1 year ago

2.0.33

1 year ago

2.4.79

12 months ago

2.0.34

1 year ago

2.0.31

1 year ago

2.0.32

1 year ago

2.6.99

11 months ago

2.4.76

12 months ago

2.4.75

12 months ago

2.0.30

1 year ago

2.4.78

12 months ago

2.4.77

12 months ago

2.6.95

11 months ago

2.6.96

11 months ago

2.6.97

11 months ago

2.4.74

12 months ago

2.6.98

11 months ago

2.4.81

12 months ago

2.4.80

12 months ago

2.2.68

1 year ago

2.2.69

1 year ago

2.2.66

1 year ago

2.2.67

1 year ago

2.2.64

1 year ago

2.2.65

1 year ago

2.2.63

1 year ago

2.4.83

12 months ago

2.4.82

12 months ago

2.4.84

12 months ago

2.2.70

1 year ago

2.1.38

1 year ago

2.1.39

1 year ago

2.1.49

1 year ago

2.1.47

1 year ago

2.1.48

1 year ago

2.1.45

1 year ago

2.1.46

1 year ago

2.1.43

1 year ago

2.1.44

1 year ago

2.1.41

1 year ago

1.0.22

1 year ago

2.1.42

1 year ago

2.1.40

1 year ago

1.0.26

1 year ago

2.5.84

12 months ago

1.0.25

1 year ago

2.5.85

12 months ago

1.0.24

1 year ago

2.5.86

12 months ago

1.0.23

1 year ago

1.0.29

1 year ago

1.0.28

1 year ago

1.0.27

1 year ago

2.1.58

1 year ago

2.1.59

1 year ago

2.1.56

1 year ago

2.1.57

1 year ago

2.1.54

1 year ago

2.1.55

1 year ago

2.1.52

1 year ago

2.3.74

12 months ago

2.1.53

1 year ago

2.1.50

1 year ago

2.1.51

1 year ago

1.0.30

1 year ago

2.3.71

1 year ago

2.3.70

1 year ago

2.3.73

1 year ago

2.3.72

1 year ago

2.1.63

1 year ago

2.1.61

1 year ago

2.1.62

1 year ago

2.1.60

1 year ago

2.6.110

11 months ago

2.6.111

11 months ago

2.6.105

11 months ago

2.6.88

12 months ago

2.6.106

11 months ago

2.6.89

12 months ago

2.6.103

11 months ago

2.6.104

11 months ago

2.6.109

11 months ago

2.6.107

11 months ago

2.6.86

12 months ago

2.6.108

11 months ago

2.6.87

12 months ago

1.0.21

1 year ago

1.0.20

1 year ago

1.0.19

1 year ago

1.0.18

1 year ago

1.0.17

1 year ago

1.0.16

1 year ago

1.0.15

1 year ago

1.0.14

1 year ago

1.0.13

1 year ago

1.0.12

1 year ago

1.0.11

1 year ago

1.0.10

1 year ago

1.0.9

1 year ago

1.0.8

1 year ago

1.0.7

1 year ago

1.0.6

1 year ago