npm i rise-lambda-foundation
import { uuid } from 'rise-lambda-foundation'
const myId = uuid()
import { getPostData } from 'rise-lambda-foundation'
export const handler = async (input) => {
const data = await getPostData(input)
}
import { getUserId } from 'rise-lambda-foundation'
export const handler = async (input) => {
const userId = await getUserId(input)
}
import { http } from 'rise-lambda-foundation'
export const handler = async (input) => {
return http.success({
id: 100
})
}
import { http } from 'rise-lambda-foundation'
export const handler = async (input) => {
const message = 'there was a problem on your end'
return aws.utils.http.validationError(message)
}
import { http } from 'rise-lambda-foundation'
export const handler = async (input) => {
const message = 'there was a problem on our end'
return aws.utils.http.serviceError(message)
}
import { makeSchema } from 'rise-lambda-foundation'
const inputSchema = makeSchema({
foo: 'number!',
bar: 'string',
order: {
foo: 'number!',
bar: 'string'
},
items: [
{
id: 'string'
}
]
})
export const handler = async (e) => {
const input = JSON.parse(e.body)
const inputValidation = inputSchema.validate(input)
if (!inputValidation.isValid) {
return {
statusCode: 400,
data: JSON.stringify({
errors: inputValidation.errors
})
}
}
return {
statusCode: 200,
data: JSON.stringify({
status: 'success'
})
}
}
import { db } from 'rise-lambda-foundation'
const item = await db.get({
pk: 'note',
sk: 'note_1234'
})
Query with begins_with on the sk
import { db } from 'rise-lambda-foundation'
const items = await db.list({
pk: 'note',
sk: 'note_'
})
import { db } from 'rise-lambda-foundation'
await db.set({
pk: 'note',
sk: 'note_@id',
content: 'hello'
})
import { db } from 'rise-lambda-foundation'
await db.remove({
pk: 'note',
sk: 'note_1234'
})