Skip to content

Commit

Permalink
working
Browse files Browse the repository at this point in the history
  • Loading branch information
Akshaypareek01 committed Oct 11, 2023
1 parent 52745e2 commit 483b9c3
Show file tree
Hide file tree
Showing 3 changed files with 280 additions and 1 deletion.
16 changes: 16 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,18 @@ import { signin, signup } from './Controller/Users.Controllers.js';
import { CpoSignin, CpoSignup } from './Controller/CopUsers.Controllers.js';
import { CustomersRouter } from './Routes/Customer.Routes.js';
import { CustomerSignin, CustomerSignup } from './Controller/Customers.Controller.js';
import multer from 'multer';
const users = {};
const app =express();
const storage = multer.diskStorage({
destination: function (req, file, cb) {
cb(null, 'media/'); // Set the destination folder for image storage
},
filename: function (req, file, cb) {
cb(null, file.originalname); // Use the original filename for the stored image
},
});
const upload = multer({ storage: storage });
app.use(express.json());
app.use(cors());

Expand All @@ -52,6 +62,12 @@ app.get('/api/token', (req, res) => {
res.json({ token });
});

app.post('/api/upload', upload.single('image'), (req, res) => {
// The image has been uploaded and stored in the media folder.
// You can send a response to the frontend, e.g., a success message.
res.json({ message: 'Image uploaded successfully' });
});

const verifyToken = (req, res, next) => {
// Get the token from the request headers or query parameters
const token = req.headers.authorization || req.query.token;
Expand Down
Loading

0 comments on commit 483b9c3

Please sign in to comment.