Go to file
yvan f1a0b17bb0 前端代码 2026-08-13 22:35:13 +08:00
.codegraph feat: initial commit - kratos admin service 2026-08-13 18:22:43 +08:00
api/kratos/admin/v1 迁移 2026-08-13 21:51:20 +08:00
configs 迁移公告,邮件 2026-08-13 22:04:27 +08:00
docs 前端代码 2026-08-13 22:35:13 +08:00
internal 前端代码 2026-08-13 22:35:13 +08:00
pkg 迁移 2026-08-13 21:51:20 +08:00
web 前端代码 2026-08-13 22:35:13 +08:00
.gitattributes feat: initial commit - kratos admin service 2026-08-13 18:22:43 +08:00
.gitignore 前端代码 2026-08-13 22:35:13 +08:00
AGENTS.md feat: initial commit - kratos admin service 2026-08-13 18:22:43 +08:00
CLAUDE.md feat: initial commit - kratos admin service 2026-08-13 18:22:43 +08:00
Dockerfile feat: initial commit - kratos admin service 2026-08-13 18:22:43 +08:00
Makefile feat: initial commit - kratos admin service 2026-08-13 18:22:43 +08:00
README.md feat: initial commit - kratos admin service 2026-08-13 18:22:43 +08:00
buf.gen.config.yaml feat: initial commit - kratos admin service 2026-08-13 18:22:43 +08:00
buf.gen.yaml feat: initial commit - kratos admin service 2026-08-13 18:22:43 +08:00
buf.lock feat: initial commit - kratos admin service 2026-08-13 18:22:43 +08:00
buf.yaml feat: initial commit - kratos admin service 2026-08-13 18:22:43 +08:00
go.mod 迁移 2026-08-13 21:51:20 +08:00
go.sum 迁移 2026-08-13 21:51:20 +08:00
openapi.yaml feat: initial commit - kratos admin service 2026-08-13 18:22:43 +08:00

README.md

Kratos Admin Template

Best Practice

Google AIP(https://google.aip.dev/general):

  1. Resource-oriented design
  2. Filtering
  3. Pagination
  4. Field masks
  5. Field behavior

Generate API files

Proto generation is driven by buf. Dependencies such as googleapis are resolved from the Buf Schema Registry (buf.build/googleapis/googleapis), so there is no vendored third_party/ directory.

# Install tooling (buf + wire)
make init
# Generate API files (pb.go, grpc, kratos http, openapi.yaml, web TS clients) from api/*.proto
make api
# Generate internal config (internal/conf/conf.pb.go) from internal/*.proto
make config

Run Web Application

# Enter web directory, install dependencies and start development server
cd web
npm install
npm run dev

The generated clients work with any Promise-based HTTP client that returns JSON.
Services are defined and re-exported from this file: web/src/services/index.ts.

import { createAdminServiceClient } from "@/services/kratos/admin/v1/index";

type Request = {
  path: string;
  method: string;
  body: string | null;
};

function requestHandler({ path, method, body }: Request) { ... }

export function createAdminService() {
  return createAdminServiceClient(requestHandler);
}

Example using the generated client:

import { createAdminService } from "@/services/index";

const adminService = createAdminService();

const handleLogin = async (username: string, password: string) => {
  try {
    const response = await adminService.Login({
      username: username,
      password: password,
    });
    console.log("Login successful:", response);
  } catch (error) {
    console.error("Login failed:", error);
  }
};