RPC work
This commit is contained in:
34
packages/common/.gitignore
vendored
Normal file
34
packages/common/.gitignore
vendored
Normal file
@@ -0,0 +1,34 @@
|
||||
# dependencies (bun install)
|
||||
node_modules
|
||||
|
||||
# output
|
||||
out
|
||||
dist
|
||||
*.tgz
|
||||
|
||||
# code coverage
|
||||
coverage
|
||||
*.lcov
|
||||
|
||||
# logs
|
||||
logs
|
||||
_.log
|
||||
report.[0-9]_.[0-9]_.[0-9]_.[0-9]_.json
|
||||
|
||||
# dotenv environment variable files
|
||||
.env
|
||||
.env.development.local
|
||||
.env.test.local
|
||||
.env.production.local
|
||||
.env.local
|
||||
|
||||
# caches
|
||||
.eslintcache
|
||||
.cache
|
||||
*.tsbuildinfo
|
||||
|
||||
# IntelliJ based IDEs
|
||||
.idea
|
||||
|
||||
# Finder (MacOS) folder config
|
||||
.DS_Store
|
||||
14
packages/common/package.json
Normal file
14
packages/common/package.json
Normal file
@@ -0,0 +1,14 @@
|
||||
{
|
||||
"name": "@website/common",
|
||||
"private": true,
|
||||
"type": "module",
|
||||
"exports": {
|
||||
"./config": "./src/config/index.ts",
|
||||
"./webrpc": "./src/webrpc/index.ts",
|
||||
"./*": "./src/*.ts"
|
||||
},
|
||||
"dependencies": {
|
||||
"@effect/rpc": "^0.69.2",
|
||||
"effect": "^3.17.13"
|
||||
}
|
||||
}
|
||||
4
packages/common/src/config/CommonConfig.ts
Normal file
4
packages/common/src/config/CommonConfig.ts
Normal file
@@ -0,0 +1,4 @@
|
||||
import { Config } from "effect"
|
||||
|
||||
|
||||
export const webRpcHttpPath = Config.succeed("/rpc/web" as const)
|
||||
1
packages/common/src/config/index.ts
Normal file
1
packages/common/src/config/index.ts
Normal file
@@ -0,0 +1 @@
|
||||
export * as CommonConfig from "./CommonConfig"
|
||||
4
packages/common/src/webrpc/WebRpc.ts
Normal file
4
packages/common/src/webrpc/WebRpc.ts
Normal file
@@ -0,0 +1,4 @@
|
||||
import * as WebRpcTest from "./WebRpcTest"
|
||||
|
||||
|
||||
export class WebRpc extends WebRpcTest.WebRpcTest {}
|
||||
11
packages/common/src/webrpc/WebRpcTest.ts
Normal file
11
packages/common/src/webrpc/WebRpcTest.ts
Normal file
@@ -0,0 +1,11 @@
|
||||
import { Rpc, RpcGroup } from "@effect/rpc"
|
||||
import { Schema } from "effect"
|
||||
|
||||
|
||||
export class PingV1 extends Rpc.make("Test.PingV1", {
|
||||
success: Schema.Literal("pong"),
|
||||
}) {}
|
||||
|
||||
export class WebRpcTest extends RpcGroup.make(
|
||||
PingV1,
|
||||
) {}
|
||||
2
packages/common/src/webrpc/index.ts
Normal file
2
packages/common/src/webrpc/index.ts
Normal file
@@ -0,0 +1,2 @@
|
||||
export * as WebRpc from "./WebRpc"
|
||||
export * as WebRpcTest from "./WebRpcTest"
|
||||
32
packages/common/tsconfig.json
Normal file
32
packages/common/tsconfig.json
Normal file
@@ -0,0 +1,32 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
// Environment setup & latest features
|
||||
"lib": ["ESNext"],
|
||||
"target": "ESNext",
|
||||
"module": "ESNext",
|
||||
"moduleDetection": "force",
|
||||
"jsx": "react-jsx",
|
||||
"allowJs": true,
|
||||
|
||||
// Bundler mode
|
||||
"moduleResolution": "bundler",
|
||||
"allowImportingTsExtensions": true,
|
||||
"verbatimModuleSyntax": true,
|
||||
"noEmit": true,
|
||||
|
||||
// Best practices
|
||||
"strict": true,
|
||||
"skipLibCheck": true,
|
||||
"noFallthroughCasesInSwitch": true,
|
||||
"noUncheckedIndexedAccess": true,
|
||||
|
||||
// Some stricter flags (disabled by default)
|
||||
"noUnusedLocals": false,
|
||||
"noUnusedParameters": false,
|
||||
"noPropertyAccessFromIndexSignature": false,
|
||||
|
||||
"plugins": [
|
||||
{ "name": "@effect/language-service" }
|
||||
]
|
||||
}
|
||||
}
|
||||
@@ -6,6 +6,7 @@
|
||||
"dependencies": {
|
||||
"@effect/platform": "^0.90.8",
|
||||
"@effect/platform-bun": "^0.79.0",
|
||||
"@website/common": "workspace:*",
|
||||
"effect": "^3.17.13"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,8 +2,7 @@ import { FileSystem, HttpMiddleware, HttpRouter, HttpServer, HttpServerRequest,
|
||||
import { Duration, Effect, flow } from "effect"
|
||||
|
||||
|
||||
const router = HttpRouter.empty.pipe(
|
||||
)
|
||||
const router = HttpRouter.empty
|
||||
|
||||
export const HttpAppDevelopment = router.pipe(
|
||||
HttpServer.serve(flow(
|
||||
|
||||
8
packages/server/src/webrpc/WebRpcLive.ts
Normal file
8
packages/server/src/webrpc/WebRpcLive.ts
Normal file
@@ -0,0 +1,8 @@
|
||||
import { Layer } from "effect"
|
||||
import * as WebRpcTestLive from "./WebRpcTestLive"
|
||||
import type { WebRpc } from "@website/common/webrpc"
|
||||
|
||||
|
||||
export const WebRpcLive = Layer.mergeAll(
|
||||
WebRpcTestLive.WebRpcTestLive,
|
||||
) satisfies ReturnType<typeof WebRpc.WebRpc.toLayer>
|
||||
9
packages/server/src/webrpc/WebRpcTestLive.ts
Normal file
9
packages/server/src/webrpc/WebRpcTestLive.ts
Normal file
@@ -0,0 +1,9 @@
|
||||
import { WebRpcTest } from "@website/common/webrpc"
|
||||
import { Effect, Layer } from "effect"
|
||||
|
||||
|
||||
export const PingV1Live = WebRpcTest.WebRpcTest.toLayerHandler("Test.PingV1", Effect.succeed(() => Effect.succeed("pong" as const)))
|
||||
|
||||
export const WebRpcTestLive = Layer.mergeAll(
|
||||
PingV1Live,
|
||||
) satisfies ReturnType<typeof WebRpcTest.WebRpcTest.toLayer>
|
||||
2
packages/server/src/webrpc/index.ts
Normal file
2
packages/server/src/webrpc/index.ts
Normal file
@@ -0,0 +1,2 @@
|
||||
export * as WebRpcLive from "./WebRpcLive"
|
||||
export * as WebRpcTestLive from "./WebRpcTestLive"
|
||||
@@ -23,6 +23,10 @@
|
||||
// Some stricter flags (disabled by default)
|
||||
"noUnusedLocals": false,
|
||||
"noUnusedParameters": false,
|
||||
"noPropertyAccessFromIndexSignature": false
|
||||
"noPropertyAccessFromIndexSignature": false,
|
||||
|
||||
"plugins": [
|
||||
{ "name": "@effect/language-service" }
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,6 +10,11 @@
|
||||
"preview": "vite preview"
|
||||
},
|
||||
"dependencies": {
|
||||
"@effect/platform": "^0.90.9",
|
||||
"@effect/platform-browser": "^0.70.0",
|
||||
"@effect/rpc": "^0.69.2",
|
||||
"effect": "^3.17.13",
|
||||
"effect-fc": "^0.1.3",
|
||||
"react": "^19.1.1",
|
||||
"react-dom": "^19.1.1"
|
||||
},
|
||||
|
||||
@@ -21,7 +21,12 @@
|
||||
"noUnusedParameters": true,
|
||||
"erasableSyntaxOnly": true,
|
||||
"noFallthroughCasesInSwitch": true,
|
||||
"noUncheckedSideEffectImports": true
|
||||
"noUncheckedSideEffectImports": true,
|
||||
|
||||
"plugins": [
|
||||
{ "name": "@effect/language-service" }
|
||||
]
|
||||
},
|
||||
|
||||
"include": ["src"]
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user