create-prod-backend 1.3.6 → 1.4.7

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/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # create-prod-backend
2
2
 
3
- Build a **production-ready Express backend** in seconds — no boilerplate, no setup headaches.
3
+ Build a **production-ready Next.js App & Express backend** in seconds — no boilerplate, no setup headaches.
4
4
 
5
5
  ---
6
6
 
@@ -35,6 +35,7 @@ create-prod-backend
35
35
 
36
36
  ## What It Generates
37
37
 
38
+ ### Express Backend
38
39
  ```
39
40
  project-name/
40
41
 
@@ -51,13 +52,42 @@ project-name/
51
52
  │ └── constants.js
52
53
 
53
54
  ├── public/
54
-
55
+ └──temp/
56
+ |
55
57
  ├── .env
58
+ ├── Dockerfile
59
+ ├── .dockerignore
60
+ ├── docker-compose.yml
56
61
  ├── .gitignore
57
62
  ├── package.json
58
63
  └── README.md
59
64
  ```
60
65
 
66
+ ### Next.js App
67
+
68
+ ```
69
+ my-app/
70
+ │── app/
71
+ │ ├── layout.js
72
+ │ ├── page.js
73
+ │ ├── globals.css
74
+
75
+ │── public/
76
+ │ ├── favicon.ico
77
+ │ ├── images...
78
+
79
+ │── node_modules/
80
+
81
+ │── package.json
82
+ │── package-lock.json / yarn.lock
83
+ │── next.config.js
84
+ │── jsconfig.json / tsconfig.json
85
+ │── .gitignore
86
+ │── README.md
87
+
88
+ ```
89
+
90
+
61
91
  ---
62
92
 
63
93
  ## Usage
@@ -134,8 +164,8 @@ Your backend is ready!
134
164
 
135
165
  * Service layer support
136
166
  * Auth template (JWT)
137
- * Docker setup
138
- * API documentation (Swagger)
167
+ * Docker setup - ✔️
168
+ * Soon Implement own Next.js - currently uses vercel package
139
169
  * TypeScript support
140
170
 
141
171
  ---
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-prod-backend",
3
- "version": "1.3.6",
3
+ "version": "1.4.7",
4
4
  "description": "A cli tool to generate a production-ready backend boilerplate with Express.js, MongoDB, and essential features.",
5
5
  "main": "index.js",
6
6
  "bin": {
package/src/index.js CHANGED
@@ -1,17 +1,33 @@
1
1
  import inquirer from "inquirer";
2
2
  import questions from "./prompts/questions.js";
3
3
  import { createProject } from "./core/createProject.js";
4
+ import { execSync } from "child_process";
4
5
  import chalk from "chalk";
5
6
 
6
7
  export default async function runCLI() {
7
8
  console.log(chalk.bold.cyan("\n------------------Welcome to the CREATE-PROD-BACKEND CLI------------------\n"));
8
9
 
9
10
  try {
11
+ const backendapp = await inquirer.prompt([
12
+ {
13
+ type: "select",
14
+ name: "usebackend",
15
+ message: chalk.bold.yellow("What do you want to create?"),
16
+ choices: ["Express Backend", "Next.js App"],
17
+ },
18
+ ]);
19
+
20
+ if (backendapp.usebackend === "Next.js App") {
21
+ execSync("npx create-next-app@latest", { stdio: "inherit" });
22
+ return;
23
+ }
24
+
10
25
  const answer = await inquirer.prompt(questions);
11
26
 
12
27
  await createProject(answer);
13
28
 
14
29
  console.log(chalk.green(`\n${chalk.bold(answer.projectName)} project created successfully!\n`));
30
+ console.log(chalk.yellow("You can change Docker file according to your need"));
15
31
  console.log(chalk.yellow("Happy coding! :)"));
16
32
  } catch (error) {
17
33
  console.error(chalk.red(("Error:", error.message)));
@@ -18,6 +18,11 @@ export default [
18
18
  name: "useMongo",
19
19
  message: chalk.bold.yellow("Do you want MongoDB?"),
20
20
  },
21
+ {
22
+ type: "confirm",
23
+ name: "useDocker",
24
+ message: chalk.bold.yellow("Do you want Docker Setup?")
25
+ },
21
26
  {
22
27
  type: "confirm",
23
28
  name: "ENV",
@@ -2,21 +2,24 @@ import fs from "fs";
2
2
  import path from "path";
3
3
 
4
4
  import { indexTemplate } from "../templates/base/index.template.js";
5
+ import { dockerfileTemplate } from "../templates/docker-setup/docker.template.js"
5
6
  import { appTemplate } from "../templates/base/app.template.js";
6
7
  import { mongoTemplate } from "../templates/db/mongo.template.js";
7
8
  import { envTemplate } from "../templates/config/env.template.js";
8
9
  import { utilsTemplates } from "../templates/utils/utils.template.js";
10
+ import { dockercomposeTemplate } from "../templates/docker-setup/dockercompose.template.js"
11
+ import { dockerignoreTemplate } from "../templates/docker-setup/dockerignore.template.js"
9
12
 
10
13
  export function createFiles(projectPath, answer) {
11
14
  // index.js
12
15
  fs.writeFileSync(
13
- path.join(projectPath,"src", "index.js"),
16
+ path.join(projectPath, "src", "index.js"),
14
17
  indexTemplate(answer)
15
18
  );
16
19
 
17
20
  // app.js
18
21
  fs.writeFileSync(
19
- path.join(projectPath,"src", "app.js"),
22
+ path.join(projectPath, "src", "app.js"),
20
23
  appTemplate(answer)
21
24
  );
22
25
 
@@ -44,6 +47,13 @@ export function createFiles(projectPath, answer) {
44
47
  fs.writeFileSync(path.join(projectPath, ".env"), envTemplate(answer));
45
48
  }
46
49
 
50
+ // docker
51
+ if (answer.useDocker) {
52
+ fs.writeFileSync(path.join(projectPath, 'Dockerfile'), dockerfileTemplate());
53
+ fs.writeFileSync(path.join(projectPath, 'docker-compose.yml'), dockercomposeTemplate());
54
+ fs.writeFileSync(path.join(projectPath, '.dockerignore'), dockerignoreTemplate());
55
+ }
56
+
47
57
  fs.writeFileSync(
48
58
  path.join(projectPath, "README.md"),
49
59
  `# ${answer.projectName}\n\nGenerated with create-prod-backend CLI. Customize your README to provide instructions and information about your project. \n\n## Setup\n\n1. Install dependencies: \`npm install\`\n2. Start the server: \`npm start\` \n\n## Environment Variables\n\n- \`PORT\`: Port number for the server (default: 3000)\n- \`MONGO_URI\`: MongoDB connection string (if using MongoDB)\n- \`JWT_SECRET\`: Secret key for JWT authentication (if using auth)\n- \`CLOUDINARY_CLOUD_NAME\`, \`CLOUDINARY_API_KEY\`, \`CLOUDINARY_API_SECRET\`: Cloudinary credentials (if using file upload) \n\n## Features\n\n- Express server setup\n- CORS enabled\n- Environment variable support with dotenv\n${answer.auth ? "- JWT authentication with jsonwebtoken and bcrypt\n" : ""}${answer.validation ? "- Request validation with Zod\n" : ""}${answer.fileUpload ? "- File upload handling with Multer and Cloudinary\n" : ""}${answer.devTools ? "- Development tools with Nodemon\n" : ""}${answer.useMongo ? "- MongoDB integration with Mongoose\n" : ""}\n\n## License\n\nThis project is licensed under the ISC License. \n\n---\n\n*Generated by [create-prod-backend](https://www.npmjs.com/package/create-prod-backend)*`
@@ -0,0 +1,19 @@
1
+ export const dockerfileTemplate = () => `
2
+ # Base image
3
+ FROM node:18-alpine
4
+
5
+ # Set working directory
6
+ WORKDIR /app
7
+
8
+ # Copy package files
9
+ COPY package*.json ./
10
+
11
+ # Install dependencies
12
+ RUN npm install
13
+
14
+ # Copy source code
15
+ COPY . .
16
+
17
+ # Start server
18
+ ENTRYPOINT ["node", "src/index.js"]
19
+ `;
@@ -0,0 +1,18 @@
1
+ export const dockercomposeTemplate = () => {
2
+ return `
3
+ version: "3.8"
4
+
5
+ services:
6
+ app:
7
+ build: .
8
+ container_name: node_app
9
+ ports:
10
+ - "5000:5000"
11
+ volumes:
12
+ - .:/app
13
+ - /app/node_modules
14
+ environment:
15
+ - PORT=5000
16
+ command: npm run dev
17
+ `;
18
+ };
@@ -0,0 +1,24 @@
1
+ export const dockerignoreTemplate = () => `
2
+ node_modules/
3
+ npm-debug.log
4
+ yarn-error.log
5
+
6
+ .git
7
+ .gitignore
8
+
9
+ .env
10
+ .env.local
11
+
12
+ Dockerfile
13
+ docker-compose.yml
14
+ .dockerignore
15
+
16
+ coverage
17
+ dist
18
+ build
19
+
20
+ .vscode
21
+ .idea
22
+
23
+ *.log
24
+ `