Skip to content

Commit

Permalink
fix: social request validation, user update
Browse files Browse the repository at this point in the history
  • Loading branch information
HungLV46 committed Aug 19, 2024
1 parent 77380b8 commit 93c6095
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 10 deletions.
27 changes: 18 additions & 9 deletions src/apis/routes/products/create.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,17 +34,26 @@ export const createProductRoute: Hapi.ServerRoute = {
.optional()
.default([]),
metadata: Joi.object({
previews: Joi.array()
.items(Joi.string())
.default([])
.example([
'https://loremflickr.com/640/480?lock=1572275828555776',
'https://loremflickr.com/640/480?lock=1572275828555776',
]),
cta_url: Joi.string().default('').example('https://www.google.com'),
previews: Joi.array().optional().items(Joi.string()).default([]),
cta_url: Joi.string().optional().default(''),
socials: Joi.array()
.optional()
.items(Joi.object({ name: Joi.string(), url: Joi.string() }))
.default([]),
})
.optional()
.default({}),
.default({})
.example({
previews: [
'https://loremflickr.com/640/480?lock=1572275828555776',
'https://loremflickr.com/640/480?lock=1572275828555776',
],
cta_url: 'https://www.google.com',
socials: [
{ name: 'twitter', url: 'https://twitter.com' },
{ name: 'discord', url: 'https://discord.com' },
],
}),
collections: Joi.array()
.items(
Joi.object({
Expand Down
10 changes: 9 additions & 1 deletion src/apis/routes/products/update.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,12 @@ export const updateProductRoute: Hapi.ServerRoute = {
{ name: 'attribute name 2', value: 'attribute value 2' },
]),
metadata: Joi.object({
previews: Joi.array().items(Joi.string()).optional().default([]),
previews: Joi.array().optional().items(Joi.string()).default([]),
cta_url: Joi.string().optional().default(''),
socials: Joi.array()
.optional()
.items(Joi.object({ name: Joi.string(), url: Joi.string() }))
.default([]),
})
.optional()
.default({})
Expand All @@ -53,6 +57,10 @@ export const updateProductRoute: Hapi.ServerRoute = {
'https://loremflickr.com/640/480?lock=1572275828555776',
],
cta_url: 'https://www.google.com',
socials: [
{ name: 'twitter', url: 'https://twitter.com' },
{ name: 'discord', url: 'https://discord.com' },
],
}),
collections: Joi.array()
.items(
Expand Down
2 changes: 2 additions & 0 deletions src/apis/routes/users/update.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,8 @@ export const updateUserRoute: Hapi.ServerRoute = {
bio: payload.bio,
avatar_img: payload.avatar_img,
banner_img: payload.banner_img,
email: payload.email,
wallet_address: payload.wallet_address,
additional_info: payload.additional_info,
} as Prisma.UserCreateInput;

Expand Down

0 comments on commit 93c6095

Please sign in to comment.