create-fullstack-setup 1.0.16 → 1.0.17

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-fullstack-setup",
3
- "version": "1.0.16",
3
+ "version": "1.0.17",
4
4
  "description": "CLI to generate ready-to-run fullstack or backend applications",
5
5
  "bin": {
6
6
  "create-fullstack-setup": "bin/index.js"
@@ -0,0 +1,29 @@
1
+ import multer from "multer";
2
+ import path from "path";
3
+ import fs from "fs";
4
+ import { fileURLToPath } from "url";
5
+
6
+ const __filename = fileURLToPath(import.meta.url);
7
+ const __dirname = path.dirname(__filename);
8
+
9
+ // ✅ Better folder name: uploads/temp
10
+ const uploadDir = path.join(__dirname, "../../uploads/temp");
11
+
12
+ if (!fs.existsSync(uploadDir)) {
13
+ fs.mkdirSync(uploadDir, { recursive: true });
14
+ }
15
+
16
+ const storage = multer.diskStorage({
17
+ destination: (_req, _file, cb) => {
18
+ cb(null, uploadDir);
19
+ },
20
+
21
+ filename: (_req, file, cb) => {
22
+ const ext = path.extname(file.originalname);
23
+ const uniqueSuffix = `${Date.now()}-${Math.round(Math.random() * 1e9)}`;
24
+
25
+ cb(null, `${file.fieldname}-${uniqueSuffix}${ext}`);
26
+ }
27
+ });
28
+
29
+ export const upload = multer({ storage });