Skip to content

Commit 486448d

Browse files
authored
feat: bun server with graphql examples (#584)
1 parent 67a86f0 commit 486448d

File tree

20 files changed

+715
-0
lines changed

20 files changed

+715
-0
lines changed
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
# Bun Server with graphql response streaming example
2+
3+
This example show how to use the Lambda Web Adapter to run a bun server application with response streaming via a [AWS Lambda](https://aws.amazon.com/lambda) Function URL.
4+
5+
### Build and Deploy
6+
7+
Run the following commands to build and deploy the application to lambda.
8+
```
9+
10+
```bash
11+
sam build
12+
13+
sam deploy --guided
14+
```
15+
When the deployment completes, the Function URL will appear in the output list, which is the entrypoint for accessing
16+
17+
### Verify it works
18+
19+
When you open the Function URL in a browser:
20+
21+
1. Write and execute GraphQL queries in the left panel
22+
2. See the results in the right panel
23+
3. Explore the API documentation using the "Docs" button
24+
25+
Try this sample subscription query to test streaming:
26+
27+
```graphql
28+
subscription {
29+
stream(addition: "testing")
30+
}
31+
```
32+
33+
You'll see each character stream in one by one with a small delay between them.
34+
35+
For command line testing, you can use curl:
36+
37+
```bash
38+
curl --no-buffer -N \
39+
-H "Content-Type: application/json" \
40+
-H "Accept: text/event-stream" \
41+
-d '{"query": "subscription { stream(addition: \"test\") }"}' \
42+
https://your-function-url.lambda-url.us-east-1.on.aws/graphql
43+
```
44+
45+
### Thanks
46+
47+
@sumcoding
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
# dependencies (bun install)
2+
node_modules
3+
4+
# output
5+
out
6+
dist
7+
*.tgz
8+
9+
# code coverage
10+
coverage
11+
*.lcov
12+
13+
# logs
14+
logs
15+
_.log
16+
report.[0-9]_.[0-9]_.[0-9]_.[0-9]_.json
17+
18+
# dotenv environment variable files
19+
.env
20+
.env.development.local
21+
.env.test.local
22+
.env.production.local
23+
.env.local
24+
25+
# caches
26+
.eslintcache
27+
.cache
28+
*.tsbuildinfo
29+
30+
# IntelliJ based IDEs
31+
.idea
32+
33+
# Finder (MacOS) folder config
34+
.DS_Store
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
.PHONY: build-BunGraphqlFunction build
2+
3+
build-BunGraphqlFunction:
4+
bun install
5+
bun run build
6+
mkdir -p $(ARTIFACTS_DIR)
7+
cp run.sh out/
8+
cp -r out/* $(ARTIFACTS_DIR)/
9+
10+
build:
11+
$(MAKE) build-BunGraphqlFunction
Lines changed: 101 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
{
2+
"lockfileVersion": 1,
3+
"workspaces": {
4+
"": {
5+
"name": "yoga-graphql-streaming-zip",
6+
"dependencies": {
7+
"cross-env": "^7.0.3",
8+
"graphql": "^16.10.0",
9+
"graphql-yoga": "^5.13.1",
10+
},
11+
"devDependencies": {
12+
"@types/bun": "latest",
13+
"typescript": "^5.8.2",
14+
},
15+
"peerDependencies": {
16+
"typescript": "^5",
17+
},
18+
},
19+
},
20+
"packages": {
21+
"@envelop/core": ["@envelop/[email protected]", "", { "dependencies": { "@envelop/instrumentation": "^1.0.0", "@envelop/types": "^5.2.1", "@whatwg-node/promise-helpers": "^1.2.4", "tslib": "^2.5.0" } }, "sha512-KfoGlYD/XXQSc3BkM1/k15+JQbkQ4ateHazeZoWl9P71FsLTDXSjGy6j7QqfhpIDSbxNISqhPMfZHYSbDFOofQ=="],
22+
23+
"@envelop/instrumentation": ["@envelop/[email protected]", "", { "dependencies": { "@whatwg-node/promise-helpers": "^1.2.1", "tslib": "^2.5.0" } }, "sha512-cxgkB66RQB95H3X27jlnxCRNTmPuSTgmBAq6/4n2Dtv4hsk4yz8FadA1ggmd0uZzvKqWD6CR+WFgTjhDqg7eyw=="],
24+
25+
"@envelop/types": ["@envelop/[email protected]", "", { "dependencies": { "@whatwg-node/promise-helpers": "^1.0.0", "tslib": "^2.5.0" } }, "sha512-CsFmA3u3c2QoLDTfEpGr4t25fjMU31nyvse7IzWTvb0ZycuPjMjb0fjlheh+PbhBYb9YLugnT2uY6Mwcg1o+Zg=="],
26+
27+
"@graphql-tools/executor": ["@graphql-tools/[email protected]", "", { "dependencies": { "@graphql-tools/utils": "^10.8.6", "@graphql-typed-document-node/core": "^3.2.0", "@repeaterjs/repeater": "^3.0.4", "@whatwg-node/disposablestack": "^0.0.6", "@whatwg-node/promise-helpers": "^1.0.0", "tslib": "^2.4.0" }, "peerDependencies": { "graphql": "^14.0.0 || ^15.0.0 || ^16.0.0 || ^17.0.0" } }, "sha512-vtwuotFe9DR1gZ2VXYRxcL6GVP6dYUHWibA9JNOkdRiwCW/icTY7oU9xUVITnOAfjNh9k8Z43kZmiyr2aMopVA=="],
28+
29+
"@graphql-tools/merge": ["@graphql-tools/[email protected]", "", { "dependencies": { "@graphql-tools/utils": "^10.8.6", "tslib": "^2.4.0" }, "peerDependencies": { "graphql": "^14.0.0 || ^15.0.0 || ^16.0.0 || ^17.0.0" } }, "sha512-NzWx/Afl/1qHT3Nm1bghGG2l4jub28AdvtG11PoUlmjcIjnFBJMv4vqL0qnxWe8A82peWo4/TkVdjJRLXwgGEw=="],
30+
31+
"@graphql-tools/schema": ["@graphql-tools/[email protected]", "", { "dependencies": { "@graphql-tools/merge": "^9.0.24", "@graphql-tools/utils": "^10.8.6", "tslib": "^2.4.0" }, "peerDependencies": { "graphql": "^14.0.0 || ^15.0.0 || ^16.0.0 || ^17.0.0" } }, "sha512-aEGVpd1PCuGEwqTXCStpEkmheTHNdMayiIKH1xDWqYp9i8yKv9FRDgkGrY4RD8TNxnf7iII+6KOBGaJ3ygH95A=="],
32+
33+
"@graphql-tools/utils": ["@graphql-tools/[email protected]", "", { "dependencies": { "@graphql-typed-document-node/core": "^3.1.1", "@whatwg-node/promise-helpers": "^1.0.0", "cross-inspect": "1.0.1", "dset": "^3.1.4", "tslib": "^2.4.0" }, "peerDependencies": { "graphql": "^14.0.0 || ^15.0.0 || ^16.0.0 || ^17.0.0" } }, "sha512-Alc9Vyg0oOsGhRapfL3xvqh1zV8nKoFUdtLhXX7Ki4nClaIJXckrA86j+uxEuG3ic6j4jlM1nvcWXRn/71AVLQ=="],
34+
35+
"@graphql-typed-document-node/core": ["@graphql-typed-document-node/[email protected]", "", { "peerDependencies": { "graphql": "^0.8.0 || ^0.9.0 || ^0.10.0 || ^0.11.0 || ^0.12.0 || ^0.13.0 || ^14.0.0 || ^15.0.0 || ^16.0.0 || ^17.0.0" } }, "sha512-mB9oAsNCm9aM3/SOv4YtBMqZbYj10R7dkq8byBqxGY/ncFwhf2oQzMV+LCRlWoDSEBJ3COiR1yeDvMtsoOsuFQ=="],
36+
37+
"@graphql-yoga/logger": ["@graphql-yoga/[email protected]", "", { "dependencies": { "tslib": "^2.8.1" } }, "sha512-Nv0BoDGLMg9QBKy9cIswQ3/6aKaKjlTh87x3GiBg2Z4RrjyrM48DvOOK0pJh1C1At+b0mUIM67cwZcFTDLN4sA=="],
38+
39+
"@graphql-yoga/subscription": ["@graphql-yoga/[email protected]", "", { "dependencies": { "@graphql-yoga/typed-event-target": "^3.0.2", "@repeaterjs/repeater": "^3.0.4", "@whatwg-node/events": "^0.1.0", "tslib": "^2.8.1" } }, "sha512-xLGEataxCULjL9rlTCVFL1IW2E90TnDIL+mE4lZBi9X92jc6s+Q+jk6Ax3I98kryCJh0UMiwjit7CaIIczTiJg=="],
40+
41+
"@graphql-yoga/typed-event-target": ["@graphql-yoga/[email protected]", "", { "dependencies": { "@repeaterjs/repeater": "^3.0.4", "tslib": "^2.8.1" } }, "sha512-ZpJxMqB+Qfe3rp6uszCQoag4nSw42icURnBRfFYSOmTgEeOe4rD0vYlbA8spvCu2TlCesNTlEN9BLWtQqLxabA=="],
42+
43+
"@repeaterjs/repeater": ["@repeaterjs/[email protected]", "", {}, "sha512-Javneu5lsuhwNCryN+pXH93VPQ8g0dBX7wItHFgYiwQmzE1sVdg5tWHiOgHywzL2W21XQopa7IwIEnNbmeUJYA=="],
44+
45+
"@types/bun": ["@types/[email protected]", "", { "dependencies": { "bun-types": "1.2.5" } }, "sha512-w2OZTzrZTVtbnJew1pdFmgV99H0/L+Pvw+z1P67HaR18MHOzYnTYOi6qzErhK8HyT+DB782ADVPPE92Xu2/Opg=="],
46+
47+
"@types/node": ["@types/[email protected]", "", { "dependencies": { "undici-types": "~6.20.0" } }, "sha512-I6LPUvlRH+O6VRUqYOcMudhaIdUVWfsjnZavnsraHvpBwaEyMN29ry+0UVJhImYL16xsscu0aske3yA+uPOWfw=="],
48+
49+
"@types/ws": ["@types/[email protected]", "", { "dependencies": { "@types/node": "*" } }, "sha512-bd/YFLW+URhBzMXurx7lWByOu+xzU9+kb3RboOteXYDfW+tr+JZa99OyNmPINEGB/ahzKrEuc8rcv4gnpJmxTw=="],
50+
51+
"@whatwg-node/disposablestack": ["@whatwg-node/[email protected]", "", { "dependencies": { "@whatwg-node/promise-helpers": "^1.0.0", "tslib": "^2.6.3" } }, "sha512-LOtTn+JgJvX8WfBVJtF08TGrdjuFzGJc4mkP8EdDI8ADbvO7kiexYep1o8dwnt0okb0jYclCDXF13xU7Ge4zSw=="],
52+
53+
"@whatwg-node/events": ["@whatwg-node/[email protected]", "", { "dependencies": { "tslib": "^2.6.3" } }, "sha512-ApcWxkrs1WmEMS2CaLLFUEem/49erT3sxIVjpzU5f6zmVcnijtDSrhoK2zVobOIikZJdH63jdAXOrvjf6eOUNQ=="],
54+
55+
"@whatwg-node/fetch": ["@whatwg-node/[email protected]", "", { "dependencies": { "@whatwg-node/node-fetch": "^0.7.11", "urlpattern-polyfill": "^10.0.0" } }, "sha512-+yFJU3hmXPAHJULwx0VzCIsvr/H0lvbPvbOH3areOH3NAuCxCwaJsQ8w6/MwwMcvEWIynSsmAxoyaH04KeosPg=="],
56+
57+
"@whatwg-node/node-fetch": ["@whatwg-node/[email protected]", "", { "dependencies": { "@whatwg-node/disposablestack": "^0.0.6", "@whatwg-node/promise-helpers": "^1.2.5", "busboy": "^1.6.0", "tslib": "^2.6.3" } }, "sha512-GMCUrFq3gXQSgWMnEBMaQUxh1rd1vi3Kp4MRQT6UKbnRycm4QmUSxp8ZIySxLQ96cpyBvonEH0BYmdQe/pWy8A=="],
58+
59+
"@whatwg-node/promise-helpers": ["@whatwg-node/[email protected]", "", { "dependencies": { "tslib": "^2.6.3" } }, "sha512-486CouizxHXucj8Ky153DDragfkMcHtVEToF5Pn/fInhUUSiCmt9Q4JVBa6UK5q4RammFBtGQ4C9qhGlXU9YbA=="],
60+
61+
"@whatwg-node/server": ["@whatwg-node/[email protected]", "", { "dependencies": { "@envelop/instrumentation": "^1.0.0", "@whatwg-node/disposablestack": "^0.0.6", "@whatwg-node/fetch": "^0.10.5", "@whatwg-node/promise-helpers": "^1.2.3", "tslib": "^2.6.3" } }, "sha512-SKZjZAhQe8o34pDHUDFn5PV5Otq/gaj/A6AlQ6Sa4+A12YBO0znKKwfoCwGxv/BSRRx0zUqLdI8fZ0ui+EyUlw=="],
62+
63+
"bun-types": ["[email protected]", "", { "dependencies": { "@types/node": "*", "@types/ws": "~8.5.10" } }, "sha512-3oO6LVGGRRKI4kHINx5PIdIgnLRb7l/SprhzqXapmoYkFl5m4j6EvALvbDVuuBFaamB46Ap6HCUxIXNLCGy+tg=="],
64+
65+
"busboy": ["[email protected]", "", { "dependencies": { "streamsearch": "^1.1.0" } }, "sha512-8SFQbg/0hQ9xy3UNTB0YEnsNBbWfhf7RtnzpL7TkBiTBRfrQ9Fxcnz7VJsleJpyp6rVLvXiuORqjlHi5q+PYuA=="],
66+
67+
"cross-env": ["[email protected]", "", { "dependencies": { "cross-spawn": "^7.0.1" }, "bin": { "cross-env": "src/bin/cross-env.js", "cross-env-shell": "src/bin/cross-env-shell.js" } }, "sha512-+/HKd6EgcQCJGh2PSjZuUitQBQynKor4wrFbRg4DtAgS1aWO+gU52xpH7M9ScGgXSYmAVS9bIJ8EzuaGw0oNAw=="],
68+
69+
"cross-inspect": ["[email protected]", "", { "dependencies": { "tslib": "^2.4.0" } }, "sha512-Pcw1JTvZLSJH83iiGWt6fRcT+BjZlCDRVwYLbUcHzv/CRpB7r0MlSrGbIyQvVSNyGnbt7G4AXuyCiDR3POvZ1A=="],
70+
71+
"cross-spawn": ["[email protected]", "", { "dependencies": { "path-key": "^3.1.0", "shebang-command": "^2.0.0", "which": "^2.0.1" } }, "sha512-uV2QOWP2nWzsy2aMp8aRibhi9dlzF5Hgh5SHaB9OiTGEyDTiJJyx0uy51QXdyWbtAHNua4XJzUKca3OzKUd3vA=="],
72+
73+
"dset": ["[email protected]", "", {}, "sha512-2QF/g9/zTaPDc3BjNcVTGoBbXBgYfMTTceLaYcFJ/W9kggFUkhxD/hMEeuLKbugyef9SqAx8cpgwlIP/jinUTA=="],
74+
75+
"graphql": ["[email protected]", "", {}, "sha512-AjqGKbDGUFRKIRCP9tCKiIGHyriz2oHEbPIbEtcSLSs4YjReZOIPQQWek4+6hjw62H9QShXHyaGivGiYVLeYFQ=="],
76+
77+
"graphql-yoga": ["[email protected]", "", { "dependencies": { "@envelop/core": "^5.2.3", "@envelop/instrumentation": "^1.0.0", "@graphql-tools/executor": "^1.4.0", "@graphql-tools/schema": "^10.0.11", "@graphql-tools/utils": "^10.6.2", "@graphql-yoga/logger": "^2.0.1", "@graphql-yoga/subscription": "^5.0.3", "@whatwg-node/fetch": "^0.10.5", "@whatwg-node/promise-helpers": "^1.2.4", "@whatwg-node/server": "^0.10.1", "dset": "^3.1.4", "lru-cache": "^10.0.0", "tslib": "^2.8.1" }, "peerDependencies": { "graphql": "^15.2.0 || ^16.0.0" } }, "sha512-ZXhIoAPCV2K2ozwpxDL1ZXhhI2SvIp3hJMaSRaHcojLGE9w9iV8oYGPnZKcV5eisF3VE13RcIF4Ys6TTkU338Q=="],
78+
79+
"isexe": ["[email protected]", "", {}, "sha512-RHxMLp9lnKHGHRng9QFhRCMbYAcVpn69smSGcq3f36xjgVVWThj4qqLbTLlq7Ssj8B+fIQ1EuCEGI2lKsyQeIw=="],
80+
81+
"lru-cache": ["[email protected]", "", {}, "sha512-JNAzZcXrCt42VGLuYz0zfAzDfAvJWW6AfYlDBQyDV5DClI2m5sAmK+OIO7s59XfsRsWHp02jAJrRadPRGTt6SQ=="],
82+
83+
"path-key": ["[email protected]", "", {}, "sha512-ojmeN0qd+y0jszEtoY48r0Peq5dwMEkIlCOu6Q5f41lfkswXuKtYrhgoTpLnyIcHm24Uhqx+5Tqm2InSwLhE6Q=="],
84+
85+
"shebang-command": ["[email protected]", "", { "dependencies": { "shebang-regex": "^3.0.0" } }, "sha512-kHxr2zZpYtdmrN1qDjrrX/Z1rR1kG8Dx+gkpK1G4eXmvXswmcE1hTWBWYUzlraYw1/yZp6YuDY77YtvbN0dmDA=="],
86+
87+
"shebang-regex": ["[email protected]", "", {}, "sha512-7++dFhtcx3353uBaq8DDR4NuxBetBzC7ZQOhmTQInHEd6bSrXdiEyzCvG07Z44UYdLShWUyXt5M/yhz8ekcb1A=="],
88+
89+
"streamsearch": ["[email protected]", "", {}, "sha512-Mcc5wHehp9aXz1ax6bZUyY5afg9u2rv5cqQI3mRrYkGC8rW2hM02jWuwjtL++LS5qinSyhj2QfLyNsuc+VsExg=="],
90+
91+
"tslib": ["[email protected]", "", {}, "sha512-oJFu94HQb+KVduSUQL7wnpmqnfmLsOA/nAh6b6EH0wCEoK0/mPeXU6c3wKDV83MkOuHPRHtSXKKU99IBazS/2w=="],
92+
93+
"typescript": ["[email protected]", "", { "bin": { "tsc": "bin/tsc", "tsserver": "bin/tsserver" } }, "sha512-aJn6wq13/afZp/jT9QZmwEjDqqvSGp1VT5GVg+f/t6/oVyrgXM6BY1h9BRh/O5p3PlUPAe+WuiEZOmb/49RqoQ=="],
94+
95+
"undici-types": ["[email protected]", "", {}, "sha512-Ny6QZ2Nju20vw1SRHe3d9jVu6gJ+4e3+MMpqu7pqE5HT6WsTSlce++GQmK5UXS8mzV8DSYHrQH+Xrf2jVcuKNg=="],
96+
97+
"urlpattern-polyfill": ["[email protected]", "", {}, "sha512-H/A06tKD7sS1O1X2SshBVeA5FLycRpjqiBeqGKmBwBDBy28EnRjORxTNe269KSSr5un5qyWi1iL61wLxpd+ZOg=="],
98+
99+
"which": ["[email protected]", "", { "dependencies": { "isexe": "^2.0.0" }, "bin": { "node-which": "./bin/node-which" } }, "sha512-BLI3Tl1TW3Pvl70l3yq3Y64i+awpwXqsGBYWkkqMtnbXgrMD+yj7rhW0kuEDxzJaYXGjEW5ogapKNMEKNMjibA=="],
100+
}
101+
}
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
{
2+
"name": "graphql-yoga",
3+
"version": "0.1.0",
4+
"private": true,
5+
"type": "module",
6+
"module": "server.ts",
7+
"scripts": {
8+
"dev": "bun run server.ts",
9+
"build": "bun build --target=bun --entrypoints ./server.ts --outfile=./out/server.js",
10+
"typecheck": "tsc"
11+
},
12+
"dependencies": {
13+
"cross-env": "^7.0.3",
14+
"graphql": "^16.10.0",
15+
"graphql-yoga": "^5.13.1"
16+
},
17+
"devDependencies": {
18+
"@types/bun": "latest",
19+
"typescript": "^5.8.2"
20+
},
21+
"peerDependencies": {
22+
"typescript": "^5"
23+
}
24+
}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
#! /bin/sh
2+
export PATH="/opt/bin:${PATH}"
3+
exec bun run server.js
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
import { createSchema } from 'graphql-yoga'
2+
3+
const typeDefs = /* GraphQL */ `
4+
type Query {
5+
hello(addition: String): String!
6+
}
7+
type Subscription {
8+
stream(addition: String): String!
9+
}
10+
`
11+
const resolvers = {
12+
Query: {
13+
hello: async (_: any, { addition }: { addition: string }) => {
14+
console.log(`Received addition: ${addition}`);
15+
return `Hello, ${addition || 'Lambda!'}!`
16+
},
17+
},
18+
Subscription: {
19+
stream: {
20+
subscribe: async function* (_: any, { addition }: { addition: string }) {
21+
const message = `This is streaming from Lambda! ${addition || ''}\n`;
22+
process.stdout.write("Streaming: ");
23+
for (const char of message) {
24+
process.stdout.write(char);
25+
yield char;
26+
// Sleep for 100ms between characters
27+
await new Promise(resolve => setTimeout(resolve, 100));
28+
}
29+
},
30+
resolve: (payload: any) => payload
31+
},
32+
}
33+
}
34+
35+
export const schema = createSchema({
36+
typeDefs,
37+
resolvers
38+
})
39+
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import { createYoga } from 'graphql-yoga'
2+
import { schema } from './schema.js'
3+
4+
// Create a Yoga instance with a GraphQL schema.
5+
const yoga = createYoga({ schema })
6+
7+
// Pass it into a server to hook into request handlers.
8+
const server = Bun.serve({
9+
fetch: yoga
10+
})
11+
12+
// Start the server and you're done!
13+
console.info(
14+
`Server is running on ${new URL(
15+
yoga.graphqlEndpoint,
16+
`http://${server.hostname}:${server.port}`
17+
)}`
18+
)
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
{
2+
"compilerOptions": {
3+
// Environment setup & latest features
4+
"lib": ["esnext"],
5+
"target": "ESNext",
6+
"module": "ESNext",
7+
"moduleDetection": "force",
8+
"jsx": "react-jsx",
9+
"allowJs": true,
10+
11+
// Bundler mode
12+
"moduleResolution": "bundler",
13+
"allowImportingTsExtensions": true,
14+
"verbatimModuleSyntax": true,
15+
"noEmit": true,
16+
17+
// Best practices
18+
"strict": true,
19+
"skipLibCheck": true,
20+
"noFallthroughCasesInSwitch": true,
21+
"noUncheckedIndexedAccess": true,
22+
23+
// Some stricter flags (disabled by default)
24+
"noUnusedLocals": false,
25+
"noUnusedParameters": false,
26+
"noPropertyAccessFromIndexSignature": false
27+
}
28+
}
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
AWSTemplateFormatVersion: '2010-09-09'
2+
Transform: AWS::Serverless-2016-10-31
3+
Description: >
4+
Bun graphql response streaming
5+
6+
# More info about Globals: https://github.com/awslabs/serverless-application-model/blob/master/docs/globals.rst
7+
Globals:
8+
Function:
9+
Timeout: 60
10+
11+
Resources:
12+
BunGraphqlFunction:
13+
Type: AWS::Serverless::Function
14+
Metadata:
15+
BuildMethod: makefile
16+
Properties:
17+
CodeUri: app/
18+
Handler: run.sh
19+
Runtime: provided.al2023
20+
Architectures:
21+
- arm64
22+
MemorySize: 256
23+
Environment:
24+
Variables:
25+
AWS_LAMBDA_EXEC_WRAPPER: /opt/bootstrap
26+
AWS_LWA_INVOKE_MODE: response_stream
27+
PORT: 3000
28+
Layers:
29+
- !Sub arn:aws:lambda:${AWS::Region}:753240598075:layer:LambdaAdapterLayerArm64:24
30+
- !Sub arn:aws:lambda:us-east-1:582637575117:layer:BunRuntimeArm64:1
31+
FunctionUrlConfig:
32+
AuthType: NONE
33+
InvokeMode: RESPONSE_STREAM
34+
35+
Outputs:
36+
BunGraphqlFunctionUrl:
37+
Description: "Function URL for Bun Graphql function"
38+
Value: !Join
39+
- ''
40+
- - !GetAtt BunGraphqlFunctionUrl.FunctionUrl
41+
- 'graphql'
42+
BunGraphqlFunction:
43+
Description: "Bun Graphql Lambda Function ARN"
44+
Value: !GetAtt BunGraphqlFunction.Arn

0 commit comments

Comments
 (0)