diff --git a/src/models/User.js b/src/models/User.js index fc6f6c06..2e536c89 100644 --- a/src/models/User.js +++ b/src/models/User.js @@ -114,18 +114,37 @@ const userSchema = new mongoose.Schema( { versionKey: false } ); +// const profilePictureSchema = new Schema({ +// customerId: { +// type: String,unique: true, +// required: true +// }, +// picture: { +// type: String, +// required: true +// } +// }); const profilePictureSchema = new Schema({ customerId: { - type: String,unique: true, + type: String, + unique: true, required: true }, picture: { - type: String, - required: true + type: { + type: String, + enum: ['jpeg', 'png', 'gif'], // add the file formats you support here + required: true + }, + data: { + type: Buffer, + required: true + } } }); + const ProfilePicture = mongoose.model('ProfilePicture', profilePictureSchema); const Counter = mongoose.model('Counter', CounterSchema); const User = mongoose.model("User", userSchema); diff --git a/src/routes/usersRoute.js b/src/routes/usersRoute.js index fba890dc..43b0552d 100644 --- a/src/routes/usersRoute.js +++ b/src/routes/usersRoute.js @@ -454,15 +454,35 @@ module.exports = function (fastify, opts, next) { }, }, }, + // body: { + // type: "object", + // required: ["picture"], + // properties: { + // picture: { + // type: 'string' + // } + // }, + // }, body: { type: "object", required: ["picture"], properties: { picture: { - type: 'string' + type: "object", + properties: { + type: { + type: "string", + enum: ['jpeg', 'png', 'gif'] + }, + data: { + type: "string", + format: "binary" + } + } } }, }, + security: [ { basicAuth: [],