commit 85205593e4929d42687c77d34a843a0d87b4c12a Author: clfreville2 Date: Wed Oct 11 11:13:47 2023 +0200 Initial commit diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..4d333ef --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +node_modules +bun.lockb diff --git a/dprint.json b/dprint.json new file mode 100644 index 0000000..49654d5 --- /dev/null +++ b/dprint.json @@ -0,0 +1,12 @@ +{ + "typescript": { + "quoteStyle": "preferSingle" + }, + "includes": ["src/**/*.{ts,tsx,js,jsx,cjs,mjs,json}"], + "excludes": [ + "**/node_modules" + ], + "plugins": [ + "https://plugins.dprint.dev/typescript-0.88.1.wasm" + ] +} diff --git a/package.json b/package.json new file mode 100644 index 0000000..25dd2e4 --- /dev/null +++ b/package.json @@ -0,0 +1,15 @@ +{ + "name": "labyrinth", + "module": "src/server.ts", + "type": "module", + "scripts": {}, + "devDependencies": { + "bun-types": "^1.0.3" + }, + "peerDependencies": { + "typescript": "^5.0.0" + }, + "dependencies": { + "msgpack-rpc-node": "^0.1.0-alpha.3" + } +} diff --git a/src/server.ts b/src/server.ts new file mode 100644 index 0000000..44f66a5 --- /dev/null +++ b/src/server.ts @@ -0,0 +1,21 @@ +import { Client, TcpClient } from 'msgpack-rpc-node'; + +const RPC_PORT = 9000; +const client = new Client(TcpClient, RPC_PORT); +await client.connect(); + +const server = Bun.serve({ + port: 3000, + fetch(request) { + const url = new URL(request.url); + switch (url.pathname) { + case '/run': + client.call('Add', 'echo $(( 1 + 2 ))', 'msh').then(console.log); + return new Response('Your code is running...'); + default: + return new Response('404!', { status: 404 }); + } + }, +}); + +console.log(`Listening on http://localhost:${server.port}`); diff --git a/tsconfig.json b/tsconfig.json new file mode 100644 index 0000000..2558e1d --- /dev/null +++ b/tsconfig.json @@ -0,0 +1,22 @@ +{ + "compilerOptions": { + "baseUrl": "./src", + "types": ["bun-types"], + + "lib": ["esnext"], + "module": "esnext", + "target": "esnext", + + "moduleResolution": "bundler", + "noEmit": true, + "allowImportingTsExtensions": true, + "moduleDetection": "force", + + "strict": true, + "forceConsistentCasingInFileNames": true, + "skipLibCheck": true, + "composite": true, + "downlevelIteration": true, + "allowSyntheticDefaultImports": true + } +}