initial commit
This commit is contained in:
commit
33e75c056f
77 changed files with 4329 additions and 0 deletions
55
apps/server/.gitignore
vendored
Normal file
55
apps/server/.gitignore
vendored
Normal file
|
|
@ -0,0 +1,55 @@
|
|||
# prod
|
||||
dist/
|
||||
/build
|
||||
/out/
|
||||
|
||||
# dev
|
||||
.yarn/
|
||||
!.yarn/patches
|
||||
!.yarn/plugins
|
||||
!.yarn/releases
|
||||
!.yarn/versions
|
||||
.vscode/*
|
||||
!.vscode/launch.json
|
||||
!.vscode/*.code-snippets
|
||||
.idea/workspace.xml
|
||||
.idea/usage.statistics.xml
|
||||
.idea/shelf
|
||||
.wrangler
|
||||
.alchemy
|
||||
/.next/
|
||||
.vercel
|
||||
prisma/generated/
|
||||
|
||||
|
||||
# deps
|
||||
node_modules/
|
||||
/node_modules
|
||||
/.pnp
|
||||
.pnp.*
|
||||
|
||||
# env
|
||||
.env*
|
||||
.env.production
|
||||
!.env.example
|
||||
.dev.vars
|
||||
|
||||
# logs
|
||||
logs/
|
||||
*.log
|
||||
npm-debug.log*
|
||||
yarn-debug.log*
|
||||
yarn-error.log*
|
||||
pnpm-debug.log*
|
||||
lerna-debug.log*
|
||||
|
||||
# misc
|
||||
.DS_Store
|
||||
*.pem
|
||||
|
||||
# local db
|
||||
*.db*
|
||||
|
||||
# typescript
|
||||
*.tsbuildinfo
|
||||
next-env.d.ts
|
||||
33
apps/server/package.json
Normal file
33
apps/server/package.json
Normal file
|
|
@ -0,0 +1,33 @@
|
|||
{
|
||||
"name": "server",
|
||||
"type": "module",
|
||||
"main": "src/index.ts",
|
||||
"scripts": {
|
||||
"build": "tsdown",
|
||||
"check-types": "tsc -b",
|
||||
"compile": "bun build --compile --minify --sourcemap --bytecode ./src/index.ts --outfile server",
|
||||
"dev": "bun run --hot src/index.ts",
|
||||
"start": "bun run dist/index.mjs"
|
||||
},
|
||||
"dependencies": {
|
||||
"@elysiajs/cors": "^1.4.1",
|
||||
"@elysiajs/trpc": "^1.1.0",
|
||||
"@hono/trpc-server": "^0.4.0",
|
||||
"@minmon/api": "workspace:*",
|
||||
"@minmon/auth": "workspace:*",
|
||||
"@minmon/db": "workspace:*",
|
||||
"@minmon/env": "workspace:*",
|
||||
"@sinclair/typebox": "^0.34.49",
|
||||
"@trpc/server": "catalog:",
|
||||
"better-auth": "catalog:",
|
||||
"dotenv": "catalog:",
|
||||
"elysia": "catalog:",
|
||||
"zod": "catalog:"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@minmon/config": "workspace:*",
|
||||
"@types/bun": "catalog:",
|
||||
"tsdown": "^0.21.9",
|
||||
"typescript": "catalog:"
|
||||
}
|
||||
}
|
||||
37
apps/server/src/index.ts
Normal file
37
apps/server/src/index.ts
Normal file
|
|
@ -0,0 +1,37 @@
|
|||
import { cors } from "@elysiajs/cors";
|
||||
import { createContext } from "@minmon/api/context";
|
||||
import { appRouter } from "@minmon/api/routers/index";
|
||||
import { auth } from "@minmon/auth";
|
||||
import { env } from "@minmon/env/server";
|
||||
import { fetchRequestHandler } from "@trpc/server/adapters/fetch";
|
||||
import { Elysia } from "elysia";
|
||||
|
||||
const app = new Elysia()
|
||||
.use(
|
||||
cors({
|
||||
origin: env.CORS_ORIGIN,
|
||||
methods: ["GET", "POST", "OPTIONS"],
|
||||
allowedHeaders: ["Content-Type", "Authorization"],
|
||||
credentials: true,
|
||||
}),
|
||||
)
|
||||
.all("/api/auth/*", async (context) => {
|
||||
const { request, status } = context;
|
||||
if (["POST", "GET"].includes(request.method)) {
|
||||
return auth.handler(request);
|
||||
}
|
||||
return status(405);
|
||||
})
|
||||
.all("/trpc/*", async (context) => {
|
||||
const res = await fetchRequestHandler({
|
||||
endpoint: "/trpc",
|
||||
router: appRouter,
|
||||
req: context.request,
|
||||
createContext: () => createContext({ context }),
|
||||
});
|
||||
return res;
|
||||
})
|
||||
.get("/", () => "OK")
|
||||
.listen(3000, () => {
|
||||
console.log("Server is running on http://localhost:3000");
|
||||
});
|
||||
11
apps/server/tsconfig.json
Normal file
11
apps/server/tsconfig.json
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
{
|
||||
"extends": "@minmon/config/tsconfig.base.json",
|
||||
"compilerOptions": {
|
||||
"composite": true,
|
||||
"outDir": "dist",
|
||||
"paths": {
|
||||
"@/*": ["./src/*"]
|
||||
},
|
||||
"jsx": "react-jsx"
|
||||
}
|
||||
}
|
||||
9
apps/server/tsdown.config.ts
Normal file
9
apps/server/tsdown.config.ts
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
import { defineConfig } from "tsdown";
|
||||
|
||||
export default defineConfig({
|
||||
entry: "./src/index.ts",
|
||||
format: "esm",
|
||||
outDir: "./dist",
|
||||
clean: true,
|
||||
noExternal: [/@minmon\/.*/],
|
||||
});
|
||||
Loading…
Add table
Add a link
Reference in a new issue