README
cnktech-utils
DB Usage
Required ENVS:
- TABLE
- REGION
const { db } = require("@cnktech/utils")
await db.create({
PK: "gary@example.com",
SK: "task_@id",
})
await db.set({
PK: "gary@example.com",
SK: "task_@id",
})
await db.remove({
PK: "gary@example.com",
SK: "task_24",
})
await db.get({
PK: "gary@example.com",
SK: "task_24",
})
await db.query({
PK: "gary@example.com",
SK: "task_",
})
await db.query({
PK: "gary@example.com",
SK: "task_",
limit: 10,
startAt: {
PK: 'something',
SK: 'else
}
})
Event Usage
Required ENVS:
- EVENTBUS
const { event } = require('@cnktech/utils')
await event({
source: 'my-service',
event: 'user-added',
data: {
id: 123,
name: 'Gary'
}
})
Email Usage
const { email } = require('@cnktech/utils')
await email({
body: '<p>hello</p>',
subject: 'Welcome',
to: 'gary@example.com',
from: 'test@example.com'
})
Cognito Usage
Required ENV
- USERPOOL_ID
const { cognito } = require('@cnktech/utils')
await cognito.createUser({
email: 'gary@example.com',
password: '123'
})
await cognito.deleteUser({
email: 'gary@example.com'
})
await cognito.resetPassword({
email: 'gary@example.com'
})
General Usage
const { general } = require('@cnktech/utils')
const pass = general.password()