create-fullstack-setup 1.0.0

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.
Files changed (57) hide show
  1. package/README.md +391 -0
  2. package/bin/index.js +175 -0
  3. package/package.json +19 -0
  4. package/templates/backend/express-js/.env.example +6 -0
  5. package/templates/backend/express-js/Utils/ApiError.js +17 -0
  6. package/templates/backend/express-js/Utils/ApiResponse.js +12 -0
  7. package/templates/backend/express-js/Utils/AsyncHandler.js +8 -0
  8. package/templates/backend/express-js/Utils/Cloudinary.js +31 -0
  9. package/templates/backend/express-js/app.js +35 -0
  10. package/templates/backend/express-js/config/db.js +18 -0
  11. package/templates/backend/express-js/middlewares/Auth.middleware.js +21 -0
  12. package/templates/backend/express-js/middlewares/Multer.middleware.js +18 -0
  13. package/templates/backend/express-js/package.json +17 -0
  14. package/templates/backend/express-js/server.js +10 -0
  15. package/templates/backend/express-ts/.env.example +3 -0
  16. package/templates/backend/express-ts/README.md +0 -0
  17. package/templates/backend/express-ts/nodemon.json +5 -0
  18. package/templates/backend/express-ts/package.json +20 -0
  19. package/templates/backend/express-ts/src/app.ts +14 -0
  20. package/templates/backend/express-ts/src/config/db.ts +0 -0
  21. package/templates/backend/express-ts/src/middlewares/auth.middleware.ts +23 -0
  22. package/templates/backend/express-ts/src/routes/index.ts +0 -0
  23. package/templates/backend/express-ts/src/server.ts +8 -0
  24. package/templates/backend/express-ts/src/utils/ApiError.ts +21 -0
  25. package/templates/backend/express-ts/src/utils/ApiResponse.ts +13 -0
  26. package/templates/backend/express-ts/src/utils/AsyncHandler.ts +9 -0
  27. package/templates/backend/express-ts/src/utils/Cloudinary.ts +11 -0
  28. package/templates/backend/express-ts/tsconfig.json +13 -0
  29. package/templates/frontend/next-js/app/layout.js +14 -0
  30. package/templates/frontend/next-js/app/page.js +8 -0
  31. package/templates/frontend/next-js/jsconfig.json +8 -0
  32. package/templates/frontend/next-js/next.config.js +6 -0
  33. package/templates/frontend/next-js/package.json +16 -0
  34. package/templates/frontend/next-ts/app/layout.tsx +18 -0
  35. package/templates/frontend/next-ts/app/page.tsx +7 -0
  36. package/templates/frontend/next-ts/next.config.js +6 -0
  37. package/templates/frontend/next-ts/package.json +22 -0
  38. package/templates/frontend/next-ts/tsconfig.json +17 -0
  39. package/templates/frontend/react-js/index.html +12 -0
  40. package/templates/frontend/react-js/package.json +19 -0
  41. package/templates/frontend/react-js/src/App.jsx +8 -0
  42. package/templates/frontend/react-js/src/index.css +0 -0
  43. package/templates/frontend/react-js/src/main.jsx +10 -0
  44. package/templates/frontend/react-js/vite.config.js +6 -0
  45. package/templates/frontend/react-ts/index.html +12 -0
  46. package/templates/frontend/react-ts/package.json +21 -0
  47. package/templates/frontend/react-ts/src/App.tsx +9 -0
  48. package/templates/frontend/react-ts/src/index.css +0 -0
  49. package/templates/frontend/react-ts/src/main.tsx +12 -0
  50. package/templates/frontend/react-ts/tsconfig.json +10 -0
  51. package/templates/frontend/react-ts/vite.config.ts +6 -0
  52. package/utils/features.config.js +72 -0
  53. package/utils/fileOps.js +0 -0
  54. package/utils/injectFeatures.js +171 -0
  55. package/utils/installer.js +157 -0
  56. package/utils/prompts.js +59 -0
  57. package/utils/replacePlaceholders.js +54 -0
package/README.md ADDED
@@ -0,0 +1,391 @@
1
+ # 🚀 create-fullstack-app
2
+
3
+ > A modern CLI tool to generate production-ready backend or full-stack applications initial setup with Express in seconds.
4
+
5
+ **create-fullstack-app** streamlines project setup by automating repetitive tasks like folder structure creation, dependency installation, middleware configuration, and environment setup—so you can focus on building features, not boilerplate.
6
+
7
+ ---
8
+
9
+ ## ✨ Features
10
+
11
+ - 🎯 **Interactive Setup** - Guided prompts for a personalized project
12
+ - ⚡ **Fast Scaffolding** - Ready-to-run projects in under a minute
13
+ - 🔧 **Feature-Based** - Only include what you need (JWT, MongoDB, Cloudinary, etc.)
14
+ - 📦 **Multiple Frontends** - Choose React, Next.js, or backend-only
15
+ - 🛠️ **TypeScript & JavaScript** - Full support for both languages
16
+ - 🌍 **Cross-Platform** - Works on Windows, macOS, and Linux
17
+ - 📝 **Zero Configuration** - Pre-wired middleware and utilities
18
+
19
+ ---
20
+
21
+ ## 📋 Requirements
22
+
23
+ - **Node.js** v18 or higher
24
+ - **npm** v9 or higher
25
+
26
+ ---
27
+
28
+ ## 🔧 Installation
29
+
30
+ Install the CLI globally via npm:
31
+
32
+ ```bash
33
+ npm install -g create-fullstack-app
34
+ ```
35
+
36
+ Verify the installation:
37
+
38
+ ```bash
39
+ create-fullstack-app --version
40
+ ```
41
+
42
+ ---
43
+
44
+ ## 🚀 Quick Start
45
+
46
+ ### Create a new project
47
+
48
+ ```bash
49
+ create-fullstack-app my-app
50
+ ```
51
+
52
+ ### Create in the current directory
53
+
54
+ ```bash
55
+ create-fullstack-app .
56
+ ```
57
+
58
+ The CLI will guide you through an interactive setup process.
59
+
60
+ ---
61
+
62
+ ## 📖 Interactive Setup Guide
63
+
64
+ The CLI prompts you step-by-step to customize your project:
65
+
66
+ ### 1️⃣ **Project Name**
67
+ Choose a name for your project folder.
68
+
69
+ ```
70
+ ? Project name: my-awesome-app
71
+ ```
72
+
73
+ ---
74
+
75
+ ### 2️⃣ **Frontend Framework** *(Optional)*
76
+
77
+ Select a frontend framework or skip for a backend-only project:
78
+
79
+ - **React** - Modern UI library
80
+ - **Next.js** - Full-stack React framework
81
+ - **None** - Backend API only
82
+
83
+ ```
84
+ ? Choose frontend framework:
85
+ ○ React
86
+ ○ Next.js
87
+ ● None
88
+ ```
89
+
90
+ ---
91
+
92
+ ### 3️⃣ **Backend Framework**
93
+
94
+ Currently supported:
95
+
96
+ - **Express** - Fast, minimalist web framework
97
+
98
+ ```
99
+ ? Choose backend framework:
100
+ ● Express
101
+ ```
102
+
103
+ ---
104
+
105
+ ### 4️⃣ **Language**
106
+
107
+ Choose your preferred language:
108
+
109
+ - **JavaScript** - Classic, widely supported
110
+ - **TypeScript** - Type-safe, modern development
111
+
112
+ ```
113
+ ? Select language:
114
+ ○ JavaScript
115
+ ● TypeScript
116
+ ```
117
+
118
+ ---
119
+
120
+ ### 5️⃣ **Backend Features**
121
+
122
+ Enable features individually based on your needs:
123
+
124
+ | Feature | Description |
125
+ |---------|-------------|
126
+ | **JWT Authentication** | Token-based auth with middleware |
127
+ | **Cloudinary** | Cloud-based media management |
128
+ | **CORS** | Cross-Origin Resource Sharing |
129
+ | **Cookie Parser** | Parse cookies from requests |
130
+ | **Dotenv** | Environment variable management |
131
+ | **MongoDB** | NoSQL database with Mongoose ODM |
132
+ | **Zod Validation** | Schema validation library |
133
+ | **Bcrypt** | Password hashing utilities |
134
+ | **Multer** | File upload handling |
135
+
136
+ ```
137
+ ? Enable JWT Authentication? (Y/n)
138
+ ? Enable Cloudinary? (Y/n)
139
+ ? Enable CORS? (Y/n)
140
+ ...
141
+ ```
142
+
143
+ ---
144
+
145
+ ## 📂 Generated Project Structure
146
+
147
+ ### Express + TypeScript
148
+
149
+ ```
150
+ my-app/
151
+ ├── server/
152
+ │ ├── src/
153
+ │ │ ├── app.ts # Express app configuration
154
+ │ │ ├── server.ts # Server entry point
155
+ │ │ ├── routes/ # API routes
156
+ │ │ ├── controllers/ # Request handlers
157
+ │ │ ├── middlewares/
158
+ │ │ │ └── auth.middleware.ts # JWT authentication
159
+ │ │ ├── utils/
160
+ │ │ │ └── Cloudinary.ts # Cloudinary setup
161
+ │ │ └── config/
162
+ │ │ └── db.ts # MongoDB connection
163
+ │ ├── .env.example # Environment template
164
+ │ ├── tsconfig.json # TypeScript config
165
+ │ ├── nodemon.json # Dev server config
166
+ │ └── package.json
167
+ └── client/ # (if frontend selected)
168
+ └── ...
169
+ ```
170
+
171
+ ### Express + JavaScript
172
+
173
+ ```
174
+ my-app/
175
+ ├── server/
176
+ │ ├── app.js # Express app configuration
177
+ │ ├── server.js # Server entry point
178
+ │ ├── routes/ # API routes
179
+ │ ├── controllers/ # Request handlers
180
+ │ ├── middlewares/
181
+ │ │ └── auth.middleware.js # JWT authentication
182
+ │ ├── utils/
183
+ │ │ └── Cloudinary.js # Cloudinary setup
184
+ │ ├── .env.example # Environment template
185
+ │ └── package.json
186
+ └── client/ # (if frontend selected)
187
+ └── ...
188
+ ```
189
+
190
+ ---
191
+
192
+ ## ⚙️ Feature Details
193
+
194
+ ### 🔐 JWT Authentication
195
+
196
+ When enabled, the CLI generates:
197
+
198
+ - Authentication middleware for protected routes
199
+ - Support for both `Authorization` header and HTTP-only cookies
200
+ - Token verification utilities
201
+
202
+ **Environment variable:**
203
+ ```env
204
+ ACCESS_TOKEN_SECRET=your_secret_key_here
205
+ ```
206
+
207
+ ---
208
+
209
+ ### ☁️ Cloudinary Integration
210
+
211
+ When enabled, the CLI generates:
212
+
213
+ - Pre-configured Cloudinary utility class
214
+ - Automatic connection on server startup
215
+ - Ready-to-use upload/delete methods
216
+
217
+ **Environment variables:**
218
+ ```env
219
+ CLOUDINARY_NAME=your_cloud_name
220
+ CLOUDINARY_API_KEY=your_api_key
221
+ CLOUDINARY_API_SECRET=your_api_secret
222
+ ```
223
+
224
+ ---
225
+
226
+ ### 🗄️ MongoDB (Mongoose)
227
+
228
+ When enabled, the CLI generates:
229
+
230
+ - Database connection utility
231
+ - Automatic connection with retry logic
232
+ - Connection error handling
233
+
234
+ **Environment variable:**
235
+ ```env
236
+ MONGO_URI=mongodb://localhost:27017/myapp
237
+ ```
238
+
239
+ ---
240
+
241
+ ### 🌐 CORS
242
+
243
+ Enables Cross-Origin Resource Sharing with sensible defaults.
244
+
245
+ ---
246
+
247
+ ### 🍪 Cookie Parser
248
+
249
+ Parses cookies from incoming requests for session management.
250
+
251
+ ---
252
+
253
+ ### 🔒 Bcrypt
254
+
255
+ Utilities for hashing and comparing passwords securely.
256
+
257
+ ---
258
+
259
+ ### 📁 Multer
260
+
261
+ Middleware for handling `multipart/form-data` file uploads.
262
+
263
+ ---
264
+
265
+ ### ✅ Zod Validation
266
+
267
+ Schema-based validation for request data.
268
+
269
+ ---
270
+
271
+ ## 🔐 Environment Variables
272
+
273
+ All required environment variables are written to:
274
+
275
+ ```
276
+ server/.env.example
277
+ ```
278
+
279
+ **Example file:**
280
+
281
+ ```env
282
+ # Server
283
+ PORT=5000
284
+
285
+ # Authentication
286
+ ACCESS_TOKEN_SECRET=your_jwt_secret_here
287
+
288
+ # Cloudinary (if enabled)
289
+ CLOUDINARY_NAME=
290
+ CLOUDINARY_API_KEY=
291
+ CLOUDINARY_API_SECRET=
292
+
293
+ # Database (if MongoDB enabled)
294
+ MONGO_URI=mongodb://localhost:27017/myapp
295
+ ```
296
+
297
+ ### ⚠️ Important
298
+
299
+ Copy `.env.example` to `.env` and fill in your actual values before running:
300
+
301
+ ```bash
302
+ cp server/.env.example server/.env
303
+ ```
304
+
305
+ ---
306
+
307
+ ## 🏃 Running Your Project
308
+
309
+ ### Backend
310
+
311
+ ```bash
312
+ cd my-app/server
313
+ npm install
314
+ npm run dev
315
+ ```
316
+
317
+ The server starts on `http://localhost:5000` (or your configured PORT).
318
+
319
+ ---
320
+
321
+ ### Frontend *(if generated)*
322
+
323
+ ```bash
324
+ cd my-app/client
325
+ npm install
326
+ npm run dev
327
+ ```
328
+
329
+ - **React**: Runs on `http://localhost:5173` (Vite default)
330
+ - **Next.js**: Runs on `http://localhost:3000`
331
+
332
+ ---
333
+
334
+ ## 🎯 Use Cases
335
+
336
+ - 🚀 **Rapid Prototyping** - Get ideas running quickly
337
+ - 📚 **Learning Express** - Study well-structured projects
338
+ - 👥 **Team Consistency** - Standardize project scaffolding
339
+ - 🏗️ **Production Starters** - Begin with best practices
340
+
341
+ ---
342
+
343
+ ## 🛠️ Design Principles
344
+
345
+ - ✅ **Feature-Based Injection** - Only include what you select
346
+ - 📝 **Language Aware** - Respects JavaScript vs TypeScript conventions
347
+ - 🔄 **Idempotent Operations** - No duplicate injections or overwrites
348
+ - 🌍 **Cross-Platform** - Works on all operating systems
349
+ - 📦 **Template Resolution** - Uses `__dirname` for global CLI safety
350
+
351
+ ---
352
+
353
+ ## 🤝 Contributing
354
+
355
+ Contributions are welcome! Feel free to:
356
+
357
+ - Report bugs
358
+ - Suggest new features
359
+ - Submit pull requests
360
+
361
+ ---
362
+
363
+ ## 👨‍💻 Author
364
+
365
+ **Uttam Yadav**
366
+ Full-Stack Developer
367
+
368
+ ---
369
+
370
+ ## 📄 License
371
+
372
+ [MIT](LICENSE)
373
+
374
+ ---
375
+
376
+ ## 📝 Notes
377
+
378
+ - This CLI focuses on **project setup**, not application logic
379
+ - Generated code is fully customizable—modify as needed
380
+ - Templates follow industry best practices
381
+ - No vendor lock-in—standard Express/Node.js code
382
+
383
+ ---
384
+
385
+ ## 🌟 Star this project
386
+
387
+ If you find this tool helpful, consider giving it a star on GitHub!
388
+
389
+ ---
390
+
391
+ **Happy Coding! 🎉**
package/bin/index.js ADDED
@@ -0,0 +1,175 @@
1
+ #!/usr/bin/env node
2
+
3
+ import inquirer from "inquirer";
4
+ import chalk from "chalk";
5
+ import { createProject } from "../utils/installer.js";
6
+
7
+ console.log(chalk.green("\n🚀 Welcome to FullStack App Generator\n"));
8
+
9
+ /* -------------------------------------------------------------------------- */
10
+ /* PROMPTS */
11
+ /* -------------------------------------------------------------------------- */
12
+
13
+ const answers = await inquirer.prompt([
14
+ {
15
+ type: "input",
16
+ name: "projectName",
17
+ message: "Project name:",
18
+ validate: input => (input ? true : "Project name is required")
19
+ },
20
+ {
21
+ type: "list",
22
+ name: "frontend",
23
+ message: "Choose frontend:",
24
+ choices: ["React", "Next.js", "None"]
25
+ },
26
+ {
27
+ type: "list",
28
+ name: "backend",
29
+ message: "Choose backend:",
30
+ choices: ["Express"] // Fastify can be added later
31
+ },
32
+ {
33
+ type: "list",
34
+ name: "language",
35
+ message: "Choose language:",
36
+ choices: ["JavaScript", "TypeScript"]
37
+ },
38
+
39
+ /* ----------------------- Backend Feature Gate ---------------------------- */
40
+
41
+ {
42
+ type: "confirm",
43
+ name: "useBackendFeatures",
44
+ message: "Select backend features?",
45
+ default: true
46
+ },
47
+
48
+ /* ---------------------- Conditional Feature Prompts ---------------------- */
49
+
50
+ {
51
+ type: "confirm",
52
+ name: "useJWT",
53
+ message: "Use JWT authentication?",
54
+ default: true,
55
+ when: ans => ans.useBackendFeatures
56
+ },
57
+ {
58
+ type: "confirm",
59
+ name: "useCORS",
60
+ message: "Enable CORS?",
61
+ default: true,
62
+ when: ans => ans.useBackendFeatures
63
+ },
64
+ {
65
+ type: "confirm",
66
+ name: "useCookieParser",
67
+ message: "Use Cookie Parser?",
68
+ default: true,
69
+ when: ans => ans.useBackendFeatures
70
+ },
71
+ {
72
+ type: "confirm",
73
+ name: "useCloudinary",
74
+ message: "Use Cloudinary?",
75
+ default: true,
76
+ when: ans => ans.useBackendFeatures
77
+ },
78
+ {
79
+ type: "confirm",
80
+ name: "useMongoose",
81
+ message: "Use MongoDB (Mongoose)?",
82
+ default: true,
83
+ when: ans => ans.useBackendFeatures
84
+ },
85
+ {
86
+ type: "confirm",
87
+ name: "useZod",
88
+ message: "Use Zod validation?",
89
+ default: true,
90
+ when: ans => ans.useBackendFeatures
91
+ },
92
+ {
93
+ type: "confirm",
94
+ name: "useDotenv",
95
+ message: "Use Dotenv?",
96
+ default: true,
97
+ when: ans => ans.useBackendFeatures
98
+ },
99
+ {
100
+ type: "confirm",
101
+ name: "useBcrypt",
102
+ message: "Use Bcrypt for password hashing?",
103
+ default: true,
104
+ when: ans => ans.useBackendFeatures
105
+ },
106
+ {
107
+ type: "confirm",
108
+ name: "useMulter",
109
+ message: "Use Multer for file uploads?",
110
+ default: true,
111
+ when: ans => ans.useBackendFeatures
112
+ }
113
+ ]);
114
+
115
+
116
+ /* -------------------------------------------------------------------------- */
117
+ /* MAP ANSWERS → TEMPLATE KEYS */
118
+ /* -------------------------------------------------------------------------- */
119
+
120
+ const frontendMap = {
121
+ React: {
122
+ JavaScript: "react-js",
123
+ TypeScript: "react-ts"
124
+ },
125
+ "Next.js": {
126
+ JavaScript: "next-js",
127
+ TypeScript: "next-ts"
128
+ },
129
+ None: "None"
130
+ };
131
+
132
+ const backendMap = {
133
+ Express: {
134
+ JavaScript: "express-js",
135
+ TypeScript: "express-ts"
136
+ }
137
+ };
138
+
139
+ /* -------------------------------------------------------------------------- */
140
+ /* BUILD backendFeatures ARRAY (IMPORTANT) */
141
+ /* -------------------------------------------------------------------------- */
142
+
143
+ const backendFeatures = [];
144
+
145
+ if (answers.useBackendFeatures) {
146
+ if (answers.useJWT) backendFeatures.push("JWT");
147
+ if (answers.useCORS) backendFeatures.push("CORS");
148
+ if (answers.useCookieParser) backendFeatures.push("Cookie-Parser");
149
+ if (answers.useMongoose) backendFeatures.push("Mongoose");
150
+ if (answers.useCloudinary) backendFeatures.push("Cloudinary");
151
+ if (answers.useZod) backendFeatures.push("Zod");
152
+ if (answers.useDotenv) backendFeatures.push("Dotenv");
153
+ if (answers.useBcrypt) backendFeatures.push("Bcrypt");
154
+ if (answers.useMulter) backendFeatures.push("Multer");
155
+ }
156
+
157
+ /* -------------------------------------------------------------------------- */
158
+ /* BUILD CONFIG OBJECT */
159
+ /* -------------------------------------------------------------------------- */
160
+
161
+ const config = {
162
+ projectName: answers.projectName,
163
+ frontend:
164
+ answers.frontend === "None"
165
+ ? "None"
166
+ : frontendMap[answers.frontend][answers.language],
167
+ backend: backendMap[answers.backend][answers.language],
168
+ backendFeatures // ✅ ALWAYS ARRAY
169
+ };
170
+
171
+ /* -------------------------------------------------------------------------- */
172
+ /* CREATE PROJECT */
173
+ /* -------------------------------------------------------------------------- */
174
+
175
+ await createProject(config);
package/package.json ADDED
@@ -0,0 +1,19 @@
1
+ {
2
+ "name": "create-fullstack-setup",
3
+ "version": "1.0.0",
4
+ "description": "CLI to generate ready-to-run fullstack or backend applications",
5
+ "bin": {
6
+ "create-fullstack-setup": "./bin/index.js"
7
+ },
8
+ "type": "module",
9
+ "keywords": [
10
+ "cli",
11
+ "express",
12
+ "fullstack",
13
+ "scaffold",
14
+ "typescript",
15
+ "javascript"
16
+ ],
17
+ "author": "Uttam Yadav",
18
+ "license": "MIT"
19
+ }
@@ -0,0 +1,6 @@
1
+ PORT=5000
2
+ MONGO_URI=
3
+ JWT_SECRET=
4
+ CLOUDINARY_CLOUD_NAME=
5
+ CLOUDINARY_API_KEY=
6
+ CLOUDINARY_API_SECRET=
@@ -0,0 +1,17 @@
1
+
2
+ class ApiError extends Error{
3
+ constructor(statusCode,message="failed",errors=[],stack){
4
+ super(message),
5
+ this.statusCode=statusCode,
6
+ this.errors=errors;
7
+
8
+ if(stack){
9
+ this.stack=stack
10
+ }
11
+ else{
12
+ Error.captureStackTrace(this,this.constructor);
13
+ }
14
+ }
15
+ }
16
+
17
+ export {ApiError}
@@ -0,0 +1,12 @@
1
+
2
+ class ApiResponse{
3
+ constructor(statusCode,data,message="sucess",sucess="sucess"){
4
+ this.statusCode=statusCode,
5
+ this.data=data,
6
+ this.message=message,
7
+ this.sucess=sucess
8
+ }
9
+
10
+ }
11
+
12
+ export {ApiResponse}
@@ -0,0 +1,8 @@
1
+ const AsyncHandler = (reqHandler) => {
2
+ return (req, res, next) => {
3
+ Promise.resolve(reqHandler(req, res, next))
4
+ .catch((error) => next(error));
5
+ };
6
+ };
7
+
8
+ export { AsyncHandler };
@@ -0,0 +1,31 @@
1
+ import { v2 as cloudinary } from 'cloudinary';
2
+ import fs from 'fs'
3
+
4
+ // Configuration
5
+ cloudinary.config({
6
+ cloud_name: process.env.CLOUDINARY_NAME,
7
+ api_key: process.env.CLOUDINARY_APIKEY,
8
+ api_secret:process.env.CLOUDINARY_APISECRET // Click 'View API Keys' above to copy your API secret
9
+ });
10
+
11
+ // Upload an image
12
+ const uploadonCloudinary=async(localfilePath)=>{
13
+ try{
14
+ if(!localfilePath) return null;
15
+ const response=await cloudinary.uploader.upload(localfilePath,{
16
+ resource_type:"auto"
17
+ });
18
+ console.log("image upload on cloudinary",response.url);
19
+
20
+ fs.unlinkSync(localfilePath) //delete temp file after succesful upload
21
+ return response;
22
+
23
+ }
24
+ catch(error){
25
+ fs.unlinkSync(localfilePath);
26
+ return null;
27
+ }
28
+
29
+ }
30
+
31
+ export {uploadonCloudinary}
@@ -0,0 +1,35 @@
1
+ import express from "express";
2
+ import dotenv from "dotenv";
3
+ import cors from "cors";
4
+ import cookieParser from "cookie-parser";
5
+
6
+ dotenv.config();
7
+
8
+ const app = express();
9
+
10
+ app.use(express.json({ limit: "16kb" }));
11
+ app.use(express.urlencoded({ extended: true, limit: "16kb" }));
12
+ app.use(cookieParser());
13
+
14
+ app.use(
15
+ cors({
16
+ origin:[ process.env.CORS_ORIGIN,
17
+ process.env.CORS_LOCAL_ORIGIN,
18
+ ],
19
+ credentials: true
20
+ })
21
+ );
22
+
23
+
24
+ const PORT = process.env.PORT || 3000;
25
+
26
+ connectDB()
27
+ .then(() => {
28
+ app.listen(PORT, () => {
29
+ console.log(`Server is running on port ${PORT}`);
30
+ });
31
+ })
32
+ .catch((error) => {
33
+ console.error("Database connection failed", error);
34
+ });
35
+