1.0.0 • Published 2 years ago

fastify-s3-buckets v1.0.0

Weekly downloads
-
License
-
Repository
github
Last release
2 years ago

fastify-s3-buckets

Fastify plugin for ensuring existence of defined AWS S3 buckets on the application startup.

NPM Version Build Status

How to use?

import fastify from 'fastify';
import { fastifyS3BucketsPlugin } from 'fastify-s3-buckets';
import { S3Client } from '@aws-sdk/client-s3'

const s3Config = {
    endpoint: 'http://s3.localhost.localstack.cloud:4566',
    region: 'eu-west-1',
    credentials: {
        accessKeyId: 'access',
        secretAccessKey: 'secret',
    },
}
const s3Client = new S3Client(s3Config)

const app = fastify()
app.register(fastifyS3BucketsPlugin, {
    s3Client,
    buckets: [{ Bucket: 'abc' }, { Bucket: 'def' }, { Bucket: 'ghi' }],
})
await app.ready() // missing buckets will be created here

Note that if buckets already exist, they will not be recreated. Existing buckets that are not specified will not be deleted.