WARNING: THIS SITE IS A MIRROR OF GITHUB.COM / IT CANNOT LOGIN OR REGISTER ACCOUNTS / THE CONTENTS ARE PROVIDED AS-IS / THIS SITE ASSUMES NO RESPONSIBILITY FOR ANY DISPLAYED CONTENT OR LINKS / IF YOU FOUND SOMETHING MAY NOT GOOD FOR EVERYONE, CONTACT ADMIN AT ilovescratch@foxmail.com
Skip to content

go-kratos/kratos-admin

Repository files navigation

Kratos Admin Template

Prerequisites

make init

Generate API files

# Download and update dependencies
make init
# Generate API files (include: pb.go, http, grpc, validate, swagger) by proto file
make api

Generate Web Client files

# Download and update dependencies
make init
# Generate client files (include: index.ts) by proto file
make web

# 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 { createAuthClient } from "@/services/kratos/admin/v1/index";

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

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

export function createAuthService() {
  return createAuthClient(requestHandler);
}

Example using the generated client:

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

const authService = createAuthService();

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

About

Kratos-admin helps you quickly build a modern admin frontend.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published