1.6.12 • Published 2 years ago

@opzlab/library v1.6.12

Weekly downloads
-
License
MIT
Repository
github
Last release
2 years ago

opzlab/library

Documents

logger

function info(...args: any[])
function warn(...args: any[])
function error(...args: any[])
function log(...args: any[])

jsonfiles

set default caches_folder in the environment file '.env'

CACHES_FOLDER = 'caches'
const networks
const objectTemplate
const arrayTemplate

async function loadJson(template: any, filename: string)
async function storeJson(JsonObject: any, filename: string)
async function renameJson(srcfile: string, dscfile: string)
async function removeJson(filenames: string[])

dotenv

async function updateEnvVariable(key: string, value: any)
async function verifyEnvPath()

Use verifyEnvPath to add default '.env' as follows

SHUTDOWNTIMEOUT = 5000
AZURE_STORAGE_CONNECTION_STRING = "DefaultEndpointsProtocol=https;AccountName=opzlife;AccountKey=LOdony4b3rontTCRXyPh6Gna5aJhelonGSWitbbd3+8kSBe46ZAEbn2lL9Xsw3IwA5f/0xS3XhJp+AStUVBkxA==;EndpointSuffix=core.windows.net"
CACHES_FOLDER = caches

POSTGRES_USER= dev
POSTGRES_PASSWORD = dev
POSTGRES_DB = workermainnet
SERVER_PORT = 5432

AZ_CONTAINER = opzlab

storage

set default caches_folder in the environment file '.env'

AZURE_STORAGE_CONNECTION_STRING = "Def..."
AZ_CONTAINER = opzlab
class datastore {
    async removeFolder(){}
    async removeContainer(){}
    async block_push(files: string[]){}
    async block_pull(files: string[]){}
}

postgresql

connections there are 2 connections for 0 default postgres 1 current as '.env'

type connection = {
    name:string,
    db:any
}

const connections:connection[] =[2]

install

async function installPostgreSqlIfNotExist()
async function uninstallPostgreSQLUbuntu()

user

async function userCreate(username: string, passwd: string)
async function userDrop(userName: string)
async function userIsExist(username: string)
async function userArray()

database

async function dbCreate(dbname: string)
async function dbDrop(dbName: string)
async function dbIsExist(dbname: string)
async function dbNameArray()
async function dbGrantToUser(dbname: string, username: string)
async function dbRevokeToUser(dbname: string, username: string)
async function dbGrantee()

table

async function tableCommand(sqlcommand:string)
async function tableList()
async function tableDrop(tableName: string)
async function tableDetail(tableName: string)
async function tableRecords(tableName:string,offset:number,limit:number)
async function tableRecordsbyId(tableName:string,orderby:string,offset:number,limit:number)

block

async function createBlockTable()
async function insertBlock(model: Block)
async function updateBlock(model: Block)
async function deleteBlock(id: number)
async function detailBlockTable(tableName: string)

sample of use

const logger = require('@opzlab/library')
const {networks,objectTemplate,arrayTemplate,loadJson,storeJson} = require('@opzlab/library')
logger.info('Current working directory:', process.cwd())

console.log(networks)
console.log(objectTemplate)
console.log(arrayTemplate)

loadJson(arrayTemplate,'testfile').then((d)=>{
    logger.info(d)
    storeJson(d,'test2')
});

install prostgresql

sudo apt update
sudo apt install postgresql postgresql-contrib
psql --version
sudo service postgresql start
service postgresql status
```
start as 'postgres' and create password for postgres = 'password'
```
sudo -u postgres psql
postgres=# ALTER USER postgres PASSWORD 'password';
postgres=# \q
```
list all users and role
```
postgres=# \du
postgres=# \q
```
try create user name $USER
```
postgres=# CREATE ROLE chaiya LOGIN SUPERUSER CREATEDB CREATEROLE REPLICATION BYPASSRLS PASSWORD 'password';
postgres=# \du
postgres=# DROP ROLE chaiya;
postgres=# \du
postgres=# \q
sudo -u postgres psql -c "CREATE USER admin WITH PASSWORD 'password';"
```

# sample
```
cd ~
sudo -u postgres createdb workermainnet
cd ~
sudo -u postgres psql -c "CREATE USER dev WITH PASSWORD 'dev';"
cd ~
sudo -u postgres psql -c "grant all privileges on database workermainnet to dev;"
```
@azure/storage-blob@terra-money/feather.js@types/bluebird@types/fs-extraababacornacorn-globalsacorn-jsxacorn-walkajvansi-colorsansi-escapesansi-regexansi-stylesanymatchargparsearia-queryarr-diffarr-flattenarr-unionarray-buffer-byte-lengtharray-equalarray-includesarray-unionarray-uniquearray.prototype.findlastindexarray.prototype.flatarray.prototype.flatmaparray.prototype.tosortedarraybuffer.prototype.sliceasn1assert-plusassign-symbolsast-types-flowastral-regexasynckitasyncroat-least-nodeatobavailable-typed-arraysaws-sign2aws4axe-coreaxiosaxobject-querybabel-eslintbabel-jestbabel-plugin-annotate-pure-callsbabel-plugin-dev-expressionbabel-plugin-istanbulbabel-plugin-jest-hoistbabel-plugin-macrosbabel-plugin-polyfill-corejs2babel-plugin-polyfill-corejs3babel-plugin-polyfill-regeneratorbabel-plugin-transform-rename-importbabel-preset-current-node-syntaxbabel-preset-jestbalanced-matchbasebcrypt-pbkdfbinary-extensionsbluebirdbrace-expansionbracesbrowser-process-hrtimebrowser-resolvebrowserslistbs-loggerbserbuffer-frombuiltin-modulesbytes-ieccache-basecall-bindcallsitescamelcasecaniuse-litecapture-exitcaselesschalkchardetchokidarci-infoclass-utilscli-cursorcli-spinnerscli-widthcliuiclonecocollect-v8-coveragecollection-visitcolor-convertcolor-namecombined-streamcommandercommondircomponent-emitterconcat-mapconfusing-browser-globalsconvert-source-mapcopy-descriptorcore-js-compatcore-util-iscosmiconfigcross-spawncssomcssstyledamerau-levenshteindashdashdata-urlsdate-fns-timezonedebugdecamelizedecode-uri-componentdeep-isdeepmergedefaultsdefine-propertiesdefine-propertydelayed-streamdequaldetect-newlinediff-sequencesdir-globdoctrinedomexceptiondotenvecc-jsbnelectron-to-chromiumemoji-regexend-of-streamenquirererror-exes-abstractes-set-tostringtages-shim-unscopableses-to-primitiveesbuildescaladeescape-string-regexpescodegeneslinteslint-config-prettiereslint-config-react-appeslint-import-resolver-nodeeslint-module-utilseslint-plugin-flowtypeeslint-plugin-importeslint-plugin-jsx-a11yeslint-plugin-prettiereslint-plugin-reacteslint-plugin-react-hookseslint-scopeeslint-utilseslint-visitor-keysespreeesprimaesqueryesrecurseestraverseestree-walkeresutilsexec-shexecaexitexpand-bracketsexpectextendextend-shallowexternal-editorextglobextsprintffast-deep-equalfast-difffast-globfast-json-stable-stringifyfast-levenshteinfastqfb-watchmanfiguresfile-entry-cachefill-rangefind-cache-dirfind-upflat-cacheflattedfor-eachfor-inforever-agentform-datafragment-cachefs-extrafs.realpathfunction-bindfunction.prototype.namefunctional-red-black-treefunctions-have-namesgensyncget-caller-fileget-intrinsicget-package-typeget-stdinget-streamget-symbol-descriptionget-valuegetpassglobglob-parentglobalglobalsglobalthisglobalyzerglobbyglobrexgopdgraceful-fsgrowlyhar-schemahar-validatorhashas-bigintshas-flaghas-property-descriptorshas-protohas-symbolshas-tostringtaghas-valuehas-valueshosted-git-infohtml-encoding-snifferhtml-escaperhttp-signaturehuman-signalshumanize-durationiconv-liteignoreimport-freshimport-localimurmurhashinflightinheritsinquirerinternal-slotinterpretip-regexis-accessor-descriptoris-array-bufferis-arrayishis-bigintis-binary-pathis-boolean-objectis-bufferis-callableis-ciis-core-moduleis-data-descriptoris-date-objectis-descriptoris-dockeris-extendableis-extglobis-fullwidth-code-pointis-generator-fnis-globis-interactiveis-moduleis-negative-zerois-numberis-number-objectis-plain-objectis-referenceis-regexis-shared-array-bufferis-streamis-stringis-symbolis-typed-arrayis-typedarrayis-weakrefis-windowsis-wslisarrayisexeisobjectisstreamistanbul-lib-coverageistanbul-lib-instrumentistanbul-lib-reportistanbul-lib-source-mapsistanbul-reportsjestjest-changed-filesjest-clijest-configjest-diffjest-docblockjest-eachjest-environment-jsdomjest-environment-nodejest-get-typejest-haste-mapjest-jasmine2jest-leak-detectorjest-matcher-utilsjest-message-utiljest-mockjest-pnp-resolverjest-regex-utiljest-resolvejest-resolve-dependenciesjest-runnerjest-runtimejest-serializerjest-snapshotjest-utiljest-validatejest-watch-typeaheadjest-watcherjest-workerjpjsjs-tokensjs-yamljsbnjsdomjsescjson-parse-even-better-errorsjson-schemajson-schema-traversejson-stable-stringify-without-jsonifyjson-stringify-safejson5jsonfilejsprimjsx-ast-utilskind-ofkleurlanguage-subtag-registrylanguage-tagslevenlevnlilconfiglines-and-columnslocate-pathlodashlodash.debouncelodash.memoizelodash.mergelodash.sortbylog-symbolslog-updatelolexloose-envifylower-caselru-cachemagic-stringmake-dirmake-errormakeerrormap-cachemap-visitmerge-streammerge2micromatchmime-dbmime-typesmimic-fnminimatchminimistmixin-deepmkdirpmrimsmute-streamnanoidnanomatchnanospinnernatural-comparenice-tryno-casenode-int64node-notifiernode-releasesnormalize-package-datanormalize-pathnpm-run-pathnwsapioauth-signobject-assignobject-copyobject-inspectobject-keysobject-visitobject.assignobject.entriesobject.fromentriesobject.groupbyobject.hasownobject.pickobject.valuesonceonetimeoptionatororaos-tmpdirp-each-seriesp-finallyp-limitp-locatep-tryparent-moduleparse-jsonparse5pascal-casepascalcasepath-existspath-is-absolutepath-keypath-parsepath-typeperformance-nowpgpg-promisepicocolorspicomatchpiratespkg-dirpnposix-character-classesprelude-lsprettierprettier-linter-helperspretty-formatprogressprogress-estimatorpromptsprop-typespslpumppunycodeqsqueue-microtaskrandombytesreact-isread-pkgread-pkg-upreaddirprealpath-nativerechoirregenerateregenerate-unicode-propertiesregenerator-runtimeregenerator-transformregex-notregexp.prototype.flagsregexppregexpu-coreregjsparserremove-trailing-separatorrepeat-elementrepeat-stringrequestrequest-promise-corerequest-promise-nativerequire-directoryrequire-main-filenameresolveresolve-cwdresolve-fromresolve-urlrestore-cursorretreusifyrimrafrolluprollup-plugin-sourcemapsrollup-plugin-terserrollup-plugin-typescript2rollup-pluginutilsrsvprun-asyncrun-parallelrxjssadesafe-array-concatsafe-buffersafe-regexsafe-regex-testsafer-buffersanesaxessemverserialize-javascriptset-blockingset-valueshebang-commandshebang-regexshelljsshellwordsside-channelsignal-exitsisteransislashslice-ansisnapdragonsnapdragon-nodesnapdragon-utilsource-mapsource-map-resolvesource-map-supportsource-map-urlsourcemap-codecspdx-correctspdx-exceptionsspdx-expression-parsespdx-license-idssplit-stringsprintf-jssshpkstack-utilsstatic-extendstealthy-requirestring-lengthstring-widthstring.prototype.matchallstring.prototype.trimstring.prototype.trimendstring.prototype.trimstartstrip-ansistrip-bomstrip-eofstrip-final-newlinestrip-json-commentssupports-colorsupports-hyperlinkssupports-preserve-symlinks-flagsymbol-treetableterminal-linktersertest-excludetext-tablethroatthroughtiny-globtmptmplto-fast-propertiesto-object-pathto-regexto-regex-rangetough-cookietr46ts-jesttsconfig-pathstsutilstunnel-agenttweetnacltype-checktype-detecttype-festtyped-array-buffertyped-array-byte-lengthtyped-array-byte-offsettyped-array-lengthtypedarray-to-bufferunbox-primitiveunicode-canonical-property-names-ecmascriptunicode-match-property-ecmascriptunicode-match-property-value-ecmascriptunicode-property-aliases-ecmascriptunion-valueuniversalifyunset-valueupdate-browserslist-dburi-jsurixuseuuidv8-compile-cachev8-to-istanbulvalidate-npm-package-licenseverrorw3c-hr-timew3c-xmlserializerwalkerwcwidthwebidl-conversionswhatwg-encodingwhatwg-mimetypewhatwg-urlwhichwhich-boxed-primitivewhich-modulewhich-typed-arrayword-wrapwrap-ansiwrappywritewrite-file-atomicwsxml-name-validatorxmlcharsy18nyallistyamlyargsyargs-parser
1.6.12

2 years ago

1.6.11

2 years ago

1.6.10

2 years ago

1.6.9

2 years ago

1.6.8

2 years ago

1.6.7

2 years ago

1.6.6

2 years ago

1.6.5

2 years ago

1.6.4

2 years ago

1.6.1

2 years ago

1.6.0

2 years ago

1.5.19

2 years ago

1.5.17

2 years ago

1.5.16

2 years ago

1.5.15

2 years ago

1.5.14

2 years ago

1.5.13

2 years ago

1.5.12

2 years ago

1.5.11

2 years ago

1.5.10

2 years ago

1.5.9

2 years ago

1.5.8

2 years ago

1.5.7

2 years ago

1.5.6

2 years ago

1.5.5

2 years ago

1.5.4

2 years ago

1.5.3

2 years ago

1.5.2

2 years ago

1.5.1

2 years ago

1.5.0

2 years ago

1.4.3

2 years ago

1.4.1

2 years ago

1.4.0

2 years ago

1.3.64

2 years ago

1.3.63

2 years ago

1.3.62

2 years ago

1.3.61

2 years ago

1.3.60

2 years ago

1.3.59

2 years ago

1.3.58

2 years ago

1.3.57

2 years ago

1.3.56

2 years ago

1.3.55

2 years ago

1.3.54

2 years ago

1.3.53

2 years ago

1.3.52

2 years ago

1.3.51

2 years ago

1.3.50

2 years ago

1.3.48

2 years ago

1.3.47

2 years ago

1.3.46

2 years ago

1.3.45

2 years ago

1.3.44

2 years ago

1.3.43

2 years ago

1.3.41

2 years ago

1.3.40

2 years ago

1.3.39

2 years ago

1.3.38

2 years ago

1.3.37

2 years ago

1.3.36

2 years ago

1.3.35

2 years ago

1.3.34

2 years ago

1.3.33

2 years ago

1.3.32

2 years ago

1.3.31

2 years ago

1.3.30

2 years ago

1.3.29

2 years ago

1.3.28

2 years ago

1.3.27

2 years ago

1.3.26

2 years ago

1.3.25

2 years ago

1.3.24

2 years ago

1.3.23

2 years ago

1.3.22

2 years ago

1.3.21

2 years ago

1.3.20

2 years ago

1.3.19

2 years ago

1.3.18

2 years ago

1.3.17

2 years ago

1.3.16

2 years ago

1.3.15

2 years ago

1.3.14

2 years ago

1.3.13

2 years ago

1.3.12

2 years ago

1.3.11

2 years ago

1.3.10

2 years ago

1.3.9

2 years ago

1.3.8

2 years ago

1.3.6

2 years ago

1.3.5

2 years ago

1.3.4

2 years ago

1.3.3

2 years ago

1.3.2

2 years ago

1.3.1

2 years ago

1.3.0

2 years ago

1.2.13

2 years ago

1.2.18

2 years ago

1.2.17

2 years ago

1.2.16

2 years ago

1.2.15

2 years ago

1.2.14

2 years ago

1.2.12

2 years ago

1.2.11

2 years ago

1.2.10

2 years ago

1.2.9

2 years ago

1.2.8

2 years ago

1.2.7

2 years ago

1.2.6

2 years ago

1.2.5

2 years ago

1.2.4

2 years ago

1.2.3

2 years ago

1.2.2

2 years ago

1.2.1

2 years ago

1.2.0

2 years ago

0.2.0

2 years ago

0.1.14

2 years ago

0.1.13

2 years ago

0.1.12

2 years ago

0.1.10

2 years ago

0.1.5

2 years ago

0.1.4

2 years ago

0.1.3

2 years ago

0.1.2

2 years ago

0.1.1

2 years ago

0.1.0

2 years ago

1.0.0

2 years ago