Refactor part 2
This commit is contained in:
parent
e21a807fb3
commit
80196b732a
9 changed files with 78 additions and 25 deletions
|
|
@ -84,6 +84,7 @@ const postCreateCommunity = async (
|
|||
name: community.name,
|
||||
description: community.description,
|
||||
ownerId: community.ownerId,
|
||||
creationDate: community.creationDate.getTime(),
|
||||
} as IPostCreateCommunityResponseSuccess;
|
||||
};
|
||||
|
||||
|
|
@ -116,6 +117,8 @@ const patchCommunity = async (request: FastifyRequest, reply: FastifyReply) => {
|
|||
id: community.id,
|
||||
name: community.name,
|
||||
description: community.description,
|
||||
ownerId: community.ownerId,
|
||||
creationDate: community.creationDate.getTime(),
|
||||
} as IPatchCommunityResponseSuccess;
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -1,15 +1,6 @@
|
|||
import type { API_ERROR } from "../errors.js";
|
||||
|
||||
interface IGetInviteParams {
|
||||
id: string;
|
||||
}
|
||||
|
||||
interface IGetInviteResponseError {
|
||||
id: string;
|
||||
error: API_ERROR;
|
||||
}
|
||||
|
||||
interface IGetInviteResponseSuccess {
|
||||
interface IInvite {
|
||||
id: string;
|
||||
communityId: string;
|
||||
valid: boolean;
|
||||
|
|
@ -21,6 +12,17 @@ interface IGetInviteResponseSuccess {
|
|||
expirationDate: number;
|
||||
}
|
||||
|
||||
interface IGetInviteParams {
|
||||
id: string;
|
||||
}
|
||||
|
||||
interface IGetInviteResponseError {
|
||||
id: string;
|
||||
error: API_ERROR;
|
||||
}
|
||||
|
||||
interface IGetInviteResponseSuccess extends IInvite {}
|
||||
|
||||
interface IDeleteInviteParams {
|
||||
id: string;
|
||||
}
|
||||
|
|
@ -53,6 +55,7 @@ interface IPostAcceptDeleteInviteResponseSuccess {
|
|||
}
|
||||
|
||||
export {
|
||||
type IInvite,
|
||||
type IGetInviteParams,
|
||||
type IGetInviteResponseError,
|
||||
type IGetInviteResponseSuccess,
|
||||
|
|
|
|||
|
|
@ -55,7 +55,9 @@ const getRole = async (request: FastifyRequest, reply: FastifyReply) => {
|
|||
return {
|
||||
id: role.id,
|
||||
name: role.name,
|
||||
description: role.description,
|
||||
communityId: role.communityId,
|
||||
permissions: role.permissions,
|
||||
creationDate: role.creationDate.getTime(),
|
||||
} as IGetRoleResponseSuccess;
|
||||
};
|
||||
|
|
@ -75,7 +77,10 @@ const postCreateRole = async (request: FastifyRequest, reply: FastifyReply) => {
|
|||
return {
|
||||
id: role.id,
|
||||
name: role.name,
|
||||
description: role.description,
|
||||
communityId: role.communityId,
|
||||
permissions: role.permissions,
|
||||
creationDate: role.creationDate.getTime(),
|
||||
} as IPostCreateRoleResponseSuccess;
|
||||
};
|
||||
|
||||
|
|
@ -103,8 +108,10 @@ const patchRole = async (request: FastifyRequest, reply: FastifyReply) => {
|
|||
return {
|
||||
id: role.id,
|
||||
name: role.name,
|
||||
description: role.description,
|
||||
communityId: role.communityId,
|
||||
permissions: role.permissions,
|
||||
creationDate: role.creationDate.getTime(),
|
||||
} as IPatchRoleResponseSuccess;
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -78,7 +78,12 @@ interface IPostAssignRoleResponseError {
|
|||
error: API_ERROR;
|
||||
}
|
||||
|
||||
interface IPostAssignRoleResponseSuccess extends IRole {}
|
||||
interface IPostAssignRoleResponseSuccess {
|
||||
id: string;
|
||||
name: string;
|
||||
communityId: string;
|
||||
userId: string;
|
||||
}
|
||||
|
||||
interface IPostUnassignRoleParams {
|
||||
id: string;
|
||||
|
|
@ -93,7 +98,12 @@ interface IPostUnassignRoleResponseError {
|
|||
error: API_ERROR;
|
||||
}
|
||||
|
||||
interface IPostUnassignRoleResponseSuccess extends IRole {}
|
||||
interface IPostUnassignRoleResponseSuccess {
|
||||
id: string;
|
||||
name: string;
|
||||
communityId: string;
|
||||
userId: string;
|
||||
}
|
||||
|
||||
export {
|
||||
type IRole,
|
||||
|
|
|
|||
|
|
@ -1,5 +1,11 @@
|
|||
import type { API_ERROR } from "../errors.js";
|
||||
|
||||
interface ISession {
|
||||
id: string;
|
||||
userId: string;
|
||||
creationDate: number;
|
||||
}
|
||||
|
||||
interface IGetSessionParams {
|
||||
id: string;
|
||||
}
|
||||
|
|
@ -9,11 +15,7 @@ interface IGetSessionResponseError {
|
|||
error: API_ERROR;
|
||||
}
|
||||
|
||||
interface IGetSessionResponseSuccess {
|
||||
id: string;
|
||||
userId: string;
|
||||
creationDate: number;
|
||||
}
|
||||
interface IGetSessionResponseSuccess extends ISession {}
|
||||
|
||||
interface IDeleteSessionParams {
|
||||
id: string;
|
||||
|
|
@ -30,6 +32,7 @@ interface IDeleteSessionResponseSuccess {
|
|||
}
|
||||
|
||||
export {
|
||||
type ISession,
|
||||
type IGetSessionParams,
|
||||
type IGetSessionResponseError,
|
||||
type IGetSessionResponseSuccess,
|
||||
|
|
|
|||
|
|
@ -98,6 +98,8 @@ const postCreateUser = async (request: FastifyRequest, reply: FastifyReply) => {
|
|||
email: user.email,
|
||||
description: user.description,
|
||||
admin: user.admin,
|
||||
registerDate: user.registerDate.getTime(),
|
||||
lastLogin: user.lastLogin?.getTime() ?? 0,
|
||||
} as IPostCreateUserResponseSuccess;
|
||||
};
|
||||
|
||||
|
|
@ -124,8 +126,12 @@ const patchUser = async (request: FastifyRequest, reply: FastifyReply) => {
|
|||
|
||||
return {
|
||||
id: user.id,
|
||||
username: user.username,
|
||||
email: user.email,
|
||||
description: user.description,
|
||||
admin: user.admin,
|
||||
registerDate: user.registerDate.getTime(),
|
||||
lastLogin: user.lastLogin?.getTime() ?? 0,
|
||||
} as IPatchUserResponseSuccess;
|
||||
};
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue