diff options
author | Elizabeth Hunt <me@liz.coffee> | 2025-06-20 14:53:38 -0700 |
---|---|---|
committer | Elizabeth Hunt <me@liz.coffee> | 2025-06-20 14:53:38 -0700 |
commit | d4791f3d357634daf506fb8f91cc5332a794c421 (patch) | |
tree | 1bb01d2d4d8fa74d83bb6f99f2c8aa4146ca2d11 /server/index.ts | |
parent | d7e8d31c94cd713a2f4cf799e20e993acc69e361 (diff) | |
download | ci-d4791f3d357634daf506fb8f91cc5332a794c421.tar.gz ci-d4791f3d357634daf506fb8f91cc5332a794c421.zip |
Move to nodejs
Diffstat (limited to 'server/index.ts')
-rw-r--r-- | server/index.ts | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/server/index.ts b/server/index.ts new file mode 100644 index 0000000..c33b43e --- /dev/null +++ b/server/index.ts @@ -0,0 +1,31 @@ +#!/usr/bin/env node + +export * from './job'; +export * from './ci'; +export * from './health'; + +import { CiHookServer } from '.'; +import { Either, type IEither } from '@emprespresso/pengueno'; +import { serve } from '@hono/node-server'; +import { Hono } from 'hono'; + +const server = new CiHookServer(); + +const neverEndingPromise = new Promise<IEither<Error, 0>>(() => {}); +export const runServer = (port: number, host: string): Promise<IEither<Error, 0>> => + Either.fromFailable<Error, void>(() => { + const app = new Hono(); + + app.all('*', async (c) => { + const response = await server.serve(c.req.raw); + return response; + }); + + serve({ + fetch: app.fetch, + port, + hostname: host, + }); + + console.log(`server running on http://${host}:${port} :D`); + }).flatMapAsync(() => neverEndingPromise); |