Package Exports
- @serverless/components
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (@serverless/components) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
Serverless Components is a framework for easily provisioning and sharing application components on cloud serverless services.
It does not seek to be another general infrastructure provisioning tool (e.g. Cloudformation, Terraform), but a solution that enables developers to build their own reusable abstractions on top of infrastructure, that resemble the use-case they are seeking to build (e.g. a Blog, Payment Processor, Realtime Application). Components are simply npm packages that provision infrastructure and high level use cases.
You could use components either programmatically with a serverless.js
file (which would also create a component in the process), or with a serverless.yml
file. These Components are use-case focused, and you can deploy them alongside infrastructure, in the same file.
# serverless.yml
name: my-blog
# higher-level abstraction
Comments:
component: "@serverless/comments"
inputs:
region: us-east-1
# infrastructure
listPosts:
component: "@serverless/aws-lambda"
inputs:
memorySize: 1024
Get Started
Install components.
$ npm i -g @serverless/components
create a directory for your new component.
$ mkdir my-component && cd my-component
Run components
and choose what you'd like to create. Choose My Own Component
for a quick tour that helps you create your own component, which could programmatically use existing components from npm.
$ components
? What would you like to create in this directory? › - Use arrow-keys. Return to submit.
❯ My Own Component
Function
API
Website
Realtime Application
Chat Application
Websocket Backend
Now every time you run components
, you'll be running your new component. Check out the generated files for more information.
Available Components
Instead of creating your own component, you could also choose to generate a serverless.yml
template that uses one or more of the available components (e.g. Chat Application
), which would copy one of the available templates into the current working directory.
Note: If you don't have your aws access keys set globally, don't forget to add them to a .env
file in the current directory.
After choosing what you'd like to create from the prompt, run components
to run your template.
$ chat-app: components
chat-app › outputs:
url: 'http://chatapp-5m53dym.s3-website-us-east-1.amazonaws.com'
53s › dev › my-chat-app › done
And there you have it! A complete chat application deployed to your own infrastructure in seconds.
These are the available components you could instantly deploy declarateively with a serverless.yml
file, or programmatically with a serverless.js
file. Check out each component repo for complete docs on how to use them. They also serve as complete examples on how to write a real-world serverless component.
- RealtimeApp
- Socket
- Website
- ChatApp
- AwsDynamoDb
- AwsApiGateway
- AwsIamRole
- AwsLambda
- AwsLambdaLayer
- AwsS3
- AwsWebSockets
Created By
- Eslam Hefnawy - @eahefnawy
- Philipp Muens - @pmuens
- Austen Collins - @ac360