Add services and auth
This commit is contained in:
parent
9b0b5dc040
commit
5dec454afb
46 changed files with 900 additions and 31 deletions
27
src/controllers/channel/channel.ts
Normal file
27
src/controllers/channel/channel.ts
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
import { type FastifyReply, type FastifyRequest } from "fastify";
|
||||
import type {
|
||||
IChannelParams,
|
||||
IChannelResponseError,
|
||||
IChannelResponseSuccess,
|
||||
} from "./types.js";
|
||||
import { getChannelById } from "../../services/channel/channel.js";
|
||||
|
||||
const getChannel = async (request: FastifyRequest, _reply: FastifyReply) => {
|
||||
const { id } = request.params as IChannelParams;
|
||||
|
||||
const channel = await getChannelById(id);
|
||||
if (!channel) {
|
||||
return {
|
||||
id: id,
|
||||
error: "channel does not exist",
|
||||
} as IChannelResponseError;
|
||||
}
|
||||
|
||||
return {
|
||||
id: channel.id,
|
||||
name: channel.name,
|
||||
communityId: channel.communityId,
|
||||
} as IChannelResponseSuccess;
|
||||
};
|
||||
|
||||
export { getChannel };
|
||||
Loading…
Add table
Add a link
Reference in a new issue