0.0.5 • Published 2 years ago

avizura-lambda-edge-dictionary v0.0.5

Weekly downloads
-
License
See license in LI...
Repository
-
Last release
2 years ago

lambda-edge-dictionary

This function accepts a config map. The Keys are request url patterns and the Values are AWS S3 object path patterns.

export type CFRequestPathPattern = string;
export type S3ObjectPathPattern = string;
export type Config = Record<CFRequestPathPattern, S3ObjectPathPattern>;

const config: Config = {
  '/dictionary/accounts/:accountId/events/:eventId/country-list': '/accounts/:accountId/events/:eventId/countries.json',
  '/dictionary/accounts/:accountId/country-list': '/accounts/:accountId/countries.json',
  '/dictionary/country-list': `/countries.json`,
};

It tries to match provided request url patterns to actual CloudFront request url in the order they are written in the config. If the match occurred it checks whether an object in the corresponding S3 path exists. If the object exists it redirects the CloudFront request to it. If the object wasn't found - it sequentially checks all remaining S3 object paths from config Values until an existing one is found and than performs a redirect. If no matches occurred or no objects were found - no action will happen.

Usage

const { createLambdaEdge } = require("@bizzabo/lambda-edge-dictionary/lib/s3PathResolver")
0.0.5

2 years ago

0.0.4

2 years ago

0.0.3

2 years ago

0.0.2

2 years ago

0.0.1

2 years ago