make init
# Download and update dependencies
make init
# Generate API files (include: pb.go, http, grpc, validate, swagger) by proto file
make api
# 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);
}
};