Gathering detailed insights and metrics for @serverless/realtime-app
Gathering detailed insights and metrics for @serverless/realtime-app
Gathering detailed insights and metrics for @serverless/realtime-app
Gathering detailed insights and metrics for @serverless/realtime-app
npm install @serverless/realtime-app
Typescript
Module System
Node Version
NPM Version
Cumulative downloads
Total Downloads
Last Day
0%
NaN
Compared to previous day
Last Week
0%
NaN
Compared to previous week
Last Month
0%
NaN
Compared to previous month
Last Year
0%
NaN
Compared to previous year
Deploy a Full-Stack Realtime App in seconds using Serverless Components. Just provide your frontend code (powered by the website component), and your backend code (powered by the socket component).
Great use-cases for this project are: Chat Apps, Bots, Notification Systems, Charting Dashboards, Stock Tickers & more. As always, consider a serverless stack like this if you are looking to deliver software or features with extremely low overhead.
1$ npm install -g @serverless/components
1$ mkdir my-realtime-app && cd my-realtime-app
the directory should look something like this:
|- backend
|- socket.js
|- frontend
|- index.html
|- serverless.yml
|- .env # your development AWS api keys
|- .env.prod # your production AWS api keys
the .env
files are not required if you have the aws keys set globally and you want to use a single stage, but they should look like this.
AWS_ACCESS_KEY_ID=XXX
AWS_SECRET_ACCESS_KEY=XXX
the socket.js
file should minimally look something like this:
1on('default', async (data, socket) => { 2 socket.send(data) 3}) 4
For more info on working with the socket.js
file, check out the socket component docs.
To see a full example of an application built with this, check out this Chat Application.
1# serverless.yml 2 3name: my-realtime-app 4stage: dev 5 6RealtimeApp: 7 component: "@serverless/realtime-app" 8 inputs: 9 name: my-realtime-app 10 description: My Realtime App 11 region: us-east-1 12 13 # backend config to be passed to the socket component 14 backend: 15 # path to the backend code that contains the socket.js file 16 code: ./backend 17 18 memory: 512 19 timeout: 10 20 env: 21 TABLE_NAME: users 22 23 # frontend config to be passed to the website component 24 frontend: 25 # path to the directory that contains your frontend code 26 # if you're using a framework like React, that would be the root of your frontend project, otherwise it'd be where index.html lives. 27 # default is './frontend' 28 code: ./static 29 30 # if your website needs to be built (e.g. using React)... 31 # default is "undefined" 32 build: 33 34 # the path to the build directory. default is ./build 35 dir: ./dist 36 37 # the build command 38 command: npm run build # this is the default anyway! 39 40 # you can provide an env file path (relative to the code path above) to be generated for use by your frontend code. By default it's './src/env.js' 41 envFile: ./frontend/src/env.js 42 43 # the contents of this env file 44 # the backend api url will be injected by default 45 # under the "urlWebsocketApi" key 46 env: 47 SOME_API_URL: https://api.com
1realtime-app (master)$ ️components 2 3 RealtimeApp › outputs: 4 frontend: 5 url: 'http://realtimeapp-lwmb8jd.s3-website-us-east-1.amazonaws.com' 6 env: undefined 7 backend: 8 url: 'wss://rzrqzb6z4h.execute-api.us-east-1.amazonaws.com/dev/' 9 env: [] 10 11 12 14s › dev › RealtimeApp › done 13 14realtime-app (master)$ 15
You can see a full Chat Application that uses this Component in the example folder. It leverages AWS DynamoDB to maintain state of who is connected, so that messages can be sent out to the appropriate connection IDs.
You can also see how this Component can be used programmatically in the Chat App Component's source code.
AWS API Gateway Websockets Pricing https://aws.amazon.com/api-gateway/pricing/#WebSocket_APIs
AWS Lambda Pricing https://aws.amazon.com/lambda/pricing/
Checkout the Serverless Components repo for more information.
No vulnerabilities found.
No security vulnerabilities found.