Skip to content

connorgiles/lambda-func

Repository files navigation

Lambda Middleware

@lambda-func CI/CD

This monorepo contains the a set of higher order functions and utilities to create composable middleware for lambda functions.

Published Packages

View published pacakges here

Usage

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)

Rush

This repo uses rush to maintain a monorepo of packages. Learn the basics 👉

Installation

npm i -g @microsoft/rush

Useful Commands

  • rush build - build pacakges that need it
  • rush test - test all packages
  • rush create-package --name package-name - create a new package based on the provided template
  • rush rebuild - builds all packages
  • rush publish - publish all packages
  • rush purge - to clean up temporary files created by rush

Installing Dependencies

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).

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Packages

No packages published