This monorepo contains the a set of higher order functions and utilities to create composable middleware for lambda functions.
import { z } from 'zod'
import { compose, Controller } from '@lambda-func/core'
import { sqs } from '@lambda-func/sqs'
import { inject } from '@lambda-func/inject'
import { select } from '@lambda-func/select'
import { zodParser } from '@lambda-func/zod'
import { Database, Logger } from '../services'
const wrapper = compose(
sqs(),
select((record) => record.body),
zodParser(
z.object({
id: z.string(),
name: z.string()
})
),
inject('db', Database),
inject('logger', Logger)
)
// easily testable controller
export const controller: Controller<typeof wrapper> = async (record, { logger, db }) => {
logger.info('Saving record to database')
await db.save(record)
}
export const handler = wrapper(controller)
This repo uses rush to maintain a monorepo of packages. Learn the basics 👉
npm i -g @microsoft/rush
rush build
- build pacakges that need itrush test
- test all packagesrush create-package --name package-name
- create a new package based on the provided templaterush rebuild
- builds all packagesrush publish
- publish all packagesrush purge
- to clean up temporary files created by rush
With rush, you often will work from the directory of the individual "project" (package) you are working on. If you want to add a dependency to to that project then you run rush add --package example-package (--dev)
.