Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/tbeseda/astro-lambda-adapter
Astro AWS Lambda SSR Adapter
https://github.com/tbeseda/astro-lambda-adapter
astro aws lambda ssr
Last synced: 5 days ago
JSON representation
Astro AWS Lambda SSR Adapter
- Host: GitHub
- URL: https://github.com/tbeseda/astro-lambda-adapter
- Owner: tbeseda
- Created: 2022-04-11T04:22:01.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2022-04-14T19:46:40.000Z (over 2 years ago)
- Last Synced: 2024-10-07T08:13:55.376Z (about 1 month ago)
- Topics: astro, aws, lambda, ssr
- Language: TypeScript
- Homepage: https://www.npmjs.com/package/astro-lambda-adapter
- Size: 20.5 KB
- Stars: 12
- Watchers: 4
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# `astro-lambda-adapter`
The primary objective here is to map a `APIGatewayProxyEventV2` received in a Lambda to an Astro/Node.js `Request` and then Astro's `Response` to `APIGatewayProxyResult`.
See [./src/server.ts](./src/server.ts).
## Astro SSR AWS Lambda Adapter
> ⚠️ Still really early days on this one. Request `body` still unsupported. No deploys with complex Astro apps. Generally untested. Feedback and PRs welcome.
```sh
npm i astro-lambda-adapter
``````js
// ./astro.config.js
import { defineConfig } from 'astro/config';
import awsAdapter from 'astro-lambda-adapter';export default defineConfig({
adapter: awsAdapter(),
outDir: './myLambda/dist',
});
``````js
// ./myLambda/index.mjs
import { handler as ssrHandler } from './dist/server/entry.mjs';export async function handler(event) {
console.log(`🚀 ${event.requestContext.http.method}: ${event.rawPath}`);
return await ssrHandler(event);
}
``````astro
---
// ./src/pages/index.astro
const RANDOM = Math.floor(Math.random() * 100) + 1;
---
Astro on Lambda
Astro on Lambda
Random:
{RANDOM}
```
> 📜 This integration doesn't modify how Astro uses Vite to build and bundle your app. You may find it beneficial to [configure Vite via Astro](https://docs.astro.build/en/reference/configuration-reference/#vite) to optimize the build for Lambda.