ydev-mern 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.
- package/README.md +76 -0
- package/backend/.env.example +1 -0
- package/backend/package-lock.json +1461 -0
- package/backend/package.json +20 -0
- package/backend/src/Server.js +15 -0
- package/backend/src/db.js +14 -0
- package/bin/cli.js +62 -0
- package/frontend/README.md +19 -0
- package/frontend/eslint.config.js +21 -0
- package/frontend/index.html +19 -0
- package/frontend/package-lock.json +2491 -0
- package/frontend/package.json +30 -0
- package/frontend/public/favicon.svg +1 -0
- package/frontend/public/icons.svg +24 -0
- package/frontend/src/App.css +732 -0
- package/frontend/src/App.jsx +424 -0
- package/frontend/src/assets/hero.png +0 -0
- package/frontend/src/assets/react.svg +1 -0
- package/frontend/src/assets/vite.svg +1 -0
- package/frontend/src/index.css +77 -0
- package/frontend/src/main.jsx +10 -0
- package/frontend/vite.config.js +11 -0
- package/package.json +31 -0
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "backend",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "",
|
|
5
|
+
"main": "index.js",
|
|
6
|
+
"scripts": {
|
|
7
|
+
"dev": "nodemon src/Server.js"
|
|
8
|
+
},
|
|
9
|
+
"keywords": [],
|
|
10
|
+
"author": "",
|
|
11
|
+
"license": "ISC",
|
|
12
|
+
"type": "module",
|
|
13
|
+
"dependencies": {
|
|
14
|
+
"cors": "^2.8.6",
|
|
15
|
+
"dotenv": "^17.4.2",
|
|
16
|
+
"express": "^5.2.1",
|
|
17
|
+
"mongoose": "^9.9.5",
|
|
18
|
+
"nodemon": "^3.1.14"
|
|
19
|
+
}
|
|
20
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import express from "express";
|
|
2
|
+
import { connectdb } from "../db.js";
|
|
3
|
+
|
|
4
|
+
const app = express();
|
|
5
|
+
|
|
6
|
+
app.use(express.json());
|
|
7
|
+
|
|
8
|
+
app.get('/', (req, res) => {
|
|
9
|
+
res.send("Backend is running");
|
|
10
|
+
})
|
|
11
|
+
|
|
12
|
+
app.listen(3000, () => {
|
|
13
|
+
console.log("Server started on port 3000");
|
|
14
|
+
connectdb();
|
|
15
|
+
})
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import mongoose from "moongoose";
|
|
2
|
+
import 'dotenv/config';
|
|
3
|
+
export const connectdb = async () => {
|
|
4
|
+
try {
|
|
5
|
+
const connection = await mongoose.connect(MONGO_URI);
|
|
6
|
+
|
|
7
|
+
console.log("Mongodb connected");
|
|
8
|
+
} catch (error) {
|
|
9
|
+
console.log(error);
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
}
|
package/bin/cli.js
ADDED
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
import fs from 'fs';
|
|
4
|
+
import path from 'path';
|
|
5
|
+
import { fileURLToPath } from 'url';
|
|
6
|
+
|
|
7
|
+
const __filename = fileURLToPath(import.meta.url);
|
|
8
|
+
const __dirname = path.dirname(__filename);
|
|
9
|
+
const rootPackageDir = path.resolve(__dirname, '..');
|
|
10
|
+
|
|
11
|
+
const targetArg = process.argv[2];
|
|
12
|
+
const targetDir = targetArg ? path.resolve(process.cwd(), targetArg) : process.cwd();
|
|
13
|
+
|
|
14
|
+
console.log('\n🚀 \x1b[36m\x1b[1mydev-mern\x1b[0m — Modern Full-Stack MERN Scaffolder');
|
|
15
|
+
console.log(`📦 Unpacking frontend & backend into: \x1b[33m${targetDir}\x1b[0m\n`);
|
|
16
|
+
|
|
17
|
+
function copyDirRecursive(src, dest) {
|
|
18
|
+
if (!fs.existsSync(dest)) {
|
|
19
|
+
fs.mkdirSync(dest, { recursive: true });
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
const entries = fs.readdirSync(src, { withFileTypes: true });
|
|
23
|
+
|
|
24
|
+
for (const entry of entries) {
|
|
25
|
+
const srcPath = path.join(src, entry.name);
|
|
26
|
+
const destPath = path.join(dest, entry.name);
|
|
27
|
+
|
|
28
|
+
if (entry.name === 'node_modules' || entry.name === 'dist' || entry.name === '.git') {
|
|
29
|
+
continue;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
if (entry.isDirectory()) {
|
|
33
|
+
copyDirRecursive(srcPath, destPath);
|
|
34
|
+
} else {
|
|
35
|
+
fs.copyFileSync(srcPath, destPath);
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
try {
|
|
41
|
+
const foldersToCopy = ['frontend', 'backend'];
|
|
42
|
+
|
|
43
|
+
for (const folder of foldersToCopy) {
|
|
44
|
+
const srcFolder = path.join(rootPackageDir, folder);
|
|
45
|
+
const destFolder = path.join(targetDir, folder);
|
|
46
|
+
|
|
47
|
+
if (fs.existsSync(srcFolder)) {
|
|
48
|
+
console.log(` ✓ Copying ${folder}/...`);
|
|
49
|
+
copyDirRecursive(srcFolder, destFolder);
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
console.log('\n\x1b[32m✔ Successfully installed ydev-mern!\x1b[0m\n');
|
|
54
|
+
console.log('Next steps:');
|
|
55
|
+
console.log(' 1. Setup Backend:');
|
|
56
|
+
console.log(' \x1b[35mcd backend && npm install && npm run dev\x1b[0m');
|
|
57
|
+
console.log(' 2. Setup Frontend:');
|
|
58
|
+
console.log(' \x1b[35mcd frontend && npm install && npm run dev\x1b[0m\n');
|
|
59
|
+
} catch (error) {
|
|
60
|
+
console.error('\x1b[31mError unpacking ydev-mern:\x1b[0m', error.message);
|
|
61
|
+
process.exit(1);
|
|
62
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
# React + Vite
|
|
2
|
+
|
|
3
|
+
This template provides a minimal setup to get React working in Vite with HMR and some ESLint rules.
|
|
4
|
+
|
|
5
|
+
Currently, two official plugins are available:
|
|
6
|
+
|
|
7
|
+
- [@vitejs/plugin-react](https://github.com/vitejs/vite-plugin-react/blob/main/packages/plugin-react) uses [Oxc](https://oxc.rs)
|
|
8
|
+
- [@vitejs/plugin-react-swc](https://github.com/vitejs/vite-plugin-react/blob/main/packages/plugin-react-swc) uses [SWC](https://swc.rs/)
|
|
9
|
+
|
|
10
|
+
## React Compiler
|
|
11
|
+
|
|
12
|
+
The React Compiler is enabled on this template. See [this documentation](https://react.dev/learn/react-compiler) for more information.
|
|
13
|
+
|
|
14
|
+
Note: This will impact Vite dev & build performances.
|
|
15
|
+
You can also try [the experimental native React Compiler support in plugin-react](https://github.com/vitejs/vite-plugin-react/blob/main/packages/plugin-react/README.md#rust-react-compiler) by using `compiler: true` in the plugin options instead of using the Babel plugin.
|
|
16
|
+
|
|
17
|
+
## Expanding the ESLint configuration
|
|
18
|
+
|
|
19
|
+
If you are developing a production application, we recommend using TypeScript with type-aware lint rules enabled. Check out the [TS template](https://github.com/vitejs/vite/tree/main/packages/create-vite/template-react-ts) for information on how to integrate TypeScript and [`typescript-eslint`](https://typescript-eslint.io) in your project.
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import js from '@eslint/js'
|
|
2
|
+
import globals from 'globals'
|
|
3
|
+
import reactHooks from 'eslint-plugin-react-hooks'
|
|
4
|
+
import reactRefresh from 'eslint-plugin-react-refresh'
|
|
5
|
+
import { defineConfig, globalIgnores } from 'eslint/config'
|
|
6
|
+
|
|
7
|
+
export default defineConfig([
|
|
8
|
+
globalIgnores(['dist']),
|
|
9
|
+
{
|
|
10
|
+
files: ['**/*.{js,jsx}'],
|
|
11
|
+
extends: [
|
|
12
|
+
js.configs.recommended,
|
|
13
|
+
reactHooks.configs.flat.recommended,
|
|
14
|
+
reactRefresh.configs.vite,
|
|
15
|
+
],
|
|
16
|
+
languageOptions: {
|
|
17
|
+
globals: globals.browser,
|
|
18
|
+
parserOptions: { ecmaFeatures: { jsx: true } },
|
|
19
|
+
},
|
|
20
|
+
},
|
|
21
|
+
])
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
<!doctype html>
|
|
2
|
+
<html lang="en">
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset="UTF-8" />
|
|
5
|
+
<link rel="icon" type="image/svg+xml" href="/vite.svg" />
|
|
6
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
7
|
+
<meta name="description" content="y-DEV — Next-generation developer toolkit for React & full-stack development. Install via npm i ydev." />
|
|
8
|
+
<meta name="keywords" content="ydev, y-DEV, npm package, developer toolkit, react, javascript" />
|
|
9
|
+
<title>y-DEV — Modern Developer Toolkit | npm i ydev</title>
|
|
10
|
+
<!-- Modern typography -->
|
|
11
|
+
<link rel="preconnect" href="https://fonts.googleapis.com">
|
|
12
|
+
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
|
|
13
|
+
<link href="https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@300;400;500;600;700;800&family=JetBrains+Mono:wght@400;500;600&display=swap" rel="stylesheet">
|
|
14
|
+
</head>
|
|
15
|
+
<body>
|
|
16
|
+
<div id="root"></div>
|
|
17
|
+
<script type="module" src="/src/main.jsx"></script>
|
|
18
|
+
</body>
|
|
19
|
+
</html>
|