All Projects → activescott → serverless-aws-static-file-handler

activescott / serverless-aws-static-file-handler

Licence: MIT license
Easily serve static files with the Serverless Framework on AWS Lambda.

Programming Languages

javascript
184084 projects - #8 most used programming language
shell
77523 projects
HTML
75241 projects

Projects that are alternatives of or similar to serverless-aws-static-file-handler

Awesome Serverless
DEPRECATED: Curated list of resources related to serverless computing and serverless architectures.
Stars: ✭ 2,049 (+4665.12%)
Mutual labels:  serverless-functions, serverless-framework, serverless-plugin, serverless-architectures
Serverless Chrome
🌐 Run headless Chrome/Chromium on AWS Lambda
Stars: ✭ 2,625 (+6004.65%)
Mutual labels:  serverless-functions, serverless-framework, serverless-plugin
serverless-fission
Use Fission through Serverless Framework https://serverless.com
Stars: ✭ 19 (-55.81%)
Mutual labels:  serverless-functions, serverless-framework, serverless-plugin
Serverless Openwhisk
Adds Apache OpenWhisk support to the Serverless Framework!
Stars: ✭ 131 (+204.65%)
Mutual labels:  serverless-functions, serverless-framework, serverless-plugin
Serverless Step Functions
AWS Step Functions plugin for Serverless Framework ⚡️
Stars: ✭ 758 (+1662.79%)
Mutual labels:  serverless-framework, serverless-plugin, serverless-architectures
Awesome Layers
λ A curated list of awesome AWS Lambda Layers. Sponsored by https://cloudash.dev
Stars: ✭ 1,655 (+3748.84%)
Mutual labels:  serverless-functions, serverless-framework
Retinal
🏙 Retinal is a Serverless AWS Lambda service for resizing images on-demand or event-triggered
Stars: ✭ 208 (+383.72%)
Mutual labels:  serverless-functions, serverless-framework
Openwhisk Deploy Kube
The Apache OpenWhisk Kubernetes Deployment repository supports deploying the Apache OpenWhisk system on Kubernetes and OpenShift clusters.
Stars: ✭ 231 (+437.21%)
Mutual labels:  serverless-functions, serverless-architectures
serverless-cloudformation-sub-variables
Serverless framework plugin for easily supporting AWS CloudFormation Sub intrinsic function variables
Stars: ✭ 25 (-41.86%)
Mutual labels:  serverless-framework, serverless-plugin
Openwhisk Runtime Nodejs
Apache OpenWhisk Runtime NodeJS supports Apache OpenWhisk functions written in JavaScript for NodeJS
Stars: ✭ 43 (+0%)
Mutual labels:  serverless-functions, serverless-architectures
openwhisk-package-kafka
Apache OpenWhisk package for communicating with Kafka or Message Hub
Stars: ✭ 35 (-18.6%)
Mutual labels:  serverless-functions, serverless-architectures
openwhisk-runtime-go
Apache OpenWhisk Runtime Go supports Apache OpenWhisk functions written in Go
Stars: ✭ 31 (-27.91%)
Mutual labels:  serverless-functions, serverless-architectures
serverless-plugin-offline-kinesis-events
⚡ Serverless plugin that works with serverless-offline to allow offline testing of Serverless functions that are triggered by Kinesis events.
Stars: ✭ 15 (-65.12%)
Mutual labels:  serverless-framework, serverless-plugin
openwhisk-catalog
Curated catalog of Apache OpenWhisk packages to interface with event producers and consumers
Stars: ✭ 30 (-30.23%)
Mutual labels:  serverless-functions, serverless-architectures
serverless-alexa-skills
Manage your Alexa Skills with Serverless Framework
Stars: ✭ 69 (+60.47%)
Mutual labels:  serverless-framework, serverless-plugin
Openwhisk Apigateway
Apache OpenWhisk API Gateway service for exposing actions as REST interfaces.
Stars: ✭ 56 (+30.23%)
Mutual labels:  serverless-functions, serverless-architectures
openwhisk-runtime-java
Apache OpenWhisk Runtime Java supports Apache OpenWhisk functions written in Java and other JVM-hosted languages
Stars: ✭ 43 (+0%)
Mutual labels:  serverless-functions, serverless-architectures
Openwhisk
Apache OpenWhisk is an open source serverless cloud platform
Stars: ✭ 5,499 (+12688.37%)
Mutual labels:  serverless-functions, serverless-architectures
Openwhisk Runtime Php
Apache OpenWhisk Runtime PHP supports Apache OpenWhisk functions written in PHP
Stars: ✭ 26 (-39.53%)
Mutual labels:  serverless-functions, serverless-architectures
openwhisk-runtime-docker
Apache OpenWhisk SDK for building Docker "blackbox" runtimes
Stars: ✭ 23 (-46.51%)
Mutual labels:  serverless-functions, serverless-architectures

npm version npm Build Status Coverage Status License GitHub stars

serverless-aws-static-file-handler

Host the front-end of your web applications on Serverless framework on AWS Lambda right alongside the API.

It is a fast and easy way to get started and makes it trivial to deploy your web applications. If you need better response time in the future and get concerned about AWS costs of using Lambda to static content, you put CloudFront in front of your Serverless endpoints service static content.

Usage / Quick Start

Import & initialize:

const StaticFileHandler = require('serverless-aws-static-file-handler')

# configure where to serve files from:
const clientFilesPath = path.join(__dirname, "./data-files/")
const fileHandler = new StaticFileHandler(clientFilesPath)

Define a handler in your code as follows:

module.exports.html = async (event, context) => {
  event.path = "index.html" // forcing a specific page for this handler, ignore requested path. This would serve ./data-files/index.html
  return fileHandler.get(event, context)
}

In your serverless.yml file, reference the handler function from above to provide routes to your static files:

functions:
  html:
    handler: handler.html
    events:
      - http:
          path: /
          method: get

  # Note Binary files work too! See configuration information below
  png:
    handler: handler.png
    events:
      - http:
          path: png
          method: get

  # The following example uses a path placeholder to serve all files directly in the /binary/ directory:
  binary:
    handler: handler.binary
    events:
      - http:
        path: /binary/{pathvar+}
        method: get

To serve binary content make sure that you setup the plugin in your serverless.yml like so:

plugins:
  - serverless-aws-static-file-handler/plugins/BinaryMediaTypes

custom:
  apiGateway:
    binaryMediaTypes:
      - "image/png"
      - "image/jpeg"

Some additional real-world examples are demonstrated in the examples/basic/ directory as well as a serverless-offline-specific example in examples/serverless-offline/.

Prerequisites / Usage Requirements

Requires Node.js latest, LTS, or v10 (tested).

Requires Serverless Framework v1.x. If you are new to the Serverless Framework, check out the Serverless Framework Getting Started Guide.

Install

Install with yarn (yarn add serverless-aws-static-file-handler) or npm (npm install serverless-aws-static-file-handler --save-prod)

Features

  • Simple to get started
  • Works with text files such as HTML or binary files such as images or fonts

Contributing 🤝

This is a community project. We invite your participation through issues and pull requests! You can peruse the contributing guidelines.

Show your support

Give a ⭐️ if this project helped you!

Release Process (Deploying to NPM)

We use semantic-release to consistently release semver-compatible versions. This project deploys to multiple npm distribution tags. Each of the below branches correspond to the following npm distribution tags:

branch npm distribution tag
main latest
beta beta

To trigger a release use a Conventional Commit following Angular Commit Message Conventions on one of the above branches.

License 📝

Copyright © 2017 [email protected].

This project is MIT licensed.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].