@actuallyjamez/elysian 0.2.1

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 ADDED
@@ -0,0 +1,58 @@
1
+ /**
2
+ * elysian - Automatic Lambda bundler for Elysia with API Gateway integration
3
+ *
4
+ * Main library exports for use in configuration and lambda files.
5
+ */
6
+ import Elysia from "elysia";
7
+ import { openapi } from "@elysiajs/openapi";
8
+ // Re-export config utilities
9
+ export { defineConfig } from "./core/config";
10
+ // Re-export type utilities from Elysia
11
+ export { t } from "elysia";
12
+ // Re-export runtime for convenience
13
+ export { createHandler } from "./runtime/adapter";
14
+ /**
15
+ * Default OpenAPI configuration for lambdas
16
+ * Can be overridden via config file
17
+ */
18
+ let openApiConfig = {
19
+ title: "API",
20
+ version: "1.0.0",
21
+ description: "",
22
+ };
23
+ /**
24
+ * Set the OpenAPI configuration (called by build process)
25
+ */
26
+ export function setOpenApiConfig(config) {
27
+ openApiConfig = { ...openApiConfig, ...config };
28
+ }
29
+ /**
30
+ * Create a new Elysia instance pre-configured for Lambda use
31
+ *
32
+ * This is the main entry point for defining Lambda routes.
33
+ * The returned Elysia instance has OpenAPI support built-in.
34
+ *
35
+ * @example
36
+ * ```ts
37
+ * import { createLambda, t } from "@actuallyjamez/elysian";
38
+ *
39
+ * export default createLambda()
40
+ * .get("/hello", () => "Hello World", {
41
+ * response: t.String(),
42
+ * })
43
+ * .get("/users/:id", ({ params }) => getUser(params.id), {
44
+ * params: t.Object({ id: t.String() }),
45
+ * });
46
+ * ```
47
+ */
48
+ export function createLambda() {
49
+ return new Elysia().use(openapi({
50
+ documentation: {
51
+ info: {
52
+ title: openApiConfig.title,
53
+ version: openApiConfig.version,
54
+ description: openApiConfig.description,
55
+ },
56
+ },
57
+ }));
58
+ }
@@ -0,0 +1,32 @@
1
+ /**
2
+ * Runtime adapter for AWS Lambda
3
+ *
4
+ * This module provides the Lambda handler creation function
5
+ * that bridges Elysia apps to AWS Lambda via Hono.
6
+ */
7
+ import type { AnyElysia } from "elysia";
8
+ import { type LambdaEvent, type LambdaContext } from "hono/aws-lambda";
9
+ /**
10
+ * Lambda handler type compatible with API Gateway v2
11
+ */
12
+ export type LambdaHandler = (event: LambdaEvent, context?: LambdaContext) => Promise<{
13
+ statusCode: number;
14
+ body: string;
15
+ headers?: Record<string, string>;
16
+ isBase64Encoded: boolean;
17
+ }>;
18
+ /**
19
+ * Create an AWS Lambda handler from an Elysia app
20
+ *
21
+ * @param app - An Elysia application instance
22
+ * @returns AWS Lambda handler function
23
+ *
24
+ * @example
25
+ * ```ts
26
+ * import { createLambda, createHandler } from "elysia-apigw/runtime";
27
+ *
28
+ * const app = createLambda().get("/hello", () => "Hello World");
29
+ * export const handler = createHandler(app);
30
+ * ```
31
+ */
32
+ export declare function createHandler(app: AnyElysia): LambdaHandler;
@@ -0,0 +1,29 @@
1
+ /**
2
+ * Runtime adapter for AWS Lambda
3
+ *
4
+ * This module provides the Lambda handler creation function
5
+ * that bridges Elysia apps to AWS Lambda via Hono.
6
+ */
7
+ import { Hono } from "hono/tiny";
8
+ import { handle } from "hono/aws-lambda";
9
+ /**
10
+ * Create an AWS Lambda handler from an Elysia app
11
+ *
12
+ * @param app - An Elysia application instance
13
+ * @returns AWS Lambda handler function
14
+ *
15
+ * @example
16
+ * ```ts
17
+ * import { createLambda, createHandler } from "elysia-apigw/runtime";
18
+ *
19
+ * const app = createLambda().get("/hello", () => "Hello World");
20
+ * export const handler = createHandler(app);
21
+ * ```
22
+ */
23
+ export function createHandler(app) {
24
+ if (!app || typeof app.fetch !== "function") {
25
+ throw new Error("createHandler requires an Elysia app instance with a .fetch method");
26
+ }
27
+ const hono = new Hono().mount("/", app.fetch);
28
+ return handle(hono);
29
+ }
@@ -0,0 +1,8 @@
1
+ /**
2
+ * elysia-apigw runtime exports
3
+ *
4
+ * This module is imported at runtime in Lambda functions.
5
+ * Keep it minimal to reduce bundle size.
6
+ */
7
+ export { createHandler, type LambdaHandler } from "./adapter";
8
+ export type * from "./types";
@@ -0,0 +1,7 @@
1
+ /**
2
+ * elysia-apigw runtime exports
3
+ *
4
+ * This module is imported at runtime in Lambda functions.
5
+ * Keep it minimal to reduce bundle size.
6
+ */
7
+ export { createHandler } from "./adapter";
@@ -0,0 +1,5 @@
1
+ /**
2
+ * Runtime type exports
3
+ */
4
+ export type { LambdaEvent, LambdaContext } from "hono/aws-lambda";
5
+ export type { LambdaHandler } from "./adapter";
@@ -0,0 +1,4 @@
1
+ /**
2
+ * Runtime type exports
3
+ */
4
+ export {};
package/package.json ADDED
@@ -0,0 +1,71 @@
1
+ {
2
+ "name": "@actuallyjamez/elysian",
3
+ "version": "0.2.1",
4
+ "description": "Automatic Lambda bundler for Elysia with API Gateway and Terraform integration",
5
+ "type": "module",
6
+ "main": "./dist/index.js",
7
+ "types": "./dist/index.d.ts",
8
+ "bin": {
9
+ "elysian": "./dist/cli/index.js"
10
+ },
11
+ "exports": {
12
+ ".": {
13
+ "types": "./dist/index.d.ts",
14
+ "import": "./dist/index.js"
15
+ },
16
+ "./runtime": {
17
+ "types": "./dist/runtime/index.d.ts",
18
+ "import": "./dist/runtime/index.js"
19
+ }
20
+ },
21
+ "files": [
22
+ "dist",
23
+ "templates"
24
+ ],
25
+ "repository": {
26
+ "type": "git",
27
+ "url": "git+https://github.com/actuallyjamez/elysian.git"
28
+ },
29
+ "publishConfig": {
30
+ "access": "public"
31
+ },
32
+ "scripts": {
33
+ "build": "rm -rf dist && tsc",
34
+ "prepublishOnly": "bun run build",
35
+ "dev": "tsc --watch",
36
+ "test": "bun test",
37
+ "changeset": "changeset",
38
+ "version": "changeset version",
39
+ "release": "npm publish"
40
+ },
41
+ "keywords": [
42
+ "elysia",
43
+ "lambda",
44
+ "aws",
45
+ "api-gateway",
46
+ "serverless",
47
+ "terraform",
48
+ "bundler",
49
+ "elysian"
50
+ ],
51
+ "author": "actuallyjamez",
52
+ "license": "MIT",
53
+ "peerDependencies": {
54
+ "elysia": ">=1.0.0"
55
+ },
56
+ "dependencies": {
57
+ "@elysiajs/openapi": "^1.4.14",
58
+ "citty": "^0.1.6",
59
+ "consola": "^3.4.2",
60
+ "hono": "^4.11.7",
61
+ "picocolors": "^1.1.1"
62
+ },
63
+ "devDependencies": {
64
+ "@changesets/changelog-github": "^0.5.2",
65
+ "@changesets/cli": "^2.29.8",
66
+ "@types/aws-lambda": "^8.10.160",
67
+ "@types/bun": "^1.3.7",
68
+ "elysia": "^1.4.22",
69
+ "typescript": "^5.8.3"
70
+ }
71
+ }