Skip to content

Commit d064a95

Browse files
luoling8192nekomeowwwNeko-233
committed
feat(server): with api server, service-lize (#807)
Co-authored-by: Neko Ayaka <neko@ayaka.moe> Co-authored-by: Lovehsigure_520 <1260907335@qq.com>
1 parent dd46b8d commit d064a95

File tree

30 files changed

+2163
-184
lines changed

30 files changed

+2163
-184
lines changed

apps/server/.env

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
DATABASE_URL=""
2+
3+
AUTH_GOOGLE_CLIENT_ID=""
4+
AUTH_GOOGLE_CLIENT_SECRET=""
5+
6+
AUTH_GITHUB_CLIENT_ID=""
7+
AUTH_GITHUB_CLIENT_SECRET=""

apps/server/Dockerfile

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
FROM node:24-alpine
2+
3+
WORKDIR /app
4+
5+
RUN corepack enable
6+
7+
COPY pnpm-lock.yaml pnpm-workspace.yaml package.json ./
8+
COPY apps/server apps/server
9+
10+
RUN pnpm install --frozen-lockfile --ignore-scripts
11+
12+
EXPOSE 3000
13+
14+
CMD ["pnpm", "-F", "@proj-airi/api-server", "start"]

apps/server/docker-compose.yml

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
version: '3.9'
2+
3+
services:
4+
db:
5+
image: postgres:16-alpine
6+
container_name: airi-postgres
7+
environment:
8+
- POSTGRES_DB=airi
9+
- POSTGRES_USER=airi
10+
- POSTGRES_PASSWORD=airi
11+
ports:
12+
- '5432:5432'
13+
healthcheck:
14+
test: ['CMD-SHELL', 'pg_isready -U $$POSTGRES_USER -d $$POSTGRES_DB']
15+
interval: 5s
16+
timeout: 5s
17+
retries: 10
18+
volumes:
19+
- ${serviceName}_data:/var/lib/postgresql/data
20+
21+
server:
22+
build:
23+
context: ../..
24+
dockerfile: apps/server/Dockerfile
25+
depends_on:
26+
db:
27+
condition: service_healthy
28+
ports:
29+
- '3000:3000'
30+
31+
volumes:
32+
db_data:
33+
driver: local

apps/server/drizzle.config.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import process from 'node:process'
2+
3+
export default {
4+
schema: './src/schemas/**/*.ts',
5+
out: './drizzle',
6+
dialect: 'postgresql',
7+
dbCredentials: {
8+
url: process.env.DATABASE_URL,
9+
},
10+
}
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
CREATE TABLE "account" (
2+
"id" text PRIMARY KEY NOT NULL,
3+
"account_id" text NOT NULL,
4+
"provider_id" text NOT NULL,
5+
"user_id" text NOT NULL,
6+
"access_token" text,
7+
"refresh_token" text,
8+
"id_token" text,
9+
"access_token_expires_at" timestamp,
10+
"refresh_token_expires_at" timestamp,
11+
"scope" text,
12+
"password" text,
13+
"created_at" timestamp DEFAULT now() NOT NULL,
14+
"updated_at" timestamp NOT NULL
15+
);
16+
--> statement-breakpoint
17+
CREATE TABLE "session" (
18+
"id" text PRIMARY KEY NOT NULL,
19+
"expires_at" timestamp NOT NULL,
20+
"token" text NOT NULL,
21+
"created_at" timestamp DEFAULT now() NOT NULL,
22+
"updated_at" timestamp NOT NULL,
23+
"ip_address" text,
24+
"user_agent" text,
25+
"user_id" text NOT NULL,
26+
CONSTRAINT "session_token_unique" UNIQUE("token")
27+
);
28+
--> statement-breakpoint
29+
CREATE TABLE "user" (
30+
"id" text PRIMARY KEY NOT NULL,
31+
"name" text NOT NULL,
32+
"email" text NOT NULL,
33+
"email_verified" boolean DEFAULT false NOT NULL,
34+
"image" text,
35+
"created_at" timestamp DEFAULT now() NOT NULL,
36+
"updated_at" timestamp DEFAULT now() NOT NULL,
37+
CONSTRAINT "user_email_unique" UNIQUE("email")
38+
);
39+
--> statement-breakpoint
40+
CREATE TABLE "verification" (
41+
"id" text PRIMARY KEY NOT NULL,
42+
"identifier" text NOT NULL,
43+
"value" text NOT NULL,
44+
"expires_at" timestamp NOT NULL,
45+
"created_at" timestamp DEFAULT now() NOT NULL,
46+
"updated_at" timestamp DEFAULT now() NOT NULL
47+
);
48+
--> statement-breakpoint
49+
ALTER TABLE "account" ADD CONSTRAINT "account_user_id_user_id_fk" FOREIGN KEY ("user_id") REFERENCES "public"."user"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
50+
ALTER TABLE "session" ADD CONSTRAINT "session_user_id_user_id_fk" FOREIGN KEY ("user_id") REFERENCES "public"."user"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
51+
CREATE INDEX "account_userId_idx" ON "account" USING btree ("user_id");--> statement-breakpoint
52+
CREATE INDEX "session_userId_idx" ON "session" USING btree ("user_id");--> statement-breakpoint
53+
CREATE INDEX "verification_identifier_idx" ON "verification" USING btree ("identifier");

0 commit comments

Comments
 (0)