create-frontify-backend 1.0.12

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 (30) hide show
  1. package/bin/index.js +59 -0
  2. package/package.json +31 -0
  3. package/templates/backend/my-backend-template/.env.example +13 -0
  4. package/templates/backend/my-backend-template/README.md +177 -0
  5. package/templates/backend/my-backend-template/eslint.config.js +30 -0
  6. package/templates/backend/my-backend-template/eslint.config.mjs +35 -0
  7. package/templates/backend/my-backend-template/package-lock.json +4738 -0
  8. package/templates/backend/my-backend-template/package.json +43 -0
  9. package/templates/backend/my-backend-template/server.js +11 -0
  10. package/templates/backend/my-backend-template/src/app.js +57 -0
  11. package/templates/backend/my-backend-template/src/config/config.js +24 -0
  12. package/templates/backend/my-backend-template/src/config/db.js +18 -0
  13. package/templates/backend/my-backend-template/src/config/email.config.js +19 -0
  14. package/templates/backend/my-backend-template/src/constants/constants.js +5 -0
  15. package/templates/backend/my-backend-template/src/controllers/auth.controller.js +196 -0
  16. package/templates/backend/my-backend-template/src/dao/user.dao.js +86 -0
  17. package/templates/backend/my-backend-template/src/loggers/morgan.logger.js +11 -0
  18. package/templates/backend/my-backend-template/src/loggers/winston.logger.js +64 -0
  19. package/templates/backend/my-backend-template/src/middlewares/auth.middleware.js +64 -0
  20. package/templates/backend/my-backend-template/src/middlewares/error.handler.js +28 -0
  21. package/templates/backend/my-backend-template/src/middlewares/rateLimiter.middleware.js +31 -0
  22. package/templates/backend/my-backend-template/src/middlewares/validator.middleware.js +66 -0
  23. package/templates/backend/my-backend-template/src/models/user.model.js +54 -0
  24. package/templates/backend/my-backend-template/src/routes/auth.routes.js +68 -0
  25. package/templates/backend/my-backend-template/src/services/userServices.js +179 -0
  26. package/templates/backend/my-backend-template/src/utils/appError.js +17 -0
  27. package/templates/backend/my-backend-template/src/utils/asyncHandler.js +5 -0
  28. package/templates/backend/my-backend-template/src/utils/password.js +20 -0
  29. package/templates/backend/my-backend-template/src/utils/sendEmail.js +17 -0
  30. package/templates/backend/my-backend-template/src/validators/auth.validator.js +99 -0
package/bin/index.js ADDED
@@ -0,0 +1,59 @@
1
+ #!/usr/bin/env node
2
+
3
+ import fs from "fs";
4
+ import path from "path";
5
+ import { execSync } from "child_process";
6
+ import { fileURLToPath } from "url";
7
+
8
+ /* ------------------ Resolve __dirname in ESM ------------------ */
9
+ const __filename = fileURLToPath(import.meta.url);
10
+ const __dirname = path.dirname(__filename);
11
+
12
+ /* ------------------ Get project name ------------------ */
13
+ const projectName = process.argv[2];
14
+
15
+ if (!projectName) {
16
+ console.error("❌ Please provide a project name");
17
+ process.exit(1);
18
+ }
19
+
20
+ /* ------------------ Paths ------------------ */
21
+ const targetDir = path.join(process.cwd(), projectName);
22
+
23
+ // 👇 THIS MUST MATCH YOUR REAL TEMPLATE FOLDER NAME
24
+ const templateDir = path.join(
25
+ __dirname,
26
+ "../templates/backend/my-backend-template"
27
+ );
28
+
29
+ /* ------------------ Validate template ------------------ */
30
+ if (!fs.existsSync(templateDir)) {
31
+ console.error("❌ Template folder not found at:");
32
+ console.error(templateDir);
33
+ process.exit(1);
34
+ }
35
+
36
+ if (fs.existsSync(targetDir)) {
37
+ console.error("❌ Folder already exists:", projectName);
38
+ process.exit(1);
39
+ }
40
+
41
+ /* ------------------ Copy template ------------------ */
42
+ fs.cpSync(templateDir, targetDir, { recursive: true });
43
+
44
+ /* ------------------ Init git & install ------------------ */
45
+ try {
46
+ execSync("git init", { cwd: targetDir, stdio: "inherit" });
47
+ execSync("npm install", { cwd: targetDir, stdio: "inherit" });
48
+ } catch (err) {
49
+ console.warn("⚠️ Git or npm install failed. You can run manually.");
50
+ }
51
+
52
+ /* ------------------ Done ------------------ */
53
+ console.log(`
54
+ ✅ Backend project created successfully!
55
+
56
+ Next steps:
57
+ cd ${projectName}
58
+ npm run dev
59
+ `);
package/package.json ADDED
@@ -0,0 +1,31 @@
1
+ {
2
+ "name": "create-frontify-backend",
3
+ "version": "1.0.12",
4
+ "description": "CLI to create a clean and independent backend starter project",
5
+ "license": "ISC",
6
+ "type": "module",
7
+ "bin": {
8
+ "backend-starter": "bin/index.js"
9
+ },
10
+ "files": [
11
+ "bin",
12
+ "templates"
13
+ ],
14
+ "repository": {
15
+ "type": "git",
16
+ "url": "https://github.com/FrontifybyHB/backend-starter-cli.git"
17
+ },
18
+ "bugs": {
19
+ "url": "https://github.com/FrontifybyHB/backend-starter-cli/issues"
20
+ },
21
+ "homepage": "https://github.com/FrontifybyHB/backend-starter-cli#readme",
22
+ "keywords": [
23
+ "backend",
24
+ "starter",
25
+ "cli",
26
+ "node",
27
+ "express",
28
+ "api",
29
+ "boilerplate"
30
+ ]
31
+ }
@@ -0,0 +1,13 @@
1
+ PORT=3000
2
+ DB_URL=mongodb://host:example.com
3
+ JWT_SECRET=JWT_SECRET_KEY
4
+ GOOGLE_CLIENT_ID=GOOGLE_CLIENT_ID
5
+ GOOGLE_CLIENT_SECRET=GOOGLE_CLIENT_SECRET
6
+ GMAIL_USER=GOOGLE_GMAIL_USER
7
+ GOOGLE_REFRESH_TOKEN=GOOGLE_REFRESH_TOKEN
8
+ GOOGLE_CALLBACK_URL=http://localhost:3000/api/v1/auth/google/callback
9
+ EMAIL_HOST=smtp.gmail.com
10
+ EMAIL_PORT=587
11
+ EMAIL_USER=your-email@gmail.com
12
+ EMAIL_PASSWORD=your-app-password
13
+
@@ -0,0 +1,177 @@
1
+ ## Backend Starter Project
2
+
3
+ Sure 👍
4
+ Below is a **clean, industry-ready GitHub README description** for your **Firebase Authentication project**.
5
+ You can directly **copy–paste** this into your repo’s `README.md`.
6
+
7
+ ---
8
+
9
+ # 🔐 Firebase Authentication System
10
+
11
+ A modern and secure authentication system built using **Firebase Authentication**, allowing users to **sign up and log in using Email & Password** as well as **Google Sign-In**.
12
+ This project is designed as a **starter kit** for real-world web applications.
13
+
14
+ ---
15
+
16
+ ## ✨ Features
17
+
18
+ * ✅ Email & Password Authentication
19
+ * ✅ Google OAuth Login
20
+ * ✅ Secure Firebase Authentication
21
+ * ✅ User session handling
22
+ * ✅ Clean and scalable project structure
23
+ * ✅ Ready to integrate with any frontend (React / Next.js)
24
+
25
+ ---
26
+
27
+ ## 🛠️ Tech Stack
28
+
29
+ * **Frontend:** React (or your framework)
30
+ * **Authentication:** Firebase Authentication
31
+ * **OAuth Provider:** Google
32
+ * **Language:** JavaScript / TypeScript
33
+ * **Package Manager:** npm / yarn
34
+
35
+ ---
36
+
37
+ ## 🔑 Authentication Methods
38
+
39
+ ### 1️⃣ Email & Password Login
40
+
41
+ * User registration with email and password
42
+ * Secure login using Firebase Auth
43
+ * Error handling for invalid credentials
44
+
45
+ ### 2️⃣ Google Sign-In
46
+
47
+ * One-click login using Google account
48
+ * OAuth handled securely by Firebase
49
+ * Automatic user profile creation
50
+
51
+ ---
52
+
53
+ ## 📂 Project Structure (Example)
54
+
55
+ ```txt
56
+ src/
57
+ ├─ firebase/
58
+ │ └─ firebase.config.js
59
+ ├─ auth/
60
+ │ ├─ login.js
61
+ │ ├─ register.js
62
+ │ └─ googleAuth.js
63
+ ├─ components/
64
+ ├─ pages/
65
+ └─ App.js
66
+ ```
67
+
68
+ ---
69
+
70
+ ## 🚀 Getting Started
71
+
72
+ ### 1️⃣ Clone the Repository
73
+
74
+ ```bash
75
+ git clone https://github.com/your-username/your-repo-name.git
76
+ cd your-repo-name
77
+ ```
78
+
79
+ ---
80
+
81
+ ### 2️⃣ Install Dependencies
82
+
83
+ ```bash
84
+ npm install
85
+ ```
86
+
87
+ ---
88
+
89
+ ### 3️⃣ Firebase Setup
90
+
91
+ 1. Go to 👉 [https://console.firebase.google.com](https://console.firebase.google.com)
92
+ 2. Create a new project
93
+ 3. Enable **Authentication**
94
+ 4. Enable:
95
+
96
+ * Email/Password
97
+ * Google Provider
98
+ 5. Copy your Firebase config
99
+
100
+ ```js
101
+ const firebaseConfig = {
102
+ apiKey: "YOUR_API_KEY",
103
+ authDomain: "YOUR_AUTH_DOMAIN",
104
+ projectId: "YOUR_PROJECT_ID",
105
+ appId: "YOUR_APP_ID",
106
+ };
107
+ ```
108
+
109
+ ---
110
+
111
+ ### 4️⃣ Run the Project
112
+
113
+ ```bash
114
+ npm run dev
115
+ ```
116
+
117
+ ---
118
+
119
+ ## 🔒 Security Notes
120
+
121
+ * Firebase handles password hashing internally
122
+ * OAuth tokens are securely managed
123
+ * No sensitive keys should be pushed to GitHub
124
+ * Use `.env` for environment variables
125
+
126
+ ---
127
+
128
+ ## 🎯 Use Cases
129
+
130
+ * Authentication starter kit
131
+ * SaaS dashboards
132
+ * Admin panels
133
+ * Personal projects
134
+ * Production-ready auth flow
135
+
136
+ ---
137
+
138
+ ## 📌 Future Improvements
139
+
140
+ * 🔄 Password reset
141
+ * 🔐 Email verification
142
+ * 🧠 Role-based authentication
143
+ * 📱 Phone number login
144
+ * 🛡 Protected routes
145
+
146
+ ---
147
+
148
+ ## 🤝 Contributing
149
+
150
+ Contributions are welcome!
151
+ Feel free to open issues or submit pull requests.
152
+
153
+ ---
154
+
155
+ ## 📜 License
156
+
157
+ This project is licensed under the **MIT License**.
158
+
159
+ ---
160
+
161
+ ## 👨‍💻 Author
162
+
163
+ **Himanshu Bhindoriya**
164
+ Frontend / Full-Stack Developer
165
+ 🚀 Learning • Building • Improving
166
+
167
+ ---
168
+
169
+ If you want, I can also:
170
+
171
+ * Make a **short GitHub repo description (1–2 lines)**
172
+ * Add **badges** (Firebase, React, MIT)
173
+ * Customize this README for **Next.js / Vite**
174
+ * Write a **professional LinkedIn post** for this repo
175
+
176
+ Just tell me 😄
177
+
@@ -0,0 +1,30 @@
1
+ import eslintPluginImport from 'eslint-plugin-import';
2
+
3
+ export default [
4
+ {
5
+ files: ['**/*.js'],
6
+ languageOptions: {
7
+ ecmaVersion: 'latest',
8
+ sourceType: 'module',
9
+ },
10
+ plugins: {
11
+ import: eslintPluginImport,
12
+ },
13
+ settings: {
14
+ 'import/resolver': {
15
+ node: {
16
+ extensions: ['.js', '.json'],
17
+ },
18
+ },
19
+ },
20
+ rules: {
21
+ 'no-unused-vars': 'warn',
22
+ 'no-console': 'warn',
23
+ 'import/order': [
24
+ 'warn',
25
+ { groups: [['builtin', 'external', 'internal']] },
26
+ ],
27
+ 'import/no-unresolved': 'error',
28
+ },
29
+ },
30
+ ];
@@ -0,0 +1,35 @@
1
+ import js from "@eslint/js";
2
+ import globals from "globals";
3
+ import eslintPluginImport from 'eslint-plugin-import';
4
+
5
+ export default [
6
+ {
7
+ files: ["**/*.{js,mjs,cjs}"],
8
+ languageOptions: {
9
+ ecmaVersion: 'latest',
10
+ sourceType: 'module',
11
+ globals: globals.browser
12
+ },
13
+ plugins: {
14
+ js,
15
+ import: eslintPluginImport,
16
+ },
17
+ settings: {
18
+ 'import/resolver': {
19
+ node: {
20
+ extensions: ['.js', '.mjs', '.cjs', '.json'],
21
+ },
22
+ },
23
+ },
24
+ rules: {
25
+ ...js.configs.recommended.rules,
26
+ 'no-unused-vars': 'warn',
27
+ 'no-console': 'warn',
28
+ 'import/order': [
29
+ 'warn',
30
+ { groups: [['builtin', 'external', 'internal']] },
31
+ ],
32
+ 'import/no-unresolved': 'error',
33
+ },
34
+ },
35
+ ];