mirror of
https://github.com/shishantbiswas/bknd.git
synced 2026-03-16 12:37:20 +00:00
init: solid start adapter
This commit is contained in:
1
app/src/adapter/solid-start/index.ts
Normal file
1
app/src/adapter/solid-start/index.ts
Normal file
@@ -0,0 +1 @@
|
||||
export * from "./solid-start.adapter";
|
||||
16
app/src/adapter/solid-start/solid-start.adapter.spec.ts
Normal file
16
app/src/adapter/solid-start/solid-start.adapter.spec.ts
Normal file
@@ -0,0 +1,16 @@
|
||||
import { afterAll, beforeAll, describe } from "bun:test";
|
||||
import * as solidStart from "./solid-start.adapter";
|
||||
import { disableConsoleLog, enableConsoleLog } from "core/utils";
|
||||
import { adapterTestSuite } from "adapter/adapter-test-suite";
|
||||
import { bunTestRunner } from "adapter/bun/test";
|
||||
import type { SolidStartBkndConfig } from "./solid-start.adapter";
|
||||
|
||||
beforeAll(disableConsoleLog);
|
||||
afterAll(enableConsoleLog);
|
||||
|
||||
describe("solid-start adapter", () => {
|
||||
adapterTestSuite<SolidStartBkndConfig>(bunTestRunner, {
|
||||
makeApp: solidStart.getApp,
|
||||
makeHandler: solidStart.serve,
|
||||
});
|
||||
});
|
||||
22
app/src/adapter/solid-start/solid-start.adapter.ts
Normal file
22
app/src/adapter/solid-start/solid-start.adapter.ts
Normal file
@@ -0,0 +1,22 @@
|
||||
import { createRuntimeApp, type RuntimeBkndConfig } from "bknd/adapter";
|
||||
|
||||
export type SolidStartEnv = NodeJS.ProcessEnv;
|
||||
export type SolidStartBkndConfig<Env = SolidStartEnv> = RuntimeBkndConfig<Env>;
|
||||
|
||||
export async function getApp<Env = SolidStartEnv>(
|
||||
config: SolidStartBkndConfig<Env>,
|
||||
args: Env = process.env as Env,
|
||||
) {
|
||||
return await createRuntimeApp(config, args);
|
||||
}
|
||||
|
||||
|
||||
export function serve<Env = SolidStartEnv>(
|
||||
config: SolidStartBkndConfig<Env> = {},
|
||||
args: Env = process.env as Env,
|
||||
) {
|
||||
return async (req: Request) => {
|
||||
const app = await getApp(config, args);
|
||||
return app.fetch(req);
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user