UNPKG

create-vault

Version:

A CLI tool to instantly set up a Full Stack (MERN) or Backend project with a structured folder system and pre-installed dependencies.

177 lines (143 loc) 4.62 kB
export const FOLDERS = [ "server", "server/controllers", "server/models", "server/routes", "server/config", "server/middlewares", "server/utils", ]; export const DEFAULT_ENV = "MONGO_URI=\nPORT=3000\n"; export const GITIGNORE_CONTENT = "node_modules/\n.env\n"; export const FILES = [ { path: "README.md", content: `# 🚀 **Vault - Full Stack & Backend Starter CLI** 🔹 **Kickstart your development journey with Vault!** This CLI tool lets you instantly set up a fully functional backend or full-stack (MERN) application with just one command. No more manual configurations – just code! 🎯 --- ## ✨ **Features** ✅ **Choose between Full Stack (MERN) or Backend-only** ✅ **Pre-configured Express.js Backend** ✅ **MongoDB Integration with Mongoose** ✅ **Vite + React + Tanstack Router (Frontend)** ✅ **.env File for Easy Configuration** ✅ **Nodemon for Seamless Development** ✅ **Pre-structured Folder System** ✅ **Automatic Dependency Installation** --- ## 🚀 **Installation & Usage** Get started with a single command: \`\`\`sh npx create-vault@latest \`\`\` This command will prompt you to select: 📌 **Full Stack (MERN)** – Includes both frontend and backend. 📌 **Backend Only** – Generates only the server-side setup. --- ## 🏗 **Project Structure** Once generated, your project will look like this: \`\`\` 📁 my-project ├── 📁 app/ # Frontend (Only in Full Stack setup) │ ├── 📄 index.jsx │ └── ... ├── 📁 server/ # Backend │ ├── 📁 controllers/ │ ├── 📁 models/ │ ├── 📁 routes/ │ ├── 📁 config/ │ ├── 📁 middlewares/ │ ├── 📁 utils/ │ ├── 📄 .env │ ├── 📄 server.js │ ├── 📄 package.json │ └── 📄 .gitignore ├── 📄 README.md └── ... \`\`\` --- ## 🔧 **Running the Project** ### 🚀 **Start the Backend** \`\`\`sh cd my-project/server npm start \`\`\` Before running, update your MongoDB connection in \`.env\`: \`\`\`sh MONGO_URI=your_mongodb_connection_url PORT=3000 \`\`\` ### 🎨 **Start the Frontend (For Full Stack Setup)** \`\`\`sh cd my-project/app npm run dev \`\`\` --- ## 🛠 **Technologies Used** 💻 **Backend**: Node.js, Express.js, Mongoose, Dotenv, Cors, JSON Web Token (optional) 🎨 **Frontend (Full Stack Setup)**: Vite, React, Tanstack Router --- ## 🤝 **Contributing** 🔹 Want to make this even better? Fork the repo, make your changes, and submit a pull request! We welcome all contributions. 💡 --- ## 📜 **License** MIT License 📝 --- 🎉 **CRAZYYYY BHAI, SETUP COMPLETE HOGYA !!! 🚀** Happy coding! 🎊 `, }, { path: "server/controllers/controller.js", content: "// Controller logic\n", }, { path: "server/models/model.js", content: "// Model schema\n" }, { path: "server/routes/route.js", content: "// Routes setup\n" }, { path: "server/config/db.js", content: `import mongoose from 'mongoose'; const connectDB = async () => { try { const conn = await mongoose.connect(process.env.MONGO_URI); console.log(\`MongoDB Connected: \${conn.connection.host}\`); } catch (error) { console.error(\`Error: \${error.message}\`); process.exit(1); } }; export default connectDB; `, }, { path: "server/middlewares/auth.js", content: "// Middleware logic\n" }, { path: "server/utils/helper.js", content: "// Utility functions\n" }, { path: "server/.env", content: DEFAULT_ENV, }, { path: "server/.gitignore", content: GITIGNORE_CONTENT, }, { path: "server/server.js", content: `import express from 'express'; import connectDB from './config/db.js'; import dotenv from 'dotenv'; import cors from "cors"; dotenv.config(); const app = express(); const PORT = process.env.PORT || 3000; // Middlewares app.use(cors()); app.use(express.json()); app.use(express.urlencoded({ extended: true })); // Connect to MDB connectDB(); app.get('/', (req, res) => { res.send("Heyy!"); }); // Start server app.listen(PORT, () => console.log(\`Server running on http://localhost:\${PORT}\`)); `, }, ];