Skip to content

Express/Connect Integration Example

Easiest way to use LambdaQueue in your Express (or any other connect type middleware) application is to use our connect SDK.

Start by installing the package:

bash
npm add @dayone-labs/lambda-queue-connect

INFO

We take care to make our client libraries as slim as possible. Don't be afraid of dependency hell when installing our SDKs. We have exactly 0 dependencies.

Below you can find a minimal code example on how to push and handle queue items using Express.js app router.

Code example

Here's a small sample application that pushes arbitrary data to queue using Connect SDK.

ts
import lq from '@dayone-labs/lambda-queue-connect'
import express from 'express'

const app = express()
const queue = lq.queue('/some-queue', async (event: { name: string }) => {
  return { message: `Hello, ${event.name}!` }
})

app.use(queue)
app.use(express.json())
app.post('/hello', async (req, res) => {
  await queue.push({ name: req.body.name })
  res.send('OK')
})
app.listen(4444, () => console.log('Listening on port 4444'))

All examples are licensed under MIT. You can use them for free in your projects.