gateway schema
This commit is contained in:
@@ -1,9 +1,21 @@
|
||||
import { Schema, model } from 'mongoose';
|
||||
|
||||
export type UserIDType = number;
|
||||
export type validOAuthType = 'KAKAO' | 'NONE';
|
||||
|
||||
const validOAuthTypeList: validOAuthType[] = ['KAKAO', 'NONE'];
|
||||
const validOAuthTypeList = ['KAKAO', 'NONE'] as const;
|
||||
export type validOAuthType = typeof validOAuthTypeList[number];
|
||||
|
||||
const validServerActionTypeList = [
|
||||
'Update', 'UpdateByGitPath', 'ShowErrorLog',
|
||||
'CloseServer', 'OpenServer', 'StopAndResumeServer', 'OpenVote',
|
||||
] as const;
|
||||
export type ServerActionType = typeof validServerActionTypeList[number];
|
||||
|
||||
const validGatewayActionTypeList = [
|
||||
'Update', 'UpdateByGitPath', 'ShowErrorLog', 'ResetUserPassword', 'ChangeGatewayState', 'DeleteUser',
|
||||
] as const;
|
||||
|
||||
export type GatewayActionType = typeof validGatewayActionTypeList[number];
|
||||
|
||||
interface IUser {
|
||||
_id: UserIDType;
|
||||
@@ -22,7 +34,8 @@ interface IUser {
|
||||
allowThirdPartyUse: boolean;
|
||||
|
||||
userName: string;
|
||||
allowServerAction?: Map<string, number>;
|
||||
allowServerAction?: Map<string, ServerActionType[]>;
|
||||
allowGatewayAction?: ServerActionType[];
|
||||
penalty?: Map<string, Date>;
|
||||
|
||||
picture?: string;
|
||||
@@ -49,7 +62,17 @@ export const User = new Schema<IUser>({
|
||||
allowThirdPartyUse: { type: Boolean, required: true },
|
||||
|
||||
userName: { type: String, required: true },
|
||||
allowServerAction: { type: Map, required: false, of: Number },
|
||||
allowServerAction: {
|
||||
type: Map, required: false, of: {
|
||||
type: Array,
|
||||
of: { type: String, enum: validServerActionTypeList }
|
||||
}
|
||||
},
|
||||
allowGatewayAction: {
|
||||
type: Array, required: false, of: {
|
||||
type: String, enum: validGatewayActionTypeList
|
||||
}
|
||||
},
|
||||
penalty: { type: Map, required: false, of: Date },
|
||||
|
||||
picture: { type: String, required: false },
|
||||
@@ -57,11 +80,11 @@ export const User = new Schema<IUser>({
|
||||
|
||||
regDate: { type: Date, required: true },
|
||||
deleteAfter: { type: Date, required: false },
|
||||
})
|
||||
}, { autoIndex: false })
|
||||
.index({ id: 1 }, { unique: true })
|
||||
.index({ email: 1 }, { unique: true })
|
||||
.index({ oauthID: 1 }, { unique: true, sparse: true })
|
||||
.index({ deleteAfter: 1 })
|
||||
.index({ deleteAfter: 1 }) // 자동 삭제 아님!
|
||||
;
|
||||
|
||||
export default model<IUser>('User', User);
|
||||
Reference in New Issue
Block a user