diff --git a/src/controllers/tankersController.js b/src/controllers/tankersController.js index 4f63e0fe..7a33bb23 100644 --- a/src/controllers/tankersController.js +++ b/src/controllers/tankersController.js @@ -178,6 +178,24 @@ exports.getTanker = async (req, reply) => { } }; +exports.getallTanker = async (req, reply) => { + try { + await Tanker.find() + .exec() + .then((docs) => { + reply.send({ status_code: 200, data: docs, count: docs.length }); + }) + .catch((err) => { + console.log(err); + reply.send({ error: err }); + }); + } catch (err) { + throw boom.boomify(err); + } +}; + + + diff --git a/src/controllers/userController.js b/src/controllers/userController.js index df0fd65d..6e558809 100644 --- a/src/controllers/userController.js +++ b/src/controllers/userController.js @@ -342,7 +342,7 @@ exports.delPhoneUser = async (req, reply) => { exports.uploadProfilePicture = async (req, reply) => { try { const customerId = req.params.customerId; - const picture = new Buffer.from(req.body.picture, 'base64'); + const picture = req.body.picture; let profilePicture = await ProfilePicture.findOne({ customerId }); diff --git a/src/models/User.js b/src/models/User.js index b59a853e..4a7c3000 100644 --- a/src/models/User.js +++ b/src/models/User.js @@ -117,7 +117,7 @@ const profilePictureSchema = new Schema({ required: true }, picture: { - type: Buffer, + type: String, required: true } }); diff --git a/src/routes/tankersRoute.js b/src/routes/tankersRoute.js index 1d9407ce..95fbbe7d 100644 --- a/src/routes/tankersRoute.js +++ b/src/routes/tankersRoute.js @@ -232,6 +232,22 @@ module.exports = function (fastify, opts, next) { handler: tankersController.getTanker, }); + fastify.get("/api/getallTankers", { + schema: { + tags: ["Supplier"], + description: "This is for Get all Tanker Data", + summary: "This is for to Get all Tanker Data", + + security: [ + { + basicAuth: [], + }, + ], + }, + preHandler: fastify.auth([fastify.authenticate]), + handler: tankersController.getallTanker, + }); + fastify.route({ method: "POST", url: "/api/addBores/:customerId",