feat(services): add guilds endpoints
This commit is contained in:
@ -19,7 +19,7 @@ const getServiceSchema: FastifySchema = {
|
||||
response: {
|
||||
200: Type.Object({
|
||||
user: Type.Object(userPublicSchema),
|
||||
guilds: Type.Union([Type.Array(Type.Object(guildSchema)), Type.Null()])
|
||||
guilds: Type.Array(Type.Object(guildSchema))
|
||||
}),
|
||||
400: fastifyErrors[400],
|
||||
404: fastifyErrors[404],
|
||||
@ -28,7 +28,7 @@ const getServiceSchema: FastifySchema = {
|
||||
} as const
|
||||
|
||||
export const getUserById: FastifyPluginAsync = async (fastify) => {
|
||||
fastify.route<{
|
||||
await fastify.route<{
|
||||
Params: ParametersGetUser
|
||||
}>({
|
||||
method: 'GET',
|
||||
@ -65,11 +65,13 @@ export const getUserById: FastifyPluginAsync = async (fastify) => {
|
||||
return {
|
||||
user: {
|
||||
...user,
|
||||
email: user.email ?? null,
|
||||
settings
|
||||
},
|
||||
guilds: !settings.isPublicGuilds
|
||||
? null
|
||||
? []
|
||||
: await prisma.guild.findMany({
|
||||
take: 10,
|
||||
where: {
|
||||
members: {
|
||||
some: {
|
||||
|
@ -25,7 +25,7 @@ const getConfirmEmailSchema: FastifySchema = {
|
||||
} as const
|
||||
|
||||
export const getConfirmEmail: FastifyPluginAsync = async (fastify) => {
|
||||
fastify.route<{
|
||||
await fastify.route<{
|
||||
Querystring: QueryGetConfirmEmailSchemaType
|
||||
}>({
|
||||
method: 'GET',
|
||||
|
@ -35,7 +35,7 @@ const postRefreshTokenSchema: FastifySchema = {
|
||||
} as const
|
||||
|
||||
export const postRefreshTokenUser: FastifyPluginAsync = async (fastify) => {
|
||||
fastify.route<{
|
||||
await fastify.route<{
|
||||
Body: BodyPostRefreshTokenSchemaType
|
||||
}>({
|
||||
method: 'POST',
|
||||
|
@ -39,7 +39,7 @@ const postResetPasswordSchema: FastifySchema = {
|
||||
} as const
|
||||
|
||||
export const postResetPasswordUser: FastifyPluginAsync = async (fastify) => {
|
||||
fastify.route<{
|
||||
await fastify.route<{
|
||||
Body: BodyPostResetPasswordSchemaType
|
||||
Querystring: QueryPostResetPasswordSchemaType
|
||||
}>({
|
||||
|
@ -26,7 +26,7 @@ const putResetPasswordSchema: FastifySchema = {
|
||||
} as const
|
||||
|
||||
export const putResetPasswordUser: FastifyPluginAsync = async (fastify) => {
|
||||
fastify.route<{
|
||||
await fastify.route<{
|
||||
Body: BodyPutResetPasswordSchemaType
|
||||
}>({
|
||||
method: 'PUT',
|
||||
|
@ -60,7 +60,7 @@ describe('POST /users/signin', () => {
|
||||
const response = await application.inject({
|
||||
method: 'POST',
|
||||
url: '/users/signin',
|
||||
payload: payload
|
||||
payload
|
||||
})
|
||||
expect(response.statusCode).toEqual(400)
|
||||
})
|
||||
|
@ -31,7 +31,7 @@ const postSigninSchema: FastifySchema = {
|
||||
} as const
|
||||
|
||||
export const postSigninUser: FastifyPluginAsync = async (fastify) => {
|
||||
fastify.route<{
|
||||
await fastify.route<{
|
||||
Body: BodyPostSigninSchemaType
|
||||
}>({
|
||||
method: 'POST',
|
||||
|
@ -24,7 +24,7 @@ const postSignoutSchema: FastifySchema = {
|
||||
} as const
|
||||
|
||||
export const postSignoutUser: FastifyPluginAsync = async (fastify) => {
|
||||
fastify.route<{
|
||||
await fastify.route<{
|
||||
Body: BodyPostSignoutSchemaType
|
||||
}>({
|
||||
method: 'POST',
|
||||
|
@ -34,7 +34,7 @@ const postSignupSchema: FastifySchema = {
|
||||
} as const
|
||||
|
||||
export const postSignupUser: FastifyPluginAsync = async (fastify) => {
|
||||
fastify.route<{
|
||||
await fastify.route<{
|
||||
Body: BodyUserSchemaType
|
||||
Querystring: QueryPostSignupSchemaType
|
||||
}>({
|
||||
|
Reference in New Issue
Block a user