update actions to fix build warning
This commit is contained in:
@@ -0,0 +1,36 @@
|
||||
import nextConnect from "next-connect";
|
||||
import multer from "multer";
|
||||
|
||||
const upload = multer({
|
||||
storage: multer.diskStorage({
|
||||
destination: "./public/uploads",
|
||||
filename: (req, file, cb) => cb(null, file.originalname),
|
||||
}),
|
||||
});
|
||||
|
||||
const apiRoute = nextConnect({
|
||||
onError(error, req, res) {
|
||||
console.log("booo", req.data);
|
||||
|
||||
res.status(501).json({
|
||||
error: `Sorry something Happened! ${error.message}`,
|
||||
});
|
||||
},
|
||||
onNoMatch(req, res) {
|
||||
res.status(405).json({ error: `Method '${req.method}' Not Allowed` });
|
||||
},
|
||||
});
|
||||
|
||||
apiRoute.use(upload.array("fileList"));
|
||||
|
||||
apiRoute.post((req, res) => {
|
||||
res.status(200).json({ data: "success" });
|
||||
});
|
||||
|
||||
export default apiRoute;
|
||||
|
||||
export const config = {
|
||||
api: {
|
||||
bodyParser: false, // Disallow body parsing, consume as stream
|
||||
},
|
||||
};
|
||||
Reference in New Issue
Block a user