Licence
MIT
Version
0.2.0
Deps
0
Size
60 kB
Vulns
0
Weekly
0
@ayepi/aws
AWS backends for ayepi: an SQS-backed @ayepi/work
Queue (with transparent S3 offload of large payloads) and an S3-backed
@ayepi/files FileStore + Presigner, all
wrapped in @ayepi/core retry so SQS/S3
throttling is absorbed under load. The AWS SDK v3 clients are optional peer dependencies
you install and own — the package talks to them via client.send(command).
pnpm add @ayepi/aws @aws-sdk/client-s3 @aws-sdk/client-sqs @aws-sdk/lib-storage @aws-sdk/s3-request-presignerimport { S3Client } from '@aws-sdk/client-s3'
import { SQSClient } from '@aws-sdk/client-sqs'
import { createWork } from '@ayepi/work'
import { s3Files } from '@ayepi/aws/s3'
import { sqsQueue } from '@ayepi/aws/sqs'
const s3 = new S3Client({ region: 'us-east-1' })
const sqs = new SQSClient({ region: 'us-east-1' })
const files = s3Files({ client: s3, bucket: 'my-bucket' })
const queue = sqsQueue({
client: sqs,
queueUrl: process.env.SQS_URL!,
waitTimeSeconds: 10,
largePayload: { store: files }, // bodies near SQS's 256 KB cap go to S3
})
const w = createWork({ queue, pubsub, store, work: [/* ... */] as const })How it works
- S3 store.
s3Filesimplements the@ayepi/filesFileStore(andPresigner): streamingput(multipart via@aws-sdk/lib-storage),get/head/delete, prefix-paginatedlist, and native presigned download/upload URLs — no server route needed. - SQS queue.
sqsQueuemaps SQS's native visibility-timeout model onto the@ayepi/workQueue:pushisSendMessage,popisReceiveMessage(a lease),heartbeatisChangeMessageVisibility,ackisDeleteMessage,failreturns the message early. Dead-lettering is the queue's own SQS redrive policy. - Large payloads. SQS caps a message at 256 KB. With
largePayload, a body over the threshold (default ~240 KB) is written to aFileStoreand the message carries a small pointer;popinlines it back andackdeletes the S3 object. - Throttle resilience. Every
client.send(...)is wrapped in@ayepi/coreretry, so a throttled (rate-limited) reply is retried; on exhaustion the error is reported toonErrorand rethrown. - You own the SDK clients. The clients are optional peer deps — you construct and configure them (region, credentials, endpoint) and manage their lifecycle.
Options
// S3 file store
s3Files({
client: s3, // a configured @aws-sdk/client-s3 S3Client
bucket: 'my-bucket',
prefix: 'docs/', // key namespace prepended to every key (default '')
retry: { attempts: 8 }, // core retry policy (default absorbs throttling)
onError: (err) => log(err),
})
// SQS work queue
sqsQueue({
client: sqs, // a configured @aws-sdk/client-sqs SQSClient
queueUrl: process.env.SQS_URL!,
waitTimeSeconds: 10, // long-poll seconds for pop (0–20, default 0)
largePayload: { // optional S3 offload of oversized bodies
store: files, // any @ayepi/files FileStore
threshold: 240 * 1024, // offload bodies larger than this (default ~240 KB)
prefix: 'sqs-payloads/', // key prefix for offloaded bodies (default)
},
retry: { attempts: 8 },
onError: (err) => log(err),
})For AI coding agents
This package ships dense, machine-oriented reference docs written for AI coding agents (Claude Code, Cursor, and the like) to understand and drive the package — point your agent at them:
They ship with this package and also live in the repo.
License
MIT Philip Diffenderfer