rise-utils
v1.0.2
Published
## DB
Readme
rise-utils
DB
Required ENVS:
- TABLE
- REGION (default is us-east-1)
const { db } = require('rise-utils')
await db.create({
PK: '[email protected]',
SK: 'task_@id',
...data
})
await db.set({
PK: '[email protected]',
SK: 'task_@id',
...data
})
await db.remove({
PK: '[email protected]',
SK: 'task_24',
...data
})
await db.get({
PK: '[email protected]',
SK: 'task_24'
})
await db.list({
PK: '[email protected]',
SK: 'task_'
})
await db.list({
GSI1: 'team_1234',
SK: 'task_'
})
await db.list({
GSI2: 'org_1234',
SK: 'task_'
})
// Pagination: get first page
await db.list({
PK: '[email protected]',
SK: 'task_',
limit: 10
})
// Pagination: get second page
await db.list({
PK: '[email protected]',
SK: 'task_',
limit: 10,
startAt: {
PK: '[email protected]',
SK: 'task_11
}
})
Users
Required ENV
- USERPOOL_ID
const { users } = require('rise-utils')
await users.create({
email: '[email protected]'
})
await users.remove({
email: '[email protected]'
})
await users.resetPassword({
email: '[email protected]'
})Consider using https://mjml.io for email html
const { email } = require('rise-utils')
await email.send({
body: '<p>hello</p>',
subject: 'Welcome',
to: '[email protected]',
from: '[email protected]'
})Emitter (SNS)
Required ENV
- ACCOUNT_ID
const { emitter } = require('rise-utils')
await emitter.send({
event: 'user-created',
data: {
id: '1234',
name: 'John'
}
})Events (EventBridge)
Required ENV
- APP_NAME
- EVENT_BUS (default is default)
const { events } = require('rise-utils')
await events.send({
event: 'user-created',
data: {
id: '1234',
name: 'John'
}
})