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.
@@ -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
+ }
@@ -1,18 +1,12 @@
1
1
  {
2
2
  "name": "aziz-app",
3
3
  "version": "1.0.2",
4
- "description": "A simple, clean React-like framework with state management, routing, and API routes",
5
- "main": "app.html",
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
  }