Skip to content

Refzlund/apie-monorepo

Repository files navigation

@apie

@apie is a monorepo that contains several packages for handling a REST API in a functional programmatic manner.

However, it is also intended to generally provide typed error responses.

  • @apie/pipe is the driver of the functional programming structure
  • @apie/responses contains branded responses and is used in conjunction with the other packages
  • @apie/utilities contains utility types/functions that the other packages depend on

Important

The following packages are work in progress. Find them in the feat-api-kit branch

Example

type State = {
	value: number
}

const pipe = createEventPipe<State>()

const checkValue = pipe((event, input: number) => {
	if(input > event.value)
		return BadRequest(`Input cannot be more than ${event.value}`)
	return 'Some string'
})

const logString = pipe((event, input: string) => {
	console.log(input)
	return OK()
})

const combined = pipe(
	200,
	checkValue,
	logString
)

combined({ value: 100 }) // => BadRequest(`Input cannot be more than 100`)
combined({ value: 500 }) // => console.log('Some string'), OK()

About

Packages that handle the architectural pattern for a typical serverless function REST API backend

Topics

Resources

Stars

Watchers

Forks