色々
This commit is contained in:
@@ -9,7 +9,7 @@ import AuthError from "../..//modules/error/auth";
|
||||
|
||||
export default interface ChannelCreate {
|
||||
"channel/create": {
|
||||
body: Omit<Channel, "userid">;
|
||||
body: Pick<Channel, "name", "description", "community">;
|
||||
response: (Success & {
|
||||
id: string;
|
||||
}) | InputError | AuthError | DatabaseError | YetInitializationError | UnknownError;
|
||||
|
||||
@@ -5,16 +5,12 @@ import UnknownError from "../../modules/error/unknown";
|
||||
import Success from "../../modules/response/success";
|
||||
import Channel from "../../modules/channel";
|
||||
import YetInitializationError from "../../modules/error/yet_init";
|
||||
import AuthError from "../..//modules/error/auth";
|
||||
|
||||
type RequireAtLeastOne<T, Keys extends keyof T = keyof T> =
|
||||
Keys extends keyof T
|
||||
? Required<Pick<T, Keys>> & Partial<Omit<T, Keys>>
|
||||
: never;
|
||||
import AuthError from "../../modules/error/auth";
|
||||
import { RequireAtLeastOne } from "../../modules/generic";
|
||||
|
||||
export default interface ChannelEdit {
|
||||
"channel/edit": {
|
||||
body: RequireAtLeastOne<Omit<Channel, "userid">>;
|
||||
body: RequireAtLeastOne<Omit<Channel, "userid", "community">>;
|
||||
response: (Success & {
|
||||
id: string;
|
||||
}) | InputError | AuthError | DatabaseError | YetInitializationError | UnknownError;
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
import InputError from "../../modules/error/input";
|
||||
import ErrorBase from "../../modules/error";
|
||||
import DatabaseError from "../../modules/error/database";
|
||||
import UnknownError from "../../modules/error/unknown";
|
||||
import Success from "../../modules/response/success";
|
||||
import Channel from "../../modules/channel";
|
||||
import YetInitializationError from "../../modules/error/yet_init";
|
||||
import AuthError from "../../modules/error/auth";
|
||||
|
||||
export default interface ChannelGet {
|
||||
"channel/get": {
|
||||
body: {
|
||||
id: string;
|
||||
};
|
||||
response: (Success & {
|
||||
channel: Channel;
|
||||
}) | InputError | AuthError | DatabaseError | YetInitializationError | UnknownError;
|
||||
};
|
||||
}
|
||||
@@ -9,16 +9,13 @@ import AuthError from "../..//modules/error/auth";
|
||||
|
||||
export default interface ChannelList {
|
||||
"channel/list": {
|
||||
body?: {
|
||||
body: {
|
||||
limit?: number;
|
||||
since?: string | Date;
|
||||
community: string;
|
||||
};
|
||||
response: (Success & {
|
||||
channels: (Omit<Channel, "userid"> & {
|
||||
id: string;
|
||||
createdBy: string;
|
||||
createdAt: string;
|
||||
})[];
|
||||
channels: Channel[];
|
||||
}) | InputError | AuthError | DatabaseError | YetInitializationError | UnknownError;
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
import InputError from "../../modules/error/input";
|
||||
import ErrorBase from "../../modules/error";
|
||||
import DatabaseError from "../../modules/error/database";
|
||||
import UnknownError from "../../modules/error/unknown";
|
||||
import Success from "../../modules/response/success";
|
||||
import Community from "../../modules/community";
|
||||
import YetInitializationError from "../../modules/error/yet_init";
|
||||
import AuthError from "../../modules/error/auth";
|
||||
|
||||
export default interface CommunityCreate {
|
||||
"community/create": {
|
||||
body: Pick<Community, "name", "description">;
|
||||
response: (Success & {
|
||||
id: string;
|
||||
}) | InputError | AuthError | DatabaseError | YetInitializationError | UnknownError;
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
import InputError from "../../modules/error/input";
|
||||
import ErrorBase from "../../modules/error";
|
||||
import DatabaseError from "../../modules/error/database";
|
||||
import UnknownError from "../../modules/error/unknown";
|
||||
import Success from "../../modules/response/success";
|
||||
import Community from "../../modules/community";
|
||||
import YetInitializationError from "../../modules/error/yet_init";
|
||||
import AuthError from "../../modules/error/auth";
|
||||
import { RequireAtLeastOne } from "../../modules/generic";
|
||||
|
||||
export default interface CommunityEdit {
|
||||
"community/edit": {
|
||||
body: RequireAtLeastOne<Omit<Community, "userid">>;
|
||||
response: (Success & {
|
||||
id: string;
|
||||
}) | InputError | AuthError | DatabaseError | YetInitializationError | UnknownError;
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
import InputError from "../../modules/error/input";
|
||||
import ErrorBase from "../../modules/error";
|
||||
import DatabaseError from "../../modules/error/database";
|
||||
import UnknownError from "../../modules/error/unknown";
|
||||
import Success from "../../modules/response/success";
|
||||
import Community from "../../modules/community";
|
||||
import YetInitializationError from "../../modules/error/yet_init";
|
||||
import AuthError from "../../modules/error/auth";
|
||||
|
||||
export default interface CommunityGet {
|
||||
"community/get": {
|
||||
body: {
|
||||
id: string;
|
||||
};
|
||||
response: (Success & {
|
||||
community: Community;
|
||||
}) | InputError | AuthError | DatabaseError | YetInitializationError | UnknownError;
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
import InputError from "../../modules/error/input";
|
||||
import ErrorBase from "../../modules/error";
|
||||
import DatabaseError from "../../modules/error/database";
|
||||
import UnknownError from "../../modules/error/unknown";
|
||||
import Success from "../../modules/response/success";
|
||||
import Community from "../../modules/community";
|
||||
import YetInitializationError from "../../modules/error/yet_init";
|
||||
import AuthError from "../../modules/error/auth";
|
||||
|
||||
export default interface CommunityList {
|
||||
"community/list": {
|
||||
body?: {
|
||||
limit?: number;
|
||||
since?: string | Date;
|
||||
};
|
||||
response: (Success & {
|
||||
communitys: Community[];
|
||||
}) | InputError | AuthError | DatabaseError | YetInitializationError | UnknownError;
|
||||
};
|
||||
}
|
||||
+10
@@ -1,6 +1,11 @@
|
||||
import ChannelCreate from "./api/channel/create";
|
||||
import ChannelEdit from "./api/channel/edit";
|
||||
import ChannelGet from "./api/channel/get";
|
||||
import ChannelList from "./api/channel/list";
|
||||
import CommunityCreate from "./api/community/create";
|
||||
import CommunityEdit from "./api/community/edit";
|
||||
import CommunityGet from "./api/community/get";
|
||||
import CommunityList from "./api/community/list";
|
||||
import Me from "./api/me";
|
||||
import PrimarySignin from "./api/primary/signin";
|
||||
import PrimarySignup from "./api/primary/signup";
|
||||
@@ -15,8 +20,13 @@ type ApiMap =
|
||||
PrimarySignin &
|
||||
PrimarySignup &
|
||||
Me &
|
||||
CommunityCreate &
|
||||
CommunityEdit &
|
||||
CommunityGet &
|
||||
CommunityList &
|
||||
ChannelCreate &
|
||||
ChannelEdit &
|
||||
ChannelGet &
|
||||
ChannelList;
|
||||
|
||||
export default ApiMap;
|
||||
@@ -1,5 +1,8 @@
|
||||
export default interface Channel {
|
||||
id: string;
|
||||
name: string;
|
||||
description: string;
|
||||
userid: string;
|
||||
community: string;
|
||||
createdBy: string;
|
||||
createdAt: Date;
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
export default interface Community {
|
||||
id: string;
|
||||
name: string;
|
||||
description: string;
|
||||
icon: string | null;
|
||||
createdBy: string;
|
||||
createdAt: Date;
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
export type RequireAtLeastOne<T, Keys extends keyof T = keyof T> =
|
||||
Keys extends keyof T
|
||||
? Required<Pick<T, Keys>> & Partial<Omit<T, Keys>>
|
||||
: never;
|
||||
@@ -26,8 +26,10 @@ export default class LynqChat<
|
||||
this.retry = options.retry ?? 5;
|
||||
this.waiting = options.waiting ?? 500;
|
||||
|
||||
if (this.retry < 1) throw new lynqError("Invalid retry count.");
|
||||
if (this.waiting < 1) throw new lynqError("Invalid base waiting time.");
|
||||
if (this.retry < 1)
|
||||
throw new lynqError("Invalid retry count.");
|
||||
if (this.waiting < 1)
|
||||
throw new lynqError("Invalid base waiting time.");
|
||||
if (options.origin !== new URL(options.origin).origin)
|
||||
throw new lynqError("Invalid origin.");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user