galenjs factories.
const { camelJsonKeys } = require('@galenjs/factories/lodash')
camelJsonKeys({
field_one: {
field_two: 'test'
},
field_three: 'test',
field_four: [{
field_five: 'test'
}]
})
const { snakeJsonKeys } = require('@galenjs/factories/lodash')
snakeJsonKeys({
fieldOne: {
fieldTwo: 'test'
},
fieldThree: 'test',
fieldFour: [{
fieldFive: 'test'
}]
})
const { sleep } = require('@galenjs/factories/sleep')
await sleep(1000)
const validateSchema = require('@galenjs/factories/validateJsonSchema')
await validateSchema({ field: 1 }, {
type: 'object',
properties: {
field: { type: 'string' }
}
}, {
extendErr: 'test'
})
const { parseCsv } = require('@galenjs/factories/csv')
parseCsv({
data: `id,name
1,Harper Lee
2,JRR Tolkien
3,William Shakespeare`,
endsWithLine: '\n',
delimiter: ','
})
const { writeCsv } = require('@galenjs/factories/csv')
writeCsv({
filePath: 'test.csv',
header: 'id,name',
data: [{ id: 1, name: "Harper Lee" }],
fields: ['id', 'name'],
writeLineLength: 1,
endsWithLine: '\r\n'
})
const { hash } = require('@galenjs/factories/crypto')
console.log(hash('test'))
const { encrypted } = require('@galenjs/factories/crypto')
const tt = 'abc'
const iv = crypto.randomBytes(16).toString('base64')
const key = crypto.randomBytes(16).toString('base64')
encrypted(tt, { key, iv })
const { decrypted } = require('@galenjs/factories/crypto')
const iv = crypto.randomBytes(16).toString('base64')
const key = crypto.randomBytes(16).toString('base64')
const decryptedData = decrypted(encryptedData, { key, iv })
const CustomLimit = require('@galenjs/factories/customLimit')
const customLimit = new CustomLimit()
const ret = await customLimit.execute(`${Date.now()}/1000`, () => 'helloWorld')
console.log(ret)