create-aziz-app 2.0.13 → 2.0.15
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 +227 -0
- package/package.json +1 -1
- package/template/README.md +862 -138
- package/template/_framework/boot.js +36 -0
- package/template/_framework/hooks.js +207 -0
- package/template/_framework/router.js +279 -0
- package/template/_framework/runtime.js +86 -0
- package/template/api/createUser.js +69 -0
- package/template/api/getUser.js +60 -0
- package/template/api/getUserWithDB.js +65 -0
- package/template/api/hello.js +8 -17
- package/template/api/loginUser.js +61 -0
- package/template/api/users.js +38 -134
- package/template/app/about/page.js +45 -0
- package/template/app/layout.js +23 -0
- package/template/app/page.js +54 -0
- package/template/app/test/page.js +55 -0
- package/template/components/Footer.js +10 -0
- package/template/components/Navbar.js +30 -0
- package/template/docs/NEXTJS-APP-ROUTER.md +536 -0
- package/template/index.html +24 -0
- package/template/lib/db.js +67 -0
- package/template/models/User.js +102 -0
- package/template/modules/next-response.js +58 -0
- package/template/package.json +4 -10
- package/template/scripts/dev-server.js +357 -268
- package/template/scripts/live-reload-client.js +0 -1
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
// User Model
|
|
2
|
+
// This is a mock - replace with real database model
|
|
3
|
+
|
|
4
|
+
// Mock in-memory database
|
|
5
|
+
let users = [
|
|
6
|
+
{ _id: '1', name: 'Aziz Ahmed', email: 'aziz@example.com', role: 'admin', phone: '123-456-7890' },
|
|
7
|
+
{ _id: '2', name: 'John Doe', email: 'john@example.com', role: 'user', phone: '098-765-4321' }
|
|
8
|
+
];
|
|
9
|
+
|
|
10
|
+
class User {
|
|
11
|
+
// Find one user
|
|
12
|
+
static async findOne(query) {
|
|
13
|
+
const user = users.find(u => {
|
|
14
|
+
return Object.keys(query).every(key => u[key] === query[key]);
|
|
15
|
+
});
|
|
16
|
+
return user || null;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
// Find by ID
|
|
20
|
+
static async findById(id) {
|
|
21
|
+
return users.find(u => u._id === id) || null;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
// Find all users
|
|
25
|
+
static async find(query = {}) {
|
|
26
|
+
if (Object.keys(query).length === 0) {
|
|
27
|
+
return users;
|
|
28
|
+
}
|
|
29
|
+
return users.filter(u => {
|
|
30
|
+
return Object.keys(query).every(key => u[key] === query[key]);
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
// Create new user
|
|
35
|
+
static async create(userData) {
|
|
36
|
+
const newUser = {
|
|
37
|
+
_id: String(users.length + 1),
|
|
38
|
+
...userData,
|
|
39
|
+
createdAt: new Date().toISOString()
|
|
40
|
+
};
|
|
41
|
+
users.push(newUser);
|
|
42
|
+
return newUser;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
// Update user
|
|
46
|
+
static async findByIdAndUpdate(id, updates) {
|
|
47
|
+
const index = users.findIndex(u => u._id === id);
|
|
48
|
+
if (index === -1) return null;
|
|
49
|
+
|
|
50
|
+
users[index] = { ...users[index], ...updates, updatedAt: new Date().toISOString() };
|
|
51
|
+
return users[index];
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
// Delete user
|
|
55
|
+
static async findByIdAndDelete(id) {
|
|
56
|
+
const index = users.findIndex(u => u._id === id);
|
|
57
|
+
if (index === -1) return null;
|
|
58
|
+
|
|
59
|
+
const deleted = users.splice(index, 1)[0];
|
|
60
|
+
return deleted;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
// Select specific fields
|
|
64
|
+
select(fields) {
|
|
65
|
+
// This is a chainable method for field selection
|
|
66
|
+
// In real Mongoose, this would be: User.findOne().select('name email')
|
|
67
|
+
return this;
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
module.exports = User;
|
|
72
|
+
|
|
73
|
+
// Example usage with Mongoose:
|
|
74
|
+
/*
|
|
75
|
+
const mongoose = require('mongoose');
|
|
76
|
+
|
|
77
|
+
const userSchema = new mongoose.Schema({
|
|
78
|
+
name: {
|
|
79
|
+
type: String,
|
|
80
|
+
required: true
|
|
81
|
+
},
|
|
82
|
+
email: {
|
|
83
|
+
type: String,
|
|
84
|
+
required: true,
|
|
85
|
+
unique: true
|
|
86
|
+
},
|
|
87
|
+
password: {
|
|
88
|
+
type: String,
|
|
89
|
+
required: true
|
|
90
|
+
},
|
|
91
|
+
role: {
|
|
92
|
+
type: String,
|
|
93
|
+
enum: ['user', 'admin'],
|
|
94
|
+
default: 'user'
|
|
95
|
+
},
|
|
96
|
+
phone: String
|
|
97
|
+
}, {
|
|
98
|
+
timestamps: true
|
|
99
|
+
});
|
|
100
|
+
|
|
101
|
+
module.exports = mongoose.models.User || mongoose.model('User', userSchema);
|
|
102
|
+
*/
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
// NextResponse - Next.js-compatible response helper
|
|
2
|
+
class NextResponse {
|
|
3
|
+
constructor(body, init = {}) {
|
|
4
|
+
this.body = body;
|
|
5
|
+
this.status = init.status || 200;
|
|
6
|
+
this.headers = new Map(Object.entries(init.headers || {}));
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
static json(data, init = {}) {
|
|
10
|
+
return new NextResponse(JSON.stringify(data), {
|
|
11
|
+
...init,
|
|
12
|
+
headers: {
|
|
13
|
+
'Content-Type': 'application/json',
|
|
14
|
+
...(init.headers || {})
|
|
15
|
+
}
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
static text(text, init = {}) {
|
|
20
|
+
return new NextResponse(text, {
|
|
21
|
+
...init,
|
|
22
|
+
headers: {
|
|
23
|
+
'Content-Type': 'text/plain',
|
|
24
|
+
...(init.headers || {})
|
|
25
|
+
}
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
static redirect(url, init = {}) {
|
|
30
|
+
return new NextResponse(null, {
|
|
31
|
+
...init,
|
|
32
|
+
status: init.status || 307,
|
|
33
|
+
headers: {
|
|
34
|
+
'Location': url,
|
|
35
|
+
...(init.headers || {})
|
|
36
|
+
}
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
static error() {
|
|
41
|
+
return new NextResponse(JSON.stringify({ error: 'Internal Server Error' }), {
|
|
42
|
+
status: 500,
|
|
43
|
+
headers: {
|
|
44
|
+
'Content-Type': 'application/json'
|
|
45
|
+
}
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
// Export for Node.js (server-side)
|
|
51
|
+
if (typeof module !== 'undefined' && module.exports) {
|
|
52
|
+
module.exports = { NextResponse };
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
// Export for browser (if needed)
|
|
56
|
+
if (typeof window !== 'undefined') {
|
|
57
|
+
window.NextResponse = NextResponse;
|
|
58
|
+
}
|
package/template/package.json
CHANGED
|
@@ -1,18 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "aziz-app",
|
|
3
3
|
"version": "1.0.2",
|
|
4
|
-
"description": "
|
|
5
|
-
"main": "
|
|
4
|
+
"description": "Lightweight Next.js clone — file-based routing, React hooks, ES module imports",
|
|
5
|
+
"main": "index.html",
|
|
6
6
|
"scripts": {
|
|
7
|
-
"dev": "node scripts/dev-server.js"
|
|
8
|
-
"build": "node scripts/generate-imports.js"
|
|
7
|
+
"dev": "node scripts/dev-server.js"
|
|
9
8
|
},
|
|
10
|
-
"keywords": [
|
|
11
|
-
"react",
|
|
12
|
-
"framework",
|
|
13
|
-
"routing",
|
|
14
|
-
"state-management"
|
|
15
|
-
],
|
|
9
|
+
"keywords": ["nextjs", "react", "framework", "routing", "lightweight"],
|
|
16
10
|
"author": "",
|
|
17
11
|
"license": "ISC"
|
|
18
12
|
}
|