First commit
This commit is contained in:
@@ -0,0 +1,8 @@
|
||||
import SetupCreateAdmin from "./setup/create-admin";
|
||||
import SetupInitilization from "./setup/initialization";
|
||||
|
||||
type ApiMap =
|
||||
SetupInitilization &
|
||||
SetupCreateAdmin;
|
||||
|
||||
export default ApiMap;
|
||||
@@ -0,0 +1,23 @@
|
||||
import { InputError, InputNoneError } from "../../modules/error/input";
|
||||
import ErrorBase from "../../modules/error";
|
||||
import DatabaseError from "../../modules/error/database";
|
||||
|
||||
export default interface SetupCreateAdmin {
|
||||
"setup/create-admin": {
|
||||
body: {
|
||||
userid: string;
|
||||
username: string;
|
||||
email: string;
|
||||
password: string;
|
||||
};
|
||||
response: Success | DatabaseError | ErrorBase<{
|
||||
bad: "client",
|
||||
code: "yet_initialization",
|
||||
message: "初期設定が行われていません。",
|
||||
}> | ErrorBase<{
|
||||
bad: "client",
|
||||
code: "first_admin_already_exists",
|
||||
message: "最初の管理者ユーザーは既に存在します。",
|
||||
}> | InputError | InputNoneError;
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
import { InputError, InputNoneError } from "../../modules/error/input";
|
||||
import ErrorBase from "../../modules/error";
|
||||
import DatabaseError from "../../modules/error/database";
|
||||
|
||||
export default interface SetupInitilization {
|
||||
"setup/initilization": {
|
||||
body: {
|
||||
name: string;
|
||||
description: string;
|
||||
requiredInvitationCode: boolean;
|
||||
force?: "use_force_initialization";
|
||||
};
|
||||
response: Success | DatabaseError | ErrorBase<{
|
||||
bad: "client",
|
||||
code: "already_initialization",
|
||||
message: "既に初期設定が行われています。",
|
||||
}> | InputError | InputNoneError;
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
import ErrorBase from ".";
|
||||
|
||||
type DatabaseError = ErrorBase<{
|
||||
bad: "server",
|
||||
code: "database_error",
|
||||
message: "サーバーでデータベースの問題が発生しました。",
|
||||
}>;
|
||||
|
||||
export default DatabaseError;
|
||||
@@ -0,0 +1,13 @@
|
||||
type ErrorType<R = unknown> = {
|
||||
bad: "client" | "server";
|
||||
code: string;
|
||||
message: string;
|
||||
reason?: R,
|
||||
}
|
||||
|
||||
type ErrorBase<E extends ErrorType<any>> = {
|
||||
success: false;
|
||||
error: E;
|
||||
}
|
||||
|
||||
export default ErrorBase;
|
||||
@@ -0,0 +1,16 @@
|
||||
export type InputError = ErrorBase<{
|
||||
bad: "client";
|
||||
code: "input_wrong";
|
||||
message: "入力に問題があります。";
|
||||
reason: {
|
||||
code: string,
|
||||
path: string,
|
||||
message: string,
|
||||
}[];
|
||||
}>;
|
||||
|
||||
export type InputNoneError = ErrorBase<{
|
||||
bad: "client",
|
||||
code: "input_none",
|
||||
message: "入力がありません。",
|
||||
}>;
|
||||
@@ -0,0 +1,3 @@
|
||||
export default interface Success {
|
||||
success: true;
|
||||
}
|
||||
Reference in New Issue
Block a user