create-rex-app 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 (53) hide show
  1. package/index.js +148 -0
  2. package/package.json +31 -0
  3. package/template/README.md +71 -0
  4. package/template/_gitignore +25 -0
  5. package/template/api/routes.js +9 -0
  6. package/template/eslint.config.js +29 -0
  7. package/template/index.html +13 -0
  8. package/template/package-lock.json +4667 -0
  9. package/template/package.json +33 -0
  10. package/template/public/rex logo.png +0 -0
  11. package/template/public/rex.png +0 -0
  12. package/template/server.js +77 -0
  13. package/template/src/App.css +42 -0
  14. package/template/src/App.jsx +326 -0
  15. package/template/src/assets/react.svg +1 -0
  16. package/template/src/hooks/useTest.js +18 -0
  17. package/template/src/index.css +1 -0
  18. package/template/src/main.jsx +14 -0
  19. package/template/vercel.json +8 -0
  20. package/template/vite.config.js +7 -0
  21. package/template-mongo/README.md +96 -0
  22. package/template-mongo/api/db.js +17 -0
  23. package/template-mongo/api/middleware/authMiddleware.js +31 -0
  24. package/template-mongo/api/models/User.js +28 -0
  25. package/template-mongo/api/routes.js +99 -0
  26. package/template-mongo/env-sample.txt +3 -0
  27. package/template-mongo/eslint.config.js +29 -0
  28. package/template-mongo/index.html +13 -0
  29. package/template-mongo/package-lock.json +5076 -0
  30. package/template-mongo/package.json +38 -0
  31. package/template-mongo/public/rex logo.png +0 -0
  32. package/template-mongo/public/rex.png +0 -0
  33. package/template-mongo/public/vite.svg +1 -0
  34. package/template-mongo/server.js +80 -0
  35. package/template-mongo/src/App.css +42 -0
  36. package/template-mongo/src/App.jsx +42 -0
  37. package/template-mongo/src/assets/react.svg +1 -0
  38. package/template-mongo/src/components/Layout.jsx +85 -0
  39. package/template-mongo/src/components/PublicOnly.jsx +17 -0
  40. package/template-mongo/src/components/RequireAuth.jsx +20 -0
  41. package/template-mongo/src/context/AuthContext.jsx +35 -0
  42. package/template-mongo/src/hooks/useAuthContext.js +11 -0
  43. package/template-mongo/src/hooks/useLogin.js +42 -0
  44. package/template-mongo/src/hooks/useSignup.js +23 -0
  45. package/template-mongo/src/hooks/useTest.js +18 -0
  46. package/template-mongo/src/index.css +1 -0
  47. package/template-mongo/src/main.jsx +18 -0
  48. package/template-mongo/src/pages/Docs.jsx +131 -0
  49. package/template-mongo/src/pages/Home.jsx +93 -0
  50. package/template-mongo/src/pages/Login.jsx +97 -0
  51. package/template-mongo/src/pages/Signup.jsx +112 -0
  52. package/template-mongo/vercel.json +13 -0
  53. package/template-mongo/vite.config.js +7 -0
@@ -0,0 +1,93 @@
1
+ import { Link } from 'react-router-dom'
2
+ import { useAuthContext } from '../hooks/useAuthContext'
3
+
4
+ const Home = () => {
5
+ const { user } = useAuthContext()
6
+
7
+ return (
8
+ <div className="relative min-h-[80vh] flex items-center z-10">
9
+
10
+ {/* BACKGROUND ORBS (Changed to fixed to prevent scrollbar/white patch) */}
11
+ <div className="fixed top-1/4 left-1/4 w-[500px] h-[500px] bg-[radial-gradient(circle,_#7C3AED,_transparent_60%)] opacity-10 blur-[100px] pointer-events-none -z-10"></div>
12
+ <div className="fixed bottom-1/4 right-1/4 w-[400px] h-[400px] bg-[radial-gradient(circle,_#F97316,_transparent_60%)] opacity-10 blur-[100px] pointer-events-none -z-10"></div>
13
+
14
+ {/* TWO-COLUMN CONTAINER */}
15
+ <div className="w-full max-w-7xl mx-auto flex flex-col lg:flex-row items-center gap-12 lg:gap-20">
16
+
17
+ {/* LEFT SIDE: LOGO IMAGE */}
18
+ <div className="flex-1 w-full max-w-sm lg:max-w-md mx-auto relative group">
19
+ {/* Animated glow behind the image */}
20
+ <div className="absolute inset-0 bg-gradient-to-br from-purple-600 to-orange-500 blur-3xl opacity-20 group-hover:opacity-40 transition-opacity duration-700 rounded-full"></div>
21
+ {/* Static image with subtle hover scale instead of bouncing */}
22
+ <img
23
+ src="/rex logo.png"
24
+ alt="Rex Logo"
25
+ className="relative z-10 w-full h-auto object-contain drop-shadow-2xl transition-transform duration-500 hover:scale-105"
26
+ />
27
+ </div>
28
+
29
+ {/* RIGHT SIDE: TEXT & CTA */}
30
+ <div className="flex-1 flex flex-col items-center lg:items-start text-center lg:text-left">
31
+
32
+ {/* Dynamic Badge */}
33
+ <div className="inline-flex items-center gap-2 bg-white/5 border border-white/10 text-slate-300 px-4 py-1.5 rounded-full text-xs font-mono font-semibold tracking-wider uppercase mb-6 shadow-lg">
34
+ <span className="w-2 h-2 rounded-full bg-orange-400 animate-pulse"></span>
35
+ {user ? 'Authenticated Session' : 'Powered by Rex'}
36
+ </div>
37
+
38
+ <h1 className="text-5xl sm:text-6xl lg:text-7xl font-extrabold tracking-tight leading-[1.1] mb-6">
39
+ {user ? (
40
+ <>
41
+ Welcome back,<br/>
42
+ <span className="bg-gradient-to-r from-purple-400 to-orange-400 bg-clip-text text-transparent">
43
+ {user.name}!
44
+ </span>
45
+ </>
46
+ ) : (
47
+ <>
48
+ One House.<br/>
49
+ <span className="bg-gradient-to-r from-purple-400 to-orange-400 bg-clip-text text-transparent">
50
+ Full Stack.
51
+ </span>
52
+ </>
53
+ )}
54
+ </h1>
55
+
56
+ <p className="text-lg sm:text-xl text-slate-400 max-w-xl leading-relaxed mb-10">
57
+ {user
58
+ ? <>You are logged in as a <strong className="text-white uppercase tracking-wide text-sm bg-white/10 px-2 py-1 rounded mx-1">{user.role}</strong>. Ready to build something <span className="text-purple-400 italic font-medium">dhaasu</span> in your unified workspace?</>
59
+ : 'Experience the ultimate boilerplate. Express rules the backend, React powers the frontend, and MongoDB stores the data—all in a single, blazing-fast setup.'
60
+ }
61
+ </p>
62
+
63
+ {/* BUTTONS SECTION */}
64
+ <div className="flex flex-col sm:flex-row gap-4 w-full sm:w-auto justify-center lg:justify-start">
65
+ {user ? (
66
+ // --- LOGGED IN USERS SEE THIS ---
67
+ <>
68
+ <button className="px-8 py-3.5 bg-gradient-to-r from-purple-600 to-orange-500 text-white rounded-xl font-bold shadow-[0_0_30px_rgba(124,58,237,0.3)] hover:-translate-y-1 hover:shadow-[0_0_50px_rgba(124,58,237,0.5)] transition-all">
69
+ Go to Dashboard
70
+ </button>
71
+
72
+ <Link to="/docs" className="px-8 py-3.5 bg-white/5 border border-white/10 text-slate-200 hover:bg-white/10 hover:border-purple-500/40 rounded-xl font-semibold hover:-translate-y-1 transition-all flex items-center justify-center gap-2">
73
+ Documentation
74
+ <svg width="16" height="16" fill="none" viewBox="0 0 24 24" stroke="currentColor" strokeWidth="2">
75
+ <path strokeLinecap="round" strokeLinejoin="round" d="M12 15v2m-6 4h12a2 2 0 00-2-2H6a2 2 0 00-2 2v6a2 2 0 002 2zm10-10V7a4 4 0 00-8 0v4h8z" />
76
+ </svg>
77
+ </Link>
78
+ </>
79
+ ) : (
80
+ // --- GUESTS SEE THIS ---
81
+ <Link to="/signup" className="px-8 py-3.5 bg-gradient-to-r from-purple-600 to-orange-500 text-white rounded-xl font-bold shadow-[0_0_30px_rgba(124,58,237,0.3)] hover:-translate-y-1 hover:shadow-[0_0_50px_rgba(124,58,237,0.5)] transition-all flex justify-center">
82
+ Create Account
83
+ </Link>
84
+ )}
85
+ </div>
86
+
87
+ </div>
88
+ </div>
89
+ </div>
90
+ )
91
+ }
92
+
93
+ export default Home
@@ -0,0 +1,97 @@
1
+ import { useState } from 'react'
2
+ import { useLogin } from '../hooks/useLogin'
3
+ import { Link } from 'react-router-dom'
4
+
5
+ const Login = () => {
6
+ const [formData, setFormData] = useState({ email: '', password: '' })
7
+ const { mutate, isPending } = useLogin()
8
+
9
+ const handleChange = (e) => setFormData({ ...formData, [e.target.name]: e.target.value })
10
+
11
+ const handleSubmit = (e) => {
12
+ e.preventDefault()
13
+ mutate(formData)
14
+ }
15
+
16
+ return (
17
+ <div className="relative flex flex-col items-center justify-center min-h-[80vh] z-10 px-4">
18
+
19
+ {/* BACKGROUND ORB */}
20
+ <div className="absolute top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2 w-[400px] h-[400px] bg-[radial-gradient(circle,_#7C3AED,_transparent_60%)] opacity-10 blur-[80px] pointer-events-none -z-10"></div>
21
+
22
+ {/* LOGIN CARD */}
23
+ <div className="w-full max-w-md bg-white/[0.02] border border-white/10 p-8 sm:p-10 rounded-3xl shadow-2xl backdrop-blur-md">
24
+
25
+ <div className="text-center mb-8">
26
+ <div className="inline-flex items-center justify-center w-12 h-12 rounded-xl bg-purple-500/10 border border-purple-500/20 mb-4 text-purple-400">
27
+ <svg width="24" height="24" fill="none" viewBox="0 0 24 24" stroke="currentColor" strokeWidth="2">
28
+ <path strokeLinecap="round" strokeLinejoin="round" d="M11 16l-4-4m0 0l4-4m-4 4h14m-5 4v1a3 3 0 01-3 3H6a3 3 0 01-3-3V7a3 3 0 013-3h7a3 3 0 013 3v1" />
29
+ </svg>
30
+ </div>
31
+ <h2 className="text-3xl font-extrabold text-white tracking-tight">
32
+ Welcome <span className="bg-gradient-to-r from-purple-400 to-orange-400 bg-clip-text text-transparent">Back</span>
33
+ </h2>
34
+ </div>
35
+
36
+ <form onSubmit={handleSubmit} className="flex flex-col gap-5">
37
+ <div>
38
+ <label className="block text-xs font-semibold text-slate-400 uppercase tracking-wider mb-2 ml-1">Email Address</label>
39
+ <input
40
+ type="email"
41
+ name="email"
42
+ placeholder="saumya@dev.com"
43
+ onChange={handleChange}
44
+ className="w-full p-3.5 rounded-xl bg-black/40 border border-white/10 focus:border-purple-500 focus:ring-1 focus:ring-purple-500 outline-none text-white placeholder-slate-600 transition-all"
45
+ required
46
+ />
47
+ </div>
48
+
49
+ <div>
50
+ <label className="block text-xs font-semibold text-slate-400 uppercase tracking-wider mb-2 ml-1">Password</label>
51
+ <input
52
+ type="password"
53
+ name="password"
54
+ placeholder="••••••••"
55
+ onChange={handleChange}
56
+ className="w-full p-3.5 rounded-xl bg-black/40 border border-white/10 focus:border-purple-500 focus:ring-1 focus:ring-purple-500 outline-none text-white placeholder-slate-600 transition-all"
57
+ required
58
+ />
59
+ </div>
60
+
61
+ <button
62
+ type="submit"
63
+ disabled={isPending}
64
+ className={`mt-4 w-full py-3.5 flex items-center justify-center gap-2 rounded-xl font-bold text-base transition-all duration-300 ${
65
+ isPending
66
+ ? 'bg-white/10 text-slate-400 cursor-not-allowed border border-white/5'
67
+ : 'bg-gradient-to-r from-purple-600 to-orange-500 text-white shadow-[0_0_20px_rgba(124,58,237,0.3)] hover:-translate-y-0.5 hover:shadow-[0_0_30px_rgba(124,58,237,0.5)]'
68
+ }`}
69
+ >
70
+ {isPending ? (
71
+ <>
72
+ <svg className="animate-spin -ml-1 mr-2 h-5 w-5 text-white" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24">
73
+ <circle className="opacity-25" cx="12" cy="12" r="10" stroke="currentColor" strokeWidth="4"></circle>
74
+ <path className="opacity-75" fill="currentColor" d="M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"></path>
75
+ </svg>
76
+ Unlocking...
77
+ </>
78
+ ) : (
79
+ <>
80
+ Login
81
+ <svg width="18" height="18" fill="none" viewBox="0 0 24 24" stroke="currentColor" strokeWidth="2.5">
82
+ <path strokeLinecap="round" strokeLinejoin="round" d="M14 5l7 7m0 0l-7 7m7-7H3" />
83
+ </svg>
84
+ </>
85
+ )}
86
+ </button>
87
+ </form>
88
+
89
+ <p className="text-slate-400 mt-8 text-center text-sm">
90
+ New here? <Link to="/signup" className="text-purple-400 font-semibold hover:text-orange-400 transition-colors hover:underline underline-offset-4 decoration-purple-500/30">Create Account</Link>
91
+ </p>
92
+ </div>
93
+ </div>
94
+ )
95
+ }
96
+
97
+ export default Login
@@ -0,0 +1,112 @@
1
+ import { useState } from 'react'
2
+ import { useSignup } from '../hooks/useSignup'
3
+ import { Link } from 'react-router-dom'
4
+
5
+ const Signup = () => {
6
+ const [formData, setFormData] = useState({ name: '', email: '', password: '' })
7
+ const { mutate, isPending } = useSignup()
8
+
9
+ const handleChange = (e) => setFormData({ ...formData, [e.target.name]: e.target.value })
10
+
11
+ const handleSubmit = (e) => {
12
+ e.preventDefault()
13
+ mutate(formData)
14
+ }
15
+
16
+ return (
17
+ <div className="relative flex flex-col items-center justify-center min-h-[80vh] z-10 px-4">
18
+
19
+ {/* BACKGROUND ORB (Orange variation to complement Login's purple) */}
20
+ <div className="absolute top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2 w-[400px] h-[400px] bg-[radial-gradient(circle,_#F97316,_transparent_60%)] opacity-10 blur-[80px] pointer-events-none -z-10"></div>
21
+
22
+ {/* SIGNUP CARD */}
23
+ <div className="w-full max-w-md bg-white/[0.02] border border-white/10 p-8 sm:p-10 rounded-3xl shadow-2xl backdrop-blur-md">
24
+
25
+ <div className="text-center mb-8">
26
+ <div className="inline-flex items-center justify-center w-12 h-12 rounded-xl bg-orange-500/10 border border-orange-500/20 mb-4 text-orange-400">
27
+ {/* User Add Icon */}
28
+ <svg width="24" height="24" fill="none" viewBox="0 0 24 24" stroke="currentColor" strokeWidth="2">
29
+ <path strokeLinecap="round" strokeLinejoin="round" d="M18 9v3m0 0v3m0-3h3m-3 0h-3m-2-5a4 4 0 11-8 0 4 4 0 018 0zM3 20a6 6 0 0112 0v1H3v-1z" />
30
+ </svg>
31
+ </div>
32
+ <h2 className="text-3xl font-extrabold text-white tracking-tight">
33
+ Join the <span className="bg-gradient-to-r from-purple-400 to-orange-400 bg-clip-text text-transparent">Squad</span>
34
+ </h2>
35
+ </div>
36
+
37
+ <form onSubmit={handleSubmit} className="flex flex-col gap-5">
38
+ <div>
39
+ <label className="block text-xs font-semibold text-slate-400 uppercase tracking-wider mb-2 ml-1">Full Name</label>
40
+ <input
41
+ type="text"
42
+ name="name"
43
+ placeholder="Saumya"
44
+ onChange={handleChange}
45
+ className="w-full p-3.5 rounded-xl bg-black/40 border border-white/10 focus:border-purple-500 focus:ring-1 focus:ring-purple-500 outline-none text-white placeholder-slate-600 transition-all"
46
+ required
47
+ />
48
+ </div>
49
+
50
+ <div>
51
+ <label className="block text-xs font-semibold text-slate-400 uppercase tracking-wider mb-2 ml-1">Email Address</label>
52
+ <input
53
+ type="email"
54
+ name="email"
55
+ placeholder="saumya@dev.com"
56
+ onChange={handleChange}
57
+ className="w-full p-3.5 rounded-xl bg-black/40 border border-white/10 focus:border-purple-500 focus:ring-1 focus:ring-purple-500 outline-none text-white placeholder-slate-600 transition-all"
58
+ required
59
+ />
60
+ </div>
61
+
62
+ <div>
63
+ <label className="block text-xs font-semibold text-slate-400 uppercase tracking-wider mb-2 ml-1">Password</label>
64
+ <input
65
+ type="password"
66
+ name="password"
67
+ placeholder="••••••••"
68
+ onChange={handleChange}
69
+ className="w-full p-3.5 rounded-xl bg-black/40 border border-white/10 focus:border-purple-500 focus:ring-1 focus:ring-purple-500 outline-none text-white placeholder-slate-600 transition-all"
70
+ required
71
+ />
72
+ </div>
73
+
74
+ <button
75
+ type="submit"
76
+ disabled={isPending}
77
+ className={`mt-4 w-full py-3.5 flex items-center justify-center gap-2 rounded-xl font-bold text-base transition-all duration-300 ${
78
+ isPending
79
+ ? 'bg-white/10 text-slate-400 cursor-not-allowed border border-white/5'
80
+ : 'bg-gradient-to-r from-purple-600 to-orange-500 text-white shadow-[0_0_20px_rgba(124,58,237,0.3)] hover:-translate-y-0.5 hover:shadow-[0_0_30px_rgba(124,58,237,0.5)]'
81
+ }`}
82
+ >
83
+ {isPending ? (
84
+ <>
85
+ {/* Tailwind SVG Spinner */}
86
+ <svg className="animate-spin -ml-1 mr-2 h-5 w-5 text-white" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24">
87
+ <circle className="opacity-25" cx="12" cy="12" r="10" stroke="currentColor" strokeWidth="4"></circle>
88
+ <path className="opacity-75" fill="currentColor" d="M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"></path>
89
+ </svg>
90
+ Creating Account...
91
+ </>
92
+ ) : (
93
+ <>
94
+ Sign Up
95
+ {/* Replaced Rocket Emoji with sleek Lightning Bolt SVG */}
96
+ <svg width="18" height="18" fill="none" viewBox="0 0 24 24" stroke="currentColor" strokeWidth="2.5">
97
+ <path strokeLinecap="round" strokeLinejoin="round" d="M13 10V3L4 14h7v7l9-11h-7z" />
98
+ </svg>
99
+ </>
100
+ )}
101
+ </button>
102
+ </form>
103
+
104
+ <p className="text-slate-400 mt-8 text-center text-sm">
105
+ Already have an account? <Link to="/login" className="text-purple-400 font-semibold hover:text-orange-400 transition-colors hover:underline underline-offset-4 decoration-purple-500/30">Login here</Link>
106
+ </p>
107
+ </div>
108
+ </div>
109
+ )
110
+ }
111
+
112
+ export default Signup
@@ -0,0 +1,13 @@
1
+ {
2
+ "version": 2,
3
+ "rewrites": [
4
+ {
5
+ "source": "/api/(.*)",
6
+ "destination": "/server.js"
7
+ },
8
+ {
9
+ "source": "/(.*)",
10
+ "destination": "/index.html"
11
+ }
12
+ ]
13
+ }
@@ -0,0 +1,7 @@
1
+ import { defineConfig } from 'vite'
2
+ import react from '@vitejs/plugin-react'
3
+ import tailwindcss from '@tailwindcss/vite'
4
+ // https://vite.dev/config/
5
+ export default defineConfig({
6
+ plugins: [react(),tailwindcss()],
7
+ })