@stacksjs/cloud 0.58.52 → 0.58.55

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -1800,8 +1800,8 @@ import {EcsTask} from "aws-cdk-lib/aws-events-targets";
1800
1800
 
1801
1801
  class QueueStack {
1802
1802
  constructor(scope, props) {
1803
- const rule = new Rule(scope, "Rule", {
1804
- ruleName: `${props.appName}-${props.appEnv}-queue`,
1803
+ const rule = new Rule(scope, "QueueRule", {
1804
+ ruleName: `${props.appName}-${props.appEnv}-queue-rule`,
1805
1805
  schedule: Schedule.cron({ minute: "*", hour: "*", month: "*", weekDay: "*", year: "*" })
1806
1806
  });
1807
1807
  rule.addTarget(new EcsTask({
@@ -1898,246 +1898,7 @@ class Cloud extends Stack2 {
1898
1898
  });
1899
1899
  }
1900
1900
  }
1901
- // /home/runner/work/stacks/stacks/storage/framework/core/router/src/middleware.ts
1902
- import {appPath} from "@stacksjs/path";
1903
- async function importMiddlewares(directory) {
1904
- return [directory];
1905
- }
1906
- var middlewares = await importMiddlewares(appPath("middleware"));
1907
- // /home/runner/work/stacks/stacks/storage/framework/core/router/src/request.ts
1908
- class Request {
1909
- query = {};
1910
- params = null;
1911
- addQuery(url) {
1912
- this.query = Object.fromEntries(url.searchParams);
1913
- }
1914
- get(element) {
1915
- return this.query[element];
1916
- }
1917
- all() {
1918
- return this.query;
1919
- }
1920
- has(element) {
1921
- return element in this.query;
1922
- }
1923
- isEmpty() {
1924
- return Object.keys(this.query).length === 0;
1925
- }
1926
- extractParamsFromRoute(routePattern, pathname) {
1927
- const pattern = new RegExp(`^${routePattern.replace(/:(\w+)/g, (match2, paramName) => `(?<${paramName}>\\w+)`)}\$`);
1928
- const match = pattern.exec(pathname);
1929
- if (match?.groups)
1930
- this.params = match?.groups;
1931
- }
1932
- getParams(key) {
1933
- return this.params ? this.params[key] || null : null;
1934
- }
1935
- }
1936
- var request = new Request;
1937
- // /home/runner/work/stacks/stacks/storage/framework/core/router/src/server.ts
1938
- import {extname} from "path";
1939
- import {URL} from "url";
1940
- async function serverResponse(req) {
1941
- console.log("serverResponse", JSON.stringify(req));
1942
- const routesList = await route.getRoutes();
1943
- const url = new URL(req.url);
1944
- const foundRoute = routesList.find((route2) => {
1945
- const pattern = new RegExp(`^${route2.uri.replace(/:\w+/g, "\\w+")}\$`);
1946
- return pattern.test(url.pathname);
1947
- });
1948
- if (!foundRoute)
1949
- return new Response("Pretty 404 page coming soon", { status: 404 });
1950
- addRouteParamsAndQuery(url, foundRoute);
1951
- executeMiddleware(foundRoute);
1952
- return execute(foundRoute, req, { statusCode: foundRoute?.statusCode });
1953
- }
1954
- var addRouteParamsAndQuery = function(url, route2) {
1955
- if (!isObjectNotEmpty(url.searchParams))
1956
- request.addQuery(url);
1957
- request.extractParamsFromRoute(route2.uri, url.pathname);
1958
- };
1959
- var executeMiddleware = function(route2) {
1960
- const { middleware: middleware2 = null } = route2;
1961
- if (middleware2 && middlewares && isObjectNotEmpty(middlewares)) {
1962
- if (isString(middleware2)) {
1963
- const middlewareItem = middlewares.find((middlewareItem2) => {
1964
- return middlewareItem2.name === middleware2;
1965
- });
1966
- if (middlewareItem)
1967
- middlewareItem.handle();
1968
- } else {
1969
- middleware2.forEach((m) => {
1970
- const middlewareItem = middlewares.find((middlewareItem2) => {
1971
- return middlewareItem2.name === m;
1972
- });
1973
- if (middlewareItem)
1974
- middlewareItem.handle();
1975
- });
1976
- }
1977
- }
1978
- };
1979
- var execute = function(route2, request3, { statusCode }) {
1980
- if (!statusCode)
1981
- statusCode = 200;
1982
- if (route2?.method === "GET" && (statusCode === 301 || statusCode === 302)) {
1983
- const callback = String(route2.callback);
1984
- const response = Response.redirect(callback, statusCode);
1985
- return noCache(response);
1986
- }
1987
- if (route2?.method !== request3.method)
1988
- return new Response("Method not allowed", { status: 405 });
1989
- if (isString(route2.callback) && extname(route2.callback) === ".html") {
1990
- try {
1991
- const fileContent = Bun.file(route2.callback);
1992
- return new Response(fileContent, { headers: { "Content-Type": "text/html" } });
1993
- } catch (error) {
1994
- return new Response("Error reading the HTML file", { status: 500 });
1995
- }
1996
- }
1997
- if (isString(route2.callback))
1998
- return new Response(route2.callback);
1999
- if (isFunction(route2.callback)) {
2000
- const result = route2.callback();
2001
- return new Response(JSON.stringify(result));
2002
- }
2003
- if (isObject(route2.callback))
2004
- return new Response(JSON.stringify(route2.callback));
2005
- return new Response("Unknown callback type.", { status: 500 });
2006
- };
2007
- var noCache = function(response) {
2008
- response.headers.set("Cache-Control", "no-store, no-cache, must-revalidate, proxy-revalidate");
2009
- response.headers.set("Pragma", "no-cache");
2010
- response.headers.set("Expires", "0");
2011
- return response;
2012
- };
2013
- var isString = function(val) {
2014
- return typeof val === "string";
2015
- };
2016
- var isObjectNotEmpty = function(obj) {
2017
- return Object.keys(obj).length > 0;
2018
- };
2019
- var isFunction = function(val) {
2020
- return typeof val === "function";
2021
- };
2022
- var isObject = function(val) {
2023
- return val !== null && typeof val === "object" && !Array.isArray(val);
2024
- };
2025
- // /home/runner/work/stacks/stacks/storage/framework/core/router/src/router.ts
2026
- import {projectPath} from "@stacksjs/path";
2027
-
2028
- class Router {
2029
- routes = [];
2030
- addRoute(method, uri, callback, statusCode) {
2031
- const name = uri.replace(/\//g, ".").replace(/:/g, "");
2032
- const pattern = new RegExp(`^${uri.replace(/:[a-zA-Z]+/g, (_match) => {
2033
- return "([a-zA-Z0-9-]+)";
2034
- })}\$`);
2035
- let routeCallback;
2036
- if (typeof callback === "string" || typeof callback === "object") {
2037
- routeCallback = () => callback;
2038
- } else {
2039
- routeCallback = callback;
2040
- }
2041
- this.routes.push({
2042
- name,
2043
- method,
2044
- url: uri,
2045
- uri,
2046
- callback: routeCallback,
2047
- pattern,
2048
- statusCode,
2049
- paramNames: []
2050
- });
2051
- }
2052
- get(path7, callback) {
2053
- this.addRoute("GET", path7, callback, 200);
2054
- return this;
2055
- }
2056
- post(path7, callback) {
2057
- this.addRoute("POST", path7, callback, 201);
2058
- return this;
2059
- }
2060
- view(path7, callback) {
2061
- this.addRoute("GET", path7, callback, 200);
2062
- return this;
2063
- }
2064
- redirect(path7, callback, _status) {
2065
- this.addRoute("GET", path7, callback, 302);
2066
- return this;
2067
- }
2068
- delete(path7, callback) {
2069
- this.addRoute("DELETE", path7, callback, 204);
2070
- return this;
2071
- }
2072
- patch(path7, callback) {
2073
- this.addRoute("PATCH", path7, callback, 202);
2074
- return this;
2075
- }
2076
- put(path7, callback) {
2077
- this.addRoute("PUT", path7, callback, 202);
2078
- return this;
2079
- }
2080
- group(options, callback) {
2081
- let cb;
2082
- if (typeof options === "function") {
2083
- cb = options;
2084
- options = {};
2085
- } else {
2086
- if (!callback)
2087
- throw new Error("Missing callback function for route group.");
2088
- cb = callback;
2089
- }
2090
- const { prefix = "", middleware: middleware2 = [] } = options;
2091
- const originalRoutes = this.routes;
2092
- this.routes = [];
2093
- cb();
2094
- this.routes.forEach((r) => {
2095
- r.uri = `${prefix}${r.uri}`;
2096
- if (middleware2.length)
2097
- r.middleware = middleware2;
2098
- originalRoutes.push(r);
2099
- return this;
2100
- });
2101
- this.routes = originalRoutes;
2102
- return this;
2103
- }
2104
- name(name) {
2105
- this.routes[this.routes.length - 1].name = name;
2106
- return this;
2107
- }
2108
- middleware(middleware2) {
2109
- this.routes[this.routes.length - 1].middleware = middleware2;
2110
- return this;
2111
- }
2112
- prefix(prefix) {
2113
- this.routes[this.routes.length - 1].prefix = prefix;
2114
- return this;
2115
- }
2116
- async getRoutes() {
2117
- await import(projectPath("routes/api.ts"));
2118
- return this.routes;
2119
- }
2120
- }
2121
- var route = new Router;
2122
- // src/runtime/server.ts
2123
- var server_default = {
2124
- async fetch(request4, server2) {
2125
- console.log("Request", {
2126
- url: request4.url,
2127
- method: request4.method,
2128
- headers: request4.headers.toJSON(),
2129
- body: request4.body ? await request4.text() : null
2130
- });
2131
- if (server2.upgrade(request4)) {
2132
- console.log("WebSocket upgraded");
2133
- return;
2134
- }
2135
- return serverResponse(request4);
2136
- },
2137
- websocket: {}
2138
- };
2139
1901
  export {
2140
- server_default as server,
2141
1902
  purchaseDomain,
2142
1903
  isFirstDeployment,
2143
1904
  isFailedState,
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@stacksjs/cloud",
3
3
  "type": "module",
4
- "version": "0.58.52",
4
+ "version": "0.58.55",
5
5
  "description": "The Stacks cloud/serverless integration & implementation.",
6
6
  "author": "Chris Breuer",
7
7
  "license": "MIT",
@@ -55,19 +55,19 @@
55
55
  "prepublishOnly": "bun run build"
56
56
  },
57
57
  "peerDependencies": {
58
- "@aws-sdk/client-bedrock": "^3.504.0",
59
- "@aws-sdk/client-cloudformation": "^3.504.0",
60
- "@aws-sdk/client-cloudfront": "^3.504.0",
61
- "@aws-sdk/client-cloudwatch-logs": "^3.504.0",
62
- "@aws-sdk/client-ec2": "^3.504.0",
63
- "@aws-sdk/client-efs": "^3.504.0",
64
- "@aws-sdk/client-iam": "^3.504.0",
65
- "@aws-sdk/client-lambda": "^3.504.0",
66
- "@aws-sdk/client-route-53-domains": "^3.504.0",
67
- "@aws-sdk/client-s3": "^3.504.0",
68
- "@aws-sdk/client-ses": "^3.504.0",
69
- "@aws-sdk/client-sesv2": "^3.504.0",
70
- "@aws-sdk/client-ssm": "^3.504.0",
58
+ "@aws-sdk/client-bedrock": "^3.507.0",
59
+ "@aws-sdk/client-cloudformation": "^3.507.0",
60
+ "@aws-sdk/client-cloudfront": "^3.507.0",
61
+ "@aws-sdk/client-cloudwatch-logs": "^3.508.0",
62
+ "@aws-sdk/client-ec2": "^3.507.0",
63
+ "@aws-sdk/client-efs": "^3.507.0",
64
+ "@aws-sdk/client-iam": "^3.507.0",
65
+ "@aws-sdk/client-lambda": "^3.507.0",
66
+ "@aws-sdk/client-route-53-domains": "^3.507.0",
67
+ "@aws-sdk/client-s3": "^3.507.0",
68
+ "@aws-sdk/client-ses": "^3.507.0",
69
+ "@aws-sdk/client-sesv2": "^3.507.0",
70
+ "@aws-sdk/client-ssm": "^3.507.0",
71
71
  "@stacksjs/config": "latest",
72
72
  "@stacksjs/env": "latest",
73
73
  "@stacksjs/logging": "latest",
@@ -79,20 +79,20 @@
79
79
  "@stacksjs/validation": "latest"
80
80
  },
81
81
  "dependencies": {
82
- "@aws-sdk/client-bedrock": "^3.504.0",
83
- "@aws-sdk/client-cloudformation": "^3.504.0",
84
- "@aws-sdk/client-cloudfront": "^3.504.0",
85
- "@aws-sdk/client-cloudwatch-logs": "^3.504.0",
86
- "@aws-sdk/client-dynamodb": "3.506.0",
87
- "@aws-sdk/client-ec2": "^3.504.0",
88
- "@aws-sdk/client-efs": "^3.504.0",
89
- "@aws-sdk/client-iam": "^3.504.0",
90
- "@aws-sdk/client-lambda": "^3.504.0",
91
- "@aws-sdk/client-route-53-domains": "^3.504.0",
92
- "@aws-sdk/client-s3": "^3.504.0",
93
- "@aws-sdk/client-ses": "^3.504.0",
94
- "@aws-sdk/client-sesv2": "^3.504.0",
95
- "@aws-sdk/client-ssm": "^3.504.0",
82
+ "@aws-sdk/client-bedrock": "^3.507.0",
83
+ "@aws-sdk/client-cloudformation": "^3.507.0",
84
+ "@aws-sdk/client-cloudfront": "^3.507.0",
85
+ "@aws-sdk/client-cloudwatch-logs": "^3.508.0",
86
+ "@aws-sdk/client-dynamodb": "3.507.0",
87
+ "@aws-sdk/client-ec2": "^3.507.0",
88
+ "@aws-sdk/client-efs": "^3.507.0",
89
+ "@aws-sdk/client-iam": "^3.507.0",
90
+ "@aws-sdk/client-lambda": "^3.507.0",
91
+ "@aws-sdk/client-route-53-domains": "^3.507.0",
92
+ "@aws-sdk/client-s3": "^3.507.0",
93
+ "@aws-sdk/client-ses": "^3.507.0",
94
+ "@aws-sdk/client-sesv2": "^3.507.0",
95
+ "@aws-sdk/client-ssm": "^3.507.0",
96
96
  "@stacksjs/config": "latest",
97
97
  "@stacksjs/dns": "latest",
98
98
  "@stacksjs/env": "latest",
@@ -113,7 +113,7 @@
113
113
  "@stacksjs/development": "latest",
114
114
  "@stacksjs/env": "latest",
115
115
  "jszip": "^3.10.1",
116
- "oclif": "^4.4.4",
116
+ "oclif": "^4.4.7",
117
117
  "source-map-support": "^0.5.21"
118
118
  }
119
119
  }
@@ -1,15 +1,15 @@
1
1
  {
2
2
  "name": "aws-sdk-layer",
3
- "version": "0.58.49",
3
+ "version": "0.58.53",
4
4
  "lockfileVersion": 3,
5
5
  "requires": true,
6
6
  "packages": {
7
7
  "": {
8
8
  "name": "aws-sdk-layer",
9
- "version": "0.58.49",
9
+ "version": "0.58.53",
10
10
  "license": "ISC",
11
11
  "dependencies": {
12
- "aws-sdk": "^2.1550.0"
12
+ "aws-sdk": "^2.1552.0"
13
13
  }
14
14
  },
15
15
  "node_modules/available-typed-arrays": {
@@ -24,9 +24,9 @@
24
24
  }
25
25
  },
26
26
  "node_modules/aws-sdk": {
27
- "version": "2.1550.0",
28
- "resolved": "https://registry.npmjs.org/aws-sdk/-/aws-sdk-2.1550.0.tgz",
29
- "integrity": "sha512-abkbOeaL7iV085UqO8Y7/Ep7VYONK32chhKejhMbPYSqTp2YgNeqOSQfSaVZWeWCwqJxujEyoXFGTNgTt46D0g==",
27
+ "version": "2.1552.0",
28
+ "resolved": "https://registry.npmjs.org/aws-sdk/-/aws-sdk-2.1552.0.tgz",
29
+ "integrity": "sha512-sRuzlCeSHXUsdLqsV/E+nPrgBn1EI3BoA38D5qfNMRcPTd9j4G8M4AyMymKyNxLoWOKLqz7xFBa801MHflGwEg==",
30
30
  "dependencies": {
31
31
  "buffer": "4.9.2",
32
32
  "events": "1.1.1",
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "aws-sdk-layer",
3
- "version": "0.58.52",
3
+ "version": "0.58.55",
4
4
  "description": "",
5
5
  "author": "",
6
6
  "license": "ISC",
@@ -10,6 +10,6 @@
10
10
  "test": "echo \"Error: no test specified\" && exit 1"
11
11
  },
12
12
  "dependencies": {
13
- "aws-sdk": "^2.1550.0"
13
+ "aws-sdk": "^2.1552.0"
14
14
  }
15
15
  }
@@ -1,8 +1,8 @@
1
+ import type { Cluster, TaskDefinition } from 'aws-cdk-lib'
1
2
  import { aws_ec2 as ec2 } from 'aws-cdk-lib'
3
+ import type { Construct } from 'constructs'
2
4
  import { Rule, Schedule } from 'aws-cdk-lib/aws-events'
3
5
  import { EcsTask } from 'aws-cdk-lib/aws-events-targets'
4
- import type { Cluster, TaskDefinition } from 'aws-cdk-lib/aws-ecs'
5
- import type { Construct } from 'constructs'
6
6
  import type { NestedCloudProps } from '../types'
7
7
 
8
8
  export interface QueueStackProps extends NestedCloudProps {
@@ -12,11 +12,10 @@ export interface QueueStackProps extends NestedCloudProps {
12
12
 
13
13
  export class QueueStack {
14
14
  constructor(scope: Construct, props: QueueStackProps) {
15
- const rule = new Rule(scope, 'Rule', {
15
+ const rule = new Rule(scope, 'QueueRule', {
16
16
  // schedule to run every second
17
- ruleName: `${props.appName}-${props.appEnv}-queue`,
17
+ ruleName: `${props.appName}-${props.appEnv}-queue-rule`,
18
18
  schedule: Schedule.cron({ minute: '*', hour: '*', month: '*', weekDay: '*', year: '*' }),
19
- // schedule: Schedule.cron({ minute: '0', hour: '0' }), // For example, every day at midnight
20
19
  })
21
20
 
22
21
  rule.addTarget(new EcsTask({
@@ -37,9 +36,11 @@ export class QueueStack {
37
36
  ],
38
37
  },
39
38
  ],
39
+
40
40
  retryAttempts: 3,
41
+
41
42
  subnetSelection: {
42
- subnetType: ec2.SubnetType.PUBLIC,
43
+ subnetType: ec2.SubnetType.PUBLIC, // SubnetType.PRIVATE_WITH_EGRESS
43
44
  },
44
45
  }))
45
46
  }
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "stacks-router-layer",
3
- "version": "0.58.52",
3
+ "version": "0.58.55",
4
4
  "description": "",
5
5
  "author": "",
6
6
  "license": "MIT",
@@ -10,6 +10,6 @@
10
10
  "test": "echo \"Error: no test specified\" && exit 1"
11
11
  },
12
12
  "dependencies": {
13
- "@stacksjs/router": "^0.58.51"
13
+ "@stacksjs/router": "^0.58.53"
14
14
  }
15
15
  }
package/src/index.ts CHANGED
@@ -1,3 +1,2 @@
1
1
  export * from './helpers'
2
2
  export * from './cloud'
3
- export { default as server } from './runtime/server'
@@ -1,116 +0,0 @@
1
- <!-- Thank you Bun ❤️ -->
2
-
3
- # bun-lambda
4
-
5
- A custom runtime layer that runs Bun on AWS Lambda.
6
-
7
- ## Setup
8
-
9
- First, you will need to deploy the layer to your AWS account. Clone this repository and run the `publish-layer` script to get started. Note: the `publish-layer` script also builds the layer.
10
-
11
- ```sh
12
- git clone git@github.com:oven-sh/bun.git
13
- cd packages/bun-lambda
14
- bun install
15
- bun run publish-layer
16
- ```
17
-
18
- ## Usage
19
-
20
- Once you publish the layer to your AWS account, you can create a Lambda function that uses the layer.
21
-
22
- ### Step 1: Create a Bun Lambda handler function
23
-
24
- In addition to providing the Bun runtime itself, the Bun Lambda Layer also provides an event transformation so you can write your Bun function in a classic Bun server format. This allows you to also run your Lambda function as a local Bun server with `bun run <handler-name>.ts`. Here are some examples of how to write a Bun Lambda function:
25
-
26
- #### HTTP Event Example
27
-
28
- When an event is triggered from [API Gateway](https://docs.aws.amazon.com/lambda/latest/dg/services-apigateway.html), the layer transforms the event payload into a [`Request`](https://developer.mozilla.org/en-US/docs/Web/API/Request). This means you can test your Lambda function locally using `bun run`, without any code changes.
29
-
30
- ```ts
31
- export default {
32
- async fetch(request: Request): Promise<Response> {
33
- console.log(request.headers.get('x-amzn-function-arn'))
34
- // ...
35
- return new Response('Hello from Lambda!', {
36
- status: 200,
37
- headers: {
38
- 'Content-Type': 'text/plain',
39
- },
40
- })
41
- },
42
- }
43
- ```
44
-
45
- #### Non-HTTP Event Example
46
-
47
- For non-HTTP events — S3, SQS, EventBridge, etc. — the event payload is the body of the [`Request`](https://developer.mozilla.org/en-US/docs/Web/API/Request).
48
-
49
- ```ts
50
- export default {
51
- async fetch(request: Request): Promise<Response> {
52
- const event = await request.json()
53
- // ...
54
- return new Response()
55
- },
56
- }
57
- ```
58
-
59
- ### Step 2: Build the Bun handler
60
-
61
- The final step is to upload your Bun handler. You can technically write the handler directly in the console if you wish, but if you want a full development environment, use the Bun toolkit. There are several ways you can choose to build and manage your artifacts, but follow these steps for a simple approach:
62
-
63
- 1. Run `bun build <handler-entry>.[ts|js] --outfile /dist/handler.js`
64
- 2. Zip the `/dist` folder
65
-
66
- ### Step 3: Create the Lambda function on AWS
67
-
68
- Once you've written your Lambda function, you need to configure a new Lambda function to use Bun. The following steps apply to configuring in the console, CloudFormation, CDK, Terraform, or any other configuration management option for AWS:
69
-
70
- 1. Create the Lambda function
71
- 2. Set the Runtime to custom with Amazon Linux 2
72
- 3. Set the handler to <handler-file-name>.fetch (e.g. if your bundled Bun handler is at `handler.js`, set the handler as `handler.fetch`)
73
- 4. Set the architecture to whichever architecture you configured when you built/deployed the Lambda Layer
74
- 5. Attach the Lambda Layer to your new function
75
- 6. Upload the zip file from step 2. You can do this in the console directly, upload to S3 and set that as the location for the handler file in Lambda, or use something like CDK to manage this for you.
76
-
77
- ## API
78
-
79
- ### `bun run build-layer`
80
-
81
- Builds a Lambda layer for Bun and saves it to a `.zip` file.
82
-
83
- | Flag | Description | Default |
84
- | ----------- | -------------------------------------------------------------------- | ---------------------- |
85
- | `--arch` | The architecture, either: "x64" or "aarch64" | aarch64 |
86
- | `--release` | The release of Bun, either: "latest", "canary", or a release "x.y.z" | latest |
87
- | `--output` | The path to write the layer as a `.zip`. | ./bun-lambda-layer.zip |
88
-
89
- Example:
90
-
91
- ```sh
92
- bun run build-layer -- \
93
- --arch x64 \
94
- --release canary \
95
- --output /path/to/layer.zip
96
- ```
97
-
98
- ### `bun run publish-layer`
99
-
100
- Builds a Lambda layer for Bun then publishes it to your AWS account.
101
-
102
- | Flag | Description | Default |
103
- | ---------- | ----------------------------------------- | ------- |
104
- | `--layer` | The layer name. | bun |
105
- | `--region` | The region name, or "\*" for all regions. | |
106
- | `--public` | If the layer should be public. | false |
107
-
108
- Example:
109
-
110
- ```sh
111
- bun run publish-layer -- \
112
- --arch aarch64 \
113
- --release latest \
114
- --output /path/to/layer.zip \
115
- --region us-east-1
116
- ```
@@ -1,3 +0,0 @@
1
- #! /bin/sh
2
- export BUN_INSTALL_CACHE_DIR=/tmp/bun/cache
3
- exec /opt/bun --cwd $LAMBDA_TASK_ROOT /opt/runtime.ts
@@ -1,36 +0,0 @@
1
- /* eslint-disable no-console */
2
- import type { Server } from 'bun'
3
-
4
- // import type { Server } from 'bun'
5
-
6
- export default {
7
- async fetch(request: Request, server: Server): Promise<Response | undefined> {
8
- console.log('Request', {
9
- url: request.url,
10
- method: request.method,
11
- headers: request.headers.toJSON(),
12
- body: request.body ? await request.text() : null,
13
- })
14
- if (server.upgrade(request)) {
15
- console.log('WebSocket upgraded')
16
- return
17
- }
18
- return new Response('Hello from Stacks on Lambda!', {
19
- status: 200,
20
- headers: {
21
- 'Content-Type': 'text/plain;charset=utf-8',
22
- },
23
- })
24
- },
25
- websocket: {
26
- // async open(ws: ServerWebSocket): Promise<void> {
27
- // console.log('WebSocket opened')
28
- // },
29
- // async message(ws: ServerWebSocket, message: string): Promise<void> {
30
- // console.log('WebSocket message', message)
31
- // },
32
- // async close(ws: ServerWebSocket, code: number, reason?: string): Promise<void> {
33
- // console.log('WebSocket closed', { code, reason })
34
- // },
35
- },
36
- }