You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
|
|
const express = require("express");
|
|
|
|
const route = express.Router();
|
|
|
|
const controller = require("../Controller/Supplier");
|
|
|
|
const { protect } = require("../Middleware/auth")
|
|
|
|
|
|
|
|
const multer = require("multer");
|
|
|
|
const moment = require("moment");
|
|
|
|
var storage = multer.diskStorage({
|
|
|
|
destination: function (req, file, cb) {
|
|
|
|
if (file.fieldname == "supplier_image") cb(null, "uploads/supplier/tmp_post");
|
|
|
|
},
|
|
|
|
|
|
|
|
filename: function (req, file, cb) {
|
|
|
|
cb(
|
|
|
|
null,
|
|
|
|
moment(Date.now()).format("YYYY-MM-DD_HH-mm-ss_") + file.originalname
|
|
|
|
);
|
|
|
|
},
|
|
|
|
});
|
|
|
|
|
|
|
|
var upload = multer({ storage: storage });
|
|
|
|
|
|
|
|
|
|
|
|
route.route('/').get(protect, controller.getAllSupplier)
|
|
|
|
route.route('/').post(upload.single("supplier_image"), protect, controller.createSupplier)
|
|
|
|
|
|
|
|
module.exports = route;
|