@architect/asap
Architect Static Asset Proxy (ASAP) - a helpful library for Lambda-based static asset delivery
Usage
Module
Call ASAP within your handler function manually like so:
let asap = require('@architect/asap')
module.exports = asap({
alias: {
'/an-asset.jpg': '/a-different-filename.jpg',
'/a-path': '/a-different-path',
},
assets: { 'some-file.gif': 'some-file-a1b2c3.gif' },
bucket: {
staging: 'staging-bucket-name',
production: 'production-bucket-name',
folder: 'some-bucket-subfolder',
},
cacheControl: 'max-age=0',
headers: { 'some-header': 'ok=true' },
passthru: true,
spa: false,
})
Lambda handler
Use ASAP as the handler for your Lambda! If you're using Architect, this is done automatically for you when you don't define a root handler for your @http
pragma.
If using ASAP with non-Architect projects, just point your Lambda's source directory to src/
, and make sure you set the following two env vars:
ARC_ENV
: staging
or production
ARC_STATIC_BUCKET
: the S3 bucket name where your assets are stored