ai-first-cli 1.1.2 → 1.1.5
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/ANALISIS_MEJORAS.md +327 -0
- package/BUGS.md +455 -0
- package/CHANGELOG.md +100 -225
- package/TEST_RESULTS.md +198 -0
- package/TEST_RESULTS_COMPARATIVE.md +159 -0
- package/TEST_RESULTS_COMPLETE.md +127 -0
- package/TEST_RESULTS_COMPREHENSIVE.md +208 -0
- package/ai/ai_context.md +17 -10
- package/ai/ai_rules.md +5 -3
- package/ai/architecture.md +28 -7
- package/ai/cache.json +832 -52
- package/ai/context/features/commands.json +18 -0
- package/ai/context/features/src.json +61 -0
- package/ai/context/features/test-projects.json +56 -0
- package/ai/context/flows/account.json +9 -0
- package/ai/context/flows/add_.json +9 -0
- package/ai/context/flows/ai-first.json +9 -0
- package/ai/context/flows/auth..json +10 -0
- package/ai/context/flows/auth.json +12 -0
- package/ai/context/flows/dashboard.json +9 -0
- package/ai/context/flows/doctor.json +9 -0
- package/ai/context/flows/explore.json +9 -0
- package/ai/context/flows/list_.json +9 -0
- package/ai/context/flows/login.json +9 -0
- package/ai/context/flows/opportunity.json +9 -0
- package/ai/context/flows/remove_.json +9 -0
- package/ai/context/flows/user.json +14 -0
- package/ai/context/flows/users..json +10 -0
- package/ai/context/flows/users.json +9 -0
- package/ai/conventions.md +3 -2
- package/ai/dependencies.json +429 -251
- package/ai/entrypoints.md +10 -0
- package/ai/files.json +822 -46
- package/ai/git/commit-activity.json +126 -39
- package/ai/git/recent-features.json +3 -1
- package/ai/git/recent-files.json +6 -6
- package/ai/git/recent-flows.json +3 -1
- package/ai/graph/knowledge-graph.json +954 -182
- package/ai/graph/module-graph.json +270 -0
- package/ai/graph/symbol-graph.json +48991 -16523
- package/ai/graph/symbol-references.json +953 -56
- package/ai/hierarchy.json +3 -24
- package/ai/index-state.json +1261 -253
- package/ai/index.db +0 -0
- package/ai/modules.json +226 -0
- package/ai/project.json +29 -0
- package/ai/repo-map.json +2284 -250
- package/ai/repo_map.json +2731 -231
- package/ai/repo_map.md +559 -2
- package/ai/schema.json +5 -0
- package/ai/summary.md +16 -7
- package/ai/tech_stack.md +4 -1
- package/ai/tools.json +10 -0
- package/dist/analyzers/dependencies.d.ts.map +1 -1
- package/dist/analyzers/dependencies.js +8 -16
- package/dist/analyzers/dependencies.js.map +1 -1
- package/dist/analyzers/symbols.d.ts.map +1 -1
- package/dist/analyzers/symbols.js +60 -0
- package/dist/analyzers/symbols.js.map +1 -1
- package/dist/commands/ai-first.d.ts +1 -0
- package/dist/commands/ai-first.d.ts.map +1 -1
- package/dist/commands/ai-first.js +29 -6
- package/dist/commands/ai-first.js.map +1 -1
- package/dist/core/semanticContexts.d.ts.map +1 -1
- package/dist/core/semanticContexts.js +48 -26
- package/dist/core/semanticContexts.js.map +1 -1
- package/dist/core/symbolGraph.d.ts.map +1 -1
- package/dist/core/symbolGraph.js +14 -2
- package/dist/core/symbolGraph.js.map +1 -1
- package/dist/utils/fileUtils.d.ts.map +1 -1
- package/dist/utils/fileUtils.js +5 -0
- package/dist/utils/fileUtils.js.map +1 -1
- package/package.json +2 -2
- package/src/analyzers/dependencies.ts +10 -20
- package/src/analyzers/symbols.ts +64 -0
- package/src/commands/ai-first.ts +32 -8
- package/src/core/semanticContexts.ts +54 -29
- package/src/core/symbolGraph.ts +16 -2
- package/src/utils/fileUtils.ts +5 -0
- package/test-projects/express-api/ai/ai_context.md +112 -0
- package/test-projects/express-api/ai/ai_rules.md +50 -0
- package/test-projects/express-api/ai/architecture.md +62 -0
- package/test-projects/express-api/ai/cache.json +125 -0
- package/test-projects/express-api/ai/context/features/controllers.json +13 -0
- package/test-projects/express-api/ai/context/features/services.json +13 -0
- package/test-projects/express-api/ai/context/flows/auth.json +12 -0
- package/test-projects/express-api/ai/context/flows/user.json +13 -0
- package/test-projects/express-api/ai/conventions.md +51 -0
- package/test-projects/express-api/ai/dependencies.json +54 -0
- package/test-projects/express-api/ai/entrypoints.md +17 -0
- package/test-projects/express-api/ai/files.json +169 -0
- package/test-projects/express-api/ai/graph/knowledge-graph.json +98 -0
- package/test-projects/express-api/ai/graph/module-graph.json +44 -0
- package/test-projects/express-api/ai/graph/symbol-graph.json +882 -0
- package/test-projects/express-api/ai/graph/symbol-references.json +51 -0
- package/test-projects/express-api/ai/index-state.json +238 -0
- package/test-projects/express-api/ai/index.db +0 -0
- package/test-projects/express-api/ai/modules.json +30 -0
- package/test-projects/express-api/ai/project.json +15 -0
- package/test-projects/express-api/ai/repo-map.json +291 -0
- package/test-projects/express-api/ai/repo_map.json +100 -0
- package/test-projects/express-api/ai/repo_map.md +36 -0
- package/test-projects/express-api/ai/schema.json +5 -0
- package/test-projects/express-api/ai/summary.md +14 -0
- package/test-projects/express-api/ai/symbols.json +1174 -0
- package/test-projects/express-api/ai/tech_stack.md +38 -0
- package/test-projects/express-api/ai/tools.json +10 -0
- package/test-projects/express-api/controllers/authController.js +32 -0
- package/test-projects/express-api/controllers/userController.js +51 -0
- package/test-projects/express-api/index.js +21 -0
- package/test-projects/express-api/middleware/authMiddleware.js +30 -0
- package/test-projects/express-api/models/userRepository.js +25 -0
- package/test-projects/express-api/package.json +18 -0
- package/test-projects/express-api/services/authService.js +17 -0
- package/test-projects/express-api/services/userService.js +28 -0
- package/test-projects/nestjs-backend/ai/ai_context.md +110 -0
- package/test-projects/nestjs-backend/ai/ai_rules.md +52 -0
- package/test-projects/nestjs-backend/ai/architecture.md +43 -0
- package/test-projects/nestjs-backend/ai/cache.json +137 -0
- package/test-projects/nestjs-backend/ai/context/features/src.json +23 -0
- package/test-projects/nestjs-backend/ai/context/flows/auth..json +10 -0
- package/test-projects/nestjs-backend/ai/context/flows/users..json +10 -0
- package/test-projects/nestjs-backend/ai/conventions.md +52 -0
- package/test-projects/nestjs-backend/ai/dependencies.json +152 -0
- package/test-projects/nestjs-backend/ai/entrypoints.md +18 -0
- package/test-projects/nestjs-backend/ai/files.json +184 -0
- package/test-projects/nestjs-backend/ai/graph/knowledge-graph.json +74 -0
- package/test-projects/nestjs-backend/ai/graph/module-graph.json +29 -0
- package/test-projects/nestjs-backend/ai/graph/symbol-graph.json +304 -0
- package/test-projects/nestjs-backend/ai/graph/symbol-references.json +5 -0
- package/test-projects/nestjs-backend/ai/index-state.json +259 -0
- package/test-projects/nestjs-backend/ai/index.db +0 -0
- package/test-projects/nestjs-backend/ai/modules.json +19 -0
- package/test-projects/nestjs-backend/ai/project.json +14 -0
- package/test-projects/nestjs-backend/ai/repo-map.json +323 -0
- package/test-projects/nestjs-backend/ai/repo_map.json +141 -0
- package/test-projects/nestjs-backend/ai/repo_map.md +39 -0
- package/test-projects/nestjs-backend/ai/schema.json +5 -0
- package/test-projects/nestjs-backend/ai/summary.md +11 -0
- package/test-projects/nestjs-backend/ai/symbols.json +527 -0
- package/test-projects/nestjs-backend/ai/tech_stack.md +37 -0
- package/test-projects/nestjs-backend/ai/tools.json +10 -0
- package/test-projects/nestjs-backend/package.json +22 -0
- package/test-projects/nestjs-backend/src/app.module.ts +8 -0
- package/test-projects/nestjs-backend/src/auth/auth.controller.ts +22 -0
- package/test-projects/nestjs-backend/src/auth/auth.module.ts +11 -0
- package/test-projects/nestjs-backend/src/auth/auth.service.ts +28 -0
- package/test-projects/nestjs-backend/src/auth/dto/login.dto.ts +4 -0
- package/test-projects/nestjs-backend/src/auth/strategies/jwt.strategy.ts +18 -0
- package/test-projects/nestjs-backend/src/main.ts +9 -0
- package/test-projects/nestjs-backend/src/users/users.controller.ts +32 -0
- package/test-projects/nestjs-backend/src/users/users.module.ts +10 -0
- package/test-projects/nestjs-backend/src/users/users.service.ts +42 -0
- package/test-projects/nestjs-backend/tsconfig.json +21 -0
- package/test-projects/python-cli/__init__.py +1 -0
- package/test-projects/python-cli/ai/ai_context.md +94 -0
- package/test-projects/python-cli/ai/ai_rules.md +47 -0
- package/test-projects/python-cli/ai/architecture.md +49 -0
- package/test-projects/python-cli/ai/cache.json +129 -0
- package/test-projects/python-cli/ai/context/features/cli.json +16 -0
- package/test-projects/python-cli/ai/context/flows/add_.json +9 -0
- package/test-projects/python-cli/ai/context/flows/list_.json +9 -0
- package/test-projects/python-cli/ai/context/flows/remove_.json +9 -0
- package/test-projects/python-cli/ai/conventions.md +51 -0
- package/test-projects/python-cli/ai/dependencies.json +66 -0
- package/test-projects/python-cli/ai/entrypoints.md +4 -0
- package/test-projects/python-cli/ai/files.json +174 -0
- package/test-projects/python-cli/ai/graph/knowledge-graph.json +83 -0
- package/test-projects/python-cli/ai/graph/module-graph.json +31 -0
- package/test-projects/python-cli/ai/graph/symbol-graph.json +358 -0
- package/test-projects/python-cli/ai/graph/symbol-references.json +11 -0
- package/test-projects/python-cli/ai/index-state.json +245 -0
- package/test-projects/python-cli/ai/index.db +0 -0
- package/test-projects/python-cli/ai/modules.json +21 -0
- package/test-projects/python-cli/ai/project.json +15 -0
- package/test-projects/python-cli/ai/repo-map.json +290 -0
- package/test-projects/python-cli/ai/repo_map.json +99 -0
- package/test-projects/python-cli/ai/repo_map.md +32 -0
- package/test-projects/python-cli/ai/schema.json +5 -0
- package/test-projects/python-cli/ai/summary.md +11 -0
- package/test-projects/python-cli/ai/symbols.json +475 -0
- package/test-projects/python-cli/ai/tech_stack.md +30 -0
- package/test-projects/python-cli/ai/tools.json +10 -0
- package/test-projects/python-cli/cli/__init__.py +1 -0
- package/test-projects/python-cli/cli/add_command.py +6 -0
- package/test-projects/python-cli/cli/list_command.py +7 -0
- package/test-projects/python-cli/cli/remove_command.py +6 -0
- package/test-projects/python-cli/main.py +34 -0
- package/test-projects/python-cli/models/__init__.py +2 -0
- package/test-projects/python-cli/models/task.py +19 -0
- package/test-projects/python-cli/models/task_repository.py +44 -0
- package/test-projects/react-app/ai/ai_context.md +95 -0
- package/test-projects/react-app/ai/ai_rules.md +49 -0
- package/test-projects/react-app/ai/architecture.md +33 -0
- package/test-projects/react-app/ai/cache.json +129 -0
- package/test-projects/react-app/ai/context/features/src.json +18 -0
- package/test-projects/react-app/ai/context/flows/dashboard.json +9 -0
- package/test-projects/react-app/ai/context/flows/login.json +9 -0
- package/test-projects/react-app/ai/context/flows/users.json +9 -0
- package/test-projects/react-app/ai/conventions.md +52 -0
- package/test-projects/react-app/ai/dependencies.json +128 -0
- package/test-projects/react-app/ai/entrypoints.md +4 -0
- package/test-projects/react-app/ai/files.json +174 -0
- package/test-projects/react-app/ai/graph/knowledge-graph.json +83 -0
- package/test-projects/react-app/ai/graph/module-graph.json +31 -0
- package/test-projects/react-app/ai/graph/symbol-graph.json +868 -0
- package/test-projects/react-app/ai/graph/symbol-references.json +31 -0
- package/test-projects/react-app/ai/index-state.json +245 -0
- package/test-projects/react-app/ai/index.db +0 -0
- package/test-projects/react-app/ai/modules.json +17 -0
- package/test-projects/react-app/ai/project.json +15 -0
- package/test-projects/react-app/ai/repo-map.json +305 -0
- package/test-projects/react-app/ai/repo_map.json +114 -0
- package/test-projects/react-app/ai/repo_map.md +31 -0
- package/test-projects/react-app/ai/schema.json +5 -0
- package/test-projects/react-app/ai/summary.md +11 -0
- package/test-projects/react-app/ai/symbols.json +985 -0
- package/test-projects/react-app/ai/tech_stack.md +38 -0
- package/test-projects/react-app/ai/tools.json +10 -0
- package/test-projects/react-app/package.json +16 -0
- package/test-projects/react-app/src/App.tsx +21 -0
- package/test-projects/react-app/src/context/AuthContext.tsx +41 -0
- package/test-projects/react-app/src/hooks/useAuth.ts +10 -0
- package/test-projects/react-app/src/main.tsx +10 -0
- package/test-projects/react-app/src/pages/DashboardPage.tsx +17 -0
- package/test-projects/react-app/src/pages/LoginPage.tsx +41 -0
- package/test-projects/react-app/src/pages/UsersPage.tsx +36 -0
- package/test-projects/react-app/src/services/userService.ts +37 -0
- package/test-projects/salesforce-cli/.forceignore +27 -0
- package/test-projects/salesforce-cli/ai/ai_context.md +88 -0
- package/test-projects/salesforce-cli/ai/ai_rules.md +47 -0
- package/test-projects/salesforce-cli/ai/architecture.md +33 -0
- package/test-projects/salesforce-cli/ai/cache.json +105 -0
- package/test-projects/salesforce-cli/ai/context/features/force-app.json +14 -0
- package/test-projects/salesforce-cli/ai/context/flows/account.json +9 -0
- package/test-projects/salesforce-cli/ai/context/flows/opportunity.json +9 -0
- package/test-projects/salesforce-cli/ai/conventions.md +51 -0
- package/test-projects/salesforce-cli/ai/dependencies.json +6 -0
- package/test-projects/salesforce-cli/ai/entrypoints.md +4 -0
- package/test-projects/salesforce-cli/ai/files.json +144 -0
- package/test-projects/salesforce-cli/ai/graph/knowledge-graph.json +64 -0
- package/test-projects/salesforce-cli/ai/graph/module-graph.json +13 -0
- package/test-projects/salesforce-cli/ai/graph/symbol-graph.json +148 -0
- package/test-projects/salesforce-cli/ai/graph/symbol-references.json +1 -0
- package/test-projects/salesforce-cli/ai/index-state.json +203 -0
- package/test-projects/salesforce-cli/ai/index.db +0 -0
- package/test-projects/salesforce-cli/ai/modules.json +12 -0
- package/test-projects/salesforce-cli/ai/project.json +14 -0
- package/test-projects/salesforce-cli/ai/repo-map.json +251 -0
- package/test-projects/salesforce-cli/ai/repo_map.json +69 -0
- package/test-projects/salesforce-cli/ai/repo_map.md +21 -0
- package/test-projects/salesforce-cli/ai/schema.json +5 -0
- package/test-projects/salesforce-cli/ai/summary.md +11 -0
- package/test-projects/salesforce-cli/ai/symbols.json +245 -0
- package/test-projects/salesforce-cli/ai/tech_stack.md +30 -0
- package/test-projects/salesforce-cli/ai/tools.json +10 -0
- package/test-projects/salesforce-cli/force-app/main/default/classes/AccountController.cls +24 -0
- package/test-projects/salesforce-cli/force-app/main/default/classes/OpportunityController.cls +25 -0
- package/test-projects/salesforce-cli/force-app/main/default/objects/Project__c.object.xml +45 -0
- package/test-projects/salesforce-cli/force-app/main/default/triggers/AccountTrigger.trigger +33 -0
- package/test-projects/salesforce-cli/sfdx-project.json +11 -0
- package/tests/e2e/README.md +85 -0
- package/tests/e2e/run-e2e.sh +88 -0
- package/tests/semanticContexts.test.ts +23 -25
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
# Technology Stack
|
|
2
|
+
|
|
3
|
+
**Languages**: JavaScript, JSON
|
|
4
|
+
|
|
5
|
+
**Frameworks**: Express.js
|
|
6
|
+
|
|
7
|
+
**Libraries**: Bcrypt, JWT
|
|
8
|
+
|
|
9
|
+
**Package Managers**: npm
|
|
10
|
+
|
|
11
|
+
## Languages
|
|
12
|
+
- JavaScript
|
|
13
|
+
- JSON
|
|
14
|
+
|
|
15
|
+
## Frameworks
|
|
16
|
+
- Express.js
|
|
17
|
+
|
|
18
|
+
## Key Libraries
|
|
19
|
+
- Bcrypt
|
|
20
|
+
- JWT
|
|
21
|
+
|
|
22
|
+
## Development Tools
|
|
23
|
+
- None detected
|
|
24
|
+
|
|
25
|
+
## Package Managers
|
|
26
|
+
- npm
|
|
27
|
+
|
|
28
|
+
## Testing
|
|
29
|
+
- None detected
|
|
30
|
+
|
|
31
|
+
## Linters
|
|
32
|
+
- None detected
|
|
33
|
+
|
|
34
|
+
## Formatters
|
|
35
|
+
- None detected
|
|
36
|
+
|
|
37
|
+
---
|
|
38
|
+
*Generated by ai-first*
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
const jwt = require('jsonwebtoken');
|
|
2
|
+
const authService = require('../services/authService');
|
|
3
|
+
|
|
4
|
+
const SECRET = process.env.JWT_SECRET || 'secret';
|
|
5
|
+
|
|
6
|
+
async function login(req, res) {
|
|
7
|
+
try {
|
|
8
|
+
const { email, password } = req.body;
|
|
9
|
+
const user = await authService.verifyCredentials(email, password);
|
|
10
|
+
|
|
11
|
+
if (!user) {
|
|
12
|
+
return res.status(401).json({ error: 'Invalid credentials' });
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
const token = jwt.sign({ userId: user.id }, SECRET, { expiresIn: '24h' });
|
|
16
|
+
res.json({ token, user: { id: user.id, email: user.email } });
|
|
17
|
+
} catch (error) {
|
|
18
|
+
res.status(500).json({ error: error.message });
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
async function register(req, res) {
|
|
23
|
+
try {
|
|
24
|
+
const { email, password } = req.body;
|
|
25
|
+
const user = await authService.createUser(email, password);
|
|
26
|
+
res.status(201).json({ user });
|
|
27
|
+
} catch (error) {
|
|
28
|
+
res.status(500).json({ error: error.message });
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
module.exports = { login, register };
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
const userService = require('../services/userService');
|
|
2
|
+
|
|
3
|
+
async function getAll(req, res) {
|
|
4
|
+
try {
|
|
5
|
+
const users = await userService.findAll();
|
|
6
|
+
res.json(users);
|
|
7
|
+
} catch (error) {
|
|
8
|
+
res.status(500).json({ error: error.message });
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
async function getById(req, res) {
|
|
13
|
+
try {
|
|
14
|
+
const user = await userService.findById(req.params.id);
|
|
15
|
+
if (!user) {
|
|
16
|
+
return res.status(404).json({ error: 'User not found' });
|
|
17
|
+
}
|
|
18
|
+
res.json(user);
|
|
19
|
+
} catch (error) {
|
|
20
|
+
res.status(500).json({ error: error.message });
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
async function create(req, res) {
|
|
25
|
+
try {
|
|
26
|
+
const user = await userService.create(req.body);
|
|
27
|
+
res.status(201).json(user);
|
|
28
|
+
} catch (error) {
|
|
29
|
+
res.status(500).json({ error: error.message });
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
async function update(req, res) {
|
|
34
|
+
try {
|
|
35
|
+
const user = await userService.update(req.params.id, req.body);
|
|
36
|
+
res.json(user);
|
|
37
|
+
} catch (error) {
|
|
38
|
+
res.status(500).json({ error: error.message });
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
async function remove(req, res) {
|
|
43
|
+
try {
|
|
44
|
+
await userService.remove(req.params.id);
|
|
45
|
+
res.status(204).send();
|
|
46
|
+
} catch (error) {
|
|
47
|
+
res.status(500).json({ error: error.message });
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
module.exports = { getAll, getById, create, update, delete: remove };
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
const express = require('express');
|
|
2
|
+
const authController = require('./controllers/authController');
|
|
3
|
+
const userController = require('./controllers/userController');
|
|
4
|
+
|
|
5
|
+
const app = express();
|
|
6
|
+
app.use(express.json());
|
|
7
|
+
|
|
8
|
+
app.post('/auth/login', authController.login);
|
|
9
|
+
app.post('/auth/register', authController.register);
|
|
10
|
+
app.get('/users', userController.getAll);
|
|
11
|
+
app.get('/users/:id', userController.getById);
|
|
12
|
+
app.post('/users', userController.create);
|
|
13
|
+
app.put('/users/:id', userController.update);
|
|
14
|
+
app.delete('/users/:id', userController.delete);
|
|
15
|
+
|
|
16
|
+
const PORT = process.env.PORT || 3000;
|
|
17
|
+
app.listen(PORT, () => {
|
|
18
|
+
console.log(`Server running on port ${PORT}`);
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
module.exports = app;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
const jwt = require('jsonwebtoken');
|
|
2
|
+
|
|
3
|
+
const SECRET = process.env.JWT_SECRET || 'secret';
|
|
4
|
+
|
|
5
|
+
function authenticate(req, res, next) {
|
|
6
|
+
const token = req.headers.authorization?.split(' ')[1];
|
|
7
|
+
|
|
8
|
+
if (!token) {
|
|
9
|
+
return res.status(401).json({ error: 'No token provided' });
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
try {
|
|
13
|
+
const decoded = jwt.verify(token, SECRET);
|
|
14
|
+
req.user = decoded;
|
|
15
|
+
next();
|
|
16
|
+
} catch (error) {
|
|
17
|
+
res.status(401).json({ error: 'Invalid token' });
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
function authorize(roles = []) {
|
|
22
|
+
return (req, res, next) => {
|
|
23
|
+
if (!roles.includes(req.user?.role)) {
|
|
24
|
+
return res.status(403).json({ error: 'Forbidden' });
|
|
25
|
+
}
|
|
26
|
+
next();
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
module.exports = { authenticate, authorize };
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
const users = [];
|
|
2
|
+
|
|
3
|
+
const db = {
|
|
4
|
+
findAll: () => Promise.resolve(users),
|
|
5
|
+
findById: (id) => Promise.resolve(users.find(u => u.id === id)),
|
|
6
|
+
findByEmail: (email) => Promise.resolve(users.find(u => u.email === email)),
|
|
7
|
+
create: (data) => {
|
|
8
|
+
const user = { id: String(users.length + 1), ...data };
|
|
9
|
+
users.push(user);
|
|
10
|
+
return Promise.resolve(user);
|
|
11
|
+
},
|
|
12
|
+
update: (id, data) => {
|
|
13
|
+
const index = users.findIndex(u => u.id === id);
|
|
14
|
+
if (index === -1) return Promise.resolve(null);
|
|
15
|
+
users[index] = { ...users[index], ...data };
|
|
16
|
+
return Promise.resolve(users[index]);
|
|
17
|
+
},
|
|
18
|
+
delete: (id) => {
|
|
19
|
+
const index = users.findIndex(u => u.id === id);
|
|
20
|
+
if (index !== -1) users.splice(index, 1);
|
|
21
|
+
return Promise.resolve();
|
|
22
|
+
}
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
module.exports = db;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "express-api",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "Express.js API with auth and users",
|
|
5
|
+
"main": "index.js",
|
|
6
|
+
"scripts": {
|
|
7
|
+
"start": "node index.js",
|
|
8
|
+
"dev": "nodemon index.js"
|
|
9
|
+
},
|
|
10
|
+
"dependencies": {
|
|
11
|
+
"express": "^4.18.2",
|
|
12
|
+
"jsonwebtoken": "^9.0.0",
|
|
13
|
+
"bcrypt": "^5.1.0"
|
|
14
|
+
},
|
|
15
|
+
"devDependencies": {
|
|
16
|
+
"nodemon": "^3.0.0"
|
|
17
|
+
}
|
|
18
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
const bcrypt = require('bcrypt');
|
|
2
|
+
const userRepository = require('../models/userRepository');
|
|
3
|
+
|
|
4
|
+
async function verifyCredentials(email, password) {
|
|
5
|
+
const user = await userRepository.findByEmail(email);
|
|
6
|
+
if (!user) return null;
|
|
7
|
+
|
|
8
|
+
const valid = await bcrypt.compare(password, user.password);
|
|
9
|
+
return valid ? user : null;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
async function createUser(email, password) {
|
|
13
|
+
const hashedPassword = await bcrypt.hash(password, 10);
|
|
14
|
+
return userRepository.create({ email, password: hashedPassword });
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
module.exports = { verifyCredentials, createUser };
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
class UserService {
|
|
2
|
+
constructor(repository) {
|
|
3
|
+
this.repository = repository;
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
async findAll() {
|
|
7
|
+
return this.repository.findAll();
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
async findById(id) {
|
|
11
|
+
return this.repository.findById(id);
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
async create(data) {
|
|
15
|
+
return this.repository.create(data);
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
async update(id, data) {
|
|
19
|
+
return this.repository.update(id, data);
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
async remove(id) {
|
|
23
|
+
return this.repository.delete(id);
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
const repository = require('../models/userRepository');
|
|
28
|
+
module.exports = new UserService(repository);
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
# AI Context
|
|
2
|
+
|
|
3
|
+
> This file provides a comprehensive overview of the repository for AI coding assistants.
|
|
4
|
+
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
## Quick Overview
|
|
8
|
+
|
|
9
|
+
- **Pattern**: Flat / Simple Structure
|
|
10
|
+
- **Languages**: JSON, TypeScript
|
|
11
|
+
- **Frameworks**: TypeScript
|
|
12
|
+
- **Total Files**: 12
|
|
13
|
+
|
|
14
|
+
---
|
|
15
|
+
|
|
16
|
+
## Table of Contents
|
|
17
|
+
|
|
18
|
+
1. [Tech Stack](#tech-stack)
|
|
19
|
+
2. [Architecture](#architecture)
|
|
20
|
+
3. [Key Entrypoints](#key-entrypoints)
|
|
21
|
+
4. [Code Conventions](#code-conventions)
|
|
22
|
+
5. [AI Rules](#ai-rules)
|
|
23
|
+
6. [Repository Map](#repository-map)
|
|
24
|
+
|
|
25
|
+
---
|
|
26
|
+
|
|
27
|
+
## Tech Stack
|
|
28
|
+
|
|
29
|
+
**Languages**: JSON, TypeScript
|
|
30
|
+
|
|
31
|
+
**Frameworks**: TypeScript
|
|
32
|
+
|
|
33
|
+
**Libraries**: Passport.js
|
|
34
|
+
|
|
35
|
+
**Package Managers**: npm
|
|
36
|
+
|
|
37
|
+
---
|
|
38
|
+
|
|
39
|
+
## Architecture
|
|
40
|
+
|
|
41
|
+
## Architectural Pattern
|
|
42
|
+
**Primary**: Flat / Simple Structure
|
|
43
|
+
|
|
44
|
+
## Layers Identified
|
|
45
|
+
- Infrastructure
|
|
46
|
+
- Config
|
|
47
|
+
|
|
48
|
+
## Key Modules
|
|
49
|
+
| Module | Responsibility |
|
|
50
|
+
|--------|----------------|
|
|
51
|
+
| `package.json` | Contains 0 files |
|
|
52
|
+
| `src` | Contains 10 files |
|
|
53
|
+
| `tsconfig.json` | Configuration management |
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
---
|
|
57
|
+
|
|
58
|
+
## Key Entrypoints
|
|
59
|
+
|
|
60
|
+
### Build
|
|
61
|
+
- `package.json#scripts.build` - build: nest build
|
|
62
|
+
|
|
63
|
+
### Server
|
|
64
|
+
- `package.json#scripts.start` - start: nest start
|
|
65
|
+
- `package.json#scripts.start:dev` - start:dev: nest start --watch
|
|
66
|
+
- `src/main.ts` - Main
|
|
67
|
+
|
|
68
|
+
---
|
|
69
|
+
|
|
70
|
+
## Code Conventions
|
|
71
|
+
|
|
72
|
+
## Naming Conventions
|
|
73
|
+
- **Files**: camelCase
|
|
74
|
+
|
|
75
|
+
## Project Structure
|
|
76
|
+
- **Source**: src/
|
|
77
|
+
|
|
78
|
+
## Code Style
|
|
79
|
+
- **Semicolons**: Required
|
|
80
|
+
|
|
81
|
+
|
|
82
|
+
---
|
|
83
|
+
|
|
84
|
+
## AI Rules
|
|
85
|
+
|
|
86
|
+
- Language: Use JSON, TypeScript
|
|
87
|
+
- Frameworks: TypeScript
|
|
88
|
+
- Architecture: Follow Flat / Simple Structure pattern
|
|
89
|
+
- File naming: camelCase
|
|
90
|
+
- Source directory: src/
|
|
91
|
+
|
|
92
|
+
---
|
|
93
|
+
|
|
94
|
+
## Repository Map
|
|
95
|
+
|
|
96
|
+
See repo_map.md for the full structure.
|
|
97
|
+
|
|
98
|
+
---
|
|
99
|
+
|
|
100
|
+
## Notes for AI Assistants
|
|
101
|
+
|
|
102
|
+
1. Follow the established naming conventions (see conventions.md)
|
|
103
|
+
2. Use the detected frameworks and libraries
|
|
104
|
+
3. Target the correct entrypoints for modifications
|
|
105
|
+
4. Maintain the detected architecture patterns
|
|
106
|
+
5. Follow AI rules in ai_rules.md
|
|
107
|
+
|
|
108
|
+
---
|
|
109
|
+
|
|
110
|
+
*Generated by ai-first*
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
# AI Rules
|
|
2
|
+
|
|
3
|
+
> Guidelines for AI assistants working on this project
|
|
4
|
+
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
## Guidelines
|
|
8
|
+
|
|
9
|
+
- Language: Use JSON, TypeScript
|
|
10
|
+
- Frameworks: TypeScript
|
|
11
|
+
- Architecture: Follow Flat / Simple Structure pattern
|
|
12
|
+
- File naming: camelCase
|
|
13
|
+
- Source directory: src/
|
|
14
|
+
- Main entry: package.json#scripts.start
|
|
15
|
+
- Dev command: npm run start:dev
|
|
16
|
+
- Build command: npm run build
|
|
17
|
+
|
|
18
|
+
## Patterns
|
|
19
|
+
|
|
20
|
+
- Layer structure: infrastructure → config
|
|
21
|
+
|
|
22
|
+
## Constraints
|
|
23
|
+
|
|
24
|
+
- Always use semicolons
|
|
25
|
+
|
|
26
|
+
---
|
|
27
|
+
|
|
28
|
+
## Quick Reference
|
|
29
|
+
|
|
30
|
+
| Category | Value |
|
|
31
|
+
|----------|-------|
|
|
32
|
+
| Language | JSON, TypeScript |
|
|
33
|
+
| Framework | TypeScript |
|
|
34
|
+
| Architecture | Flat / Simple Structure |
|
|
35
|
+
| Naming | camelCase |
|
|
36
|
+
| Indentation | unknown |
|
|
37
|
+
|
|
38
|
+
---
|
|
39
|
+
|
|
40
|
+
## Best Practices
|
|
41
|
+
|
|
42
|
+
1. Follow the established naming conventions
|
|
43
|
+
2. Keep functions small and focused
|
|
44
|
+
3. Write tests for new features
|
|
45
|
+
4. Use descriptive variable names
|
|
46
|
+
5. Keep the architecture consistent
|
|
47
|
+
6. Document complex logic
|
|
48
|
+
7. Review code before committing
|
|
49
|
+
|
|
50
|
+
---
|
|
51
|
+
|
|
52
|
+
*Generated by ai-first*
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
# Architecture
|
|
2
|
+
|
|
3
|
+
## Architectural Pattern
|
|
4
|
+
**Primary**: Flat / Simple Structure
|
|
5
|
+
|
|
6
|
+
## Layers Identified
|
|
7
|
+
- Infrastructure
|
|
8
|
+
- Config
|
|
9
|
+
|
|
10
|
+
## Key Modules
|
|
11
|
+
| Module | Responsibility |
|
|
12
|
+
|--------|----------------|
|
|
13
|
+
| `package.json` | Contains 0 files |
|
|
14
|
+
| `src` | Contains 10 files |
|
|
15
|
+
| `tsconfig.json` | Configuration management |
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
## Module Details
|
|
19
|
+
|
|
20
|
+
### package.json
|
|
21
|
+
- **Path**: `package.json`
|
|
22
|
+
- **Responsibility**: Contains 0 files
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
### src
|
|
26
|
+
- **Path**: `src`
|
|
27
|
+
- **Responsibility**: Contains 10 files
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
### tsconfig.json
|
|
31
|
+
- **Path**: `tsconfig.json`
|
|
32
|
+
- **Responsibility**: Configuration management
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
## Recommendations
|
|
37
|
+
|
|
38
|
+
- Keep the architecture consistent as the project grows
|
|
39
|
+
- Follow the established layer structure
|
|
40
|
+
- Use dependency injection to manage module relationships
|
|
41
|
+
|
|
42
|
+
---
|
|
43
|
+
*Generated by ai-first*
|
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
{
|
|
2
|
+
"files": {
|
|
3
|
+
"ai/ai_context.md": {
|
|
4
|
+
"hash": "01e94675a8faa5d598f2782c09e3d5ad",
|
|
5
|
+
"mtime": 1773796492431.4038
|
|
6
|
+
},
|
|
7
|
+
"ai/ai_rules.md": {
|
|
8
|
+
"hash": "0056c2b3f1d212bd870734924f577d09",
|
|
9
|
+
"mtime": 1773796492431.4038
|
|
10
|
+
},
|
|
11
|
+
"ai/architecture.md": {
|
|
12
|
+
"hash": "b763c79531f89caf3a6731d8c6b4f157",
|
|
13
|
+
"mtime": 1773796492425.4036
|
|
14
|
+
},
|
|
15
|
+
"ai/context/features/src.json": {
|
|
16
|
+
"hash": "e62d7f714439c64f0a0051436687b023",
|
|
17
|
+
"mtime": 1773796492433.4038
|
|
18
|
+
},
|
|
19
|
+
"ai/context/flows/auth..json": {
|
|
20
|
+
"hash": "064519d0be7978f42c408cf2f99edaf9",
|
|
21
|
+
"mtime": 1773796492433.4038
|
|
22
|
+
},
|
|
23
|
+
"ai/context/flows/users..json": {
|
|
24
|
+
"hash": "743cdda74793f8b1d4fac2656267c24b",
|
|
25
|
+
"mtime": 1773796492433.4038
|
|
26
|
+
},
|
|
27
|
+
"ai/conventions.md": {
|
|
28
|
+
"hash": "9924468f87cfd5d2328fa48737aac075",
|
|
29
|
+
"mtime": 1773796492427.4036
|
|
30
|
+
},
|
|
31
|
+
"ai/dependencies.json": {
|
|
32
|
+
"hash": "7dbe8e380f477563ed486728fc7d796e",
|
|
33
|
+
"mtime": 1773796492430.4038
|
|
34
|
+
},
|
|
35
|
+
"ai/entrypoints.md": {
|
|
36
|
+
"hash": "31bc6c36186b7db7764086f994a34fcf",
|
|
37
|
+
"mtime": 1773796492426.4036
|
|
38
|
+
},
|
|
39
|
+
"ai/files.json": {
|
|
40
|
+
"hash": "6fc0e5f9f769544e4d28bbd29197b2f5",
|
|
41
|
+
"mtime": 1773796517474.7942
|
|
42
|
+
},
|
|
43
|
+
"ai/graph/module-graph.json": {
|
|
44
|
+
"hash": "0e4d69958d08b9aaf402549b2cfe2b3a",
|
|
45
|
+
"mtime": 1773796517467.7942
|
|
46
|
+
},
|
|
47
|
+
"ai/modules.json": {
|
|
48
|
+
"hash": "11513775b7ba2c22e59f9bd915ea33fa",
|
|
49
|
+
"mtime": 1773796517464.7942
|
|
50
|
+
},
|
|
51
|
+
"ai/project.json": {
|
|
52
|
+
"hash": "3dccdf21bae258d5c57bd9001b4b39e6",
|
|
53
|
+
"mtime": 1773796492433.4038
|
|
54
|
+
},
|
|
55
|
+
"ai/repo-map.json": {
|
|
56
|
+
"hash": "d0781e3898006491005ab603b6fe5f2a",
|
|
57
|
+
"mtime": 1773796517466.0496
|
|
58
|
+
},
|
|
59
|
+
"ai/repo_map.json": {
|
|
60
|
+
"hash": "7646f8ddcac9b2573aefd42e6dbf7186",
|
|
61
|
+
"mtime": 1773796492423.4036
|
|
62
|
+
},
|
|
63
|
+
"ai/repo_map.md": {
|
|
64
|
+
"hash": "d3b93db63ba7b92c1bcba98b7682b487",
|
|
65
|
+
"mtime": 1773796492423.4036
|
|
66
|
+
},
|
|
67
|
+
"ai/schema.json": {
|
|
68
|
+
"hash": "b7af586eb15247e9b5c644920a03afa4",
|
|
69
|
+
"mtime": 1773796492433.4038
|
|
70
|
+
},
|
|
71
|
+
"ai/summary.md": {
|
|
72
|
+
"hash": "c97180815314cb04e69623f705703641",
|
|
73
|
+
"mtime": 1773796492424.4036
|
|
74
|
+
},
|
|
75
|
+
"ai/symbols.json": {
|
|
76
|
+
"hash": "86f0962de99584aca04f8773850703ba",
|
|
77
|
+
"mtime": 1773796492428.4036
|
|
78
|
+
},
|
|
79
|
+
"ai/tech_stack.md": {
|
|
80
|
+
"hash": "a84eb022eb8e5959365181abc81e5f9d",
|
|
81
|
+
"mtime": 1773796492426.4036
|
|
82
|
+
},
|
|
83
|
+
"ai/tools.json": {
|
|
84
|
+
"hash": "b1356e52c74e9b3b6a0d397b790a4968",
|
|
85
|
+
"mtime": 1773796492433.4038
|
|
86
|
+
},
|
|
87
|
+
"package.json": {
|
|
88
|
+
"hash": "54188023d3f4898db4ed5ecb0963ad7c",
|
|
89
|
+
"mtime": 1773776957019.264
|
|
90
|
+
},
|
|
91
|
+
"src/app.module.ts": {
|
|
92
|
+
"hash": "340f55f1f816bff231e0d7cceb640a6a",
|
|
93
|
+
"mtime": 1773777098469.8062
|
|
94
|
+
},
|
|
95
|
+
"src/auth/auth.controller.ts": {
|
|
96
|
+
"hash": "042f9828f736d2cd17f81a9f38e92902",
|
|
97
|
+
"mtime": 1773776992110.6333
|
|
98
|
+
},
|
|
99
|
+
"src/auth/auth.module.ts": {
|
|
100
|
+
"hash": "d77f0da16ab8259e61017e585aa84ba1",
|
|
101
|
+
"mtime": 1773776981771.5234
|
|
102
|
+
},
|
|
103
|
+
"src/auth/auth.service.ts": {
|
|
104
|
+
"hash": "82d1c6ef4273438c42f5ec7a6d11af7e",
|
|
105
|
+
"mtime": 1773777003294.753
|
|
106
|
+
},
|
|
107
|
+
"src/auth/dto/login.dto.ts": {
|
|
108
|
+
"hash": "ea30ef087078e1172bffc80a370ebff3",
|
|
109
|
+
"mtime": 1773777024191.979
|
|
110
|
+
},
|
|
111
|
+
"src/auth/strategies/jwt.strategy.ts": {
|
|
112
|
+
"hash": "0f76815e6d72c4b1d3324713b6c09853",
|
|
113
|
+
"mtime": 1773777033163.077
|
|
114
|
+
},
|
|
115
|
+
"src/main.ts": {
|
|
116
|
+
"hash": "37685b56941c1e865638bae7fd76d81c",
|
|
117
|
+
"mtime": 1773777107555.9097
|
|
118
|
+
},
|
|
119
|
+
"src/users/users.controller.ts": {
|
|
120
|
+
"hash": "41b4cfa3872766fb0578a901abd294fa",
|
|
121
|
+
"mtime": 1773777065483.4343
|
|
122
|
+
},
|
|
123
|
+
"src/users/users.module.ts": {
|
|
124
|
+
"hash": "f3eb2901994d3dcf77b5bb6766f937aa",
|
|
125
|
+
"mtime": 1773777054886.3164
|
|
126
|
+
},
|
|
127
|
+
"src/users/users.service.ts": {
|
|
128
|
+
"hash": "34c037f935826f26a9f72d53774a3223",
|
|
129
|
+
"mtime": 1773777078186.5767
|
|
130
|
+
},
|
|
131
|
+
"tsconfig.json": {
|
|
132
|
+
"hash": "f0902e207501d022c8048ac457251ecc",
|
|
133
|
+
"mtime": 1773777131755.1877
|
|
134
|
+
}
|
|
135
|
+
},
|
|
136
|
+
"lastIndexed": "2026-03-18T01:15:17.476Z"
|
|
137
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "src",
|
|
3
|
+
"path": "src",
|
|
4
|
+
"files": [
|
|
5
|
+
"src/app.module.ts",
|
|
6
|
+
"src/auth/auth.controller.ts",
|
|
7
|
+
"src/auth/auth.module.ts",
|
|
8
|
+
"src/auth/auth.service.ts",
|
|
9
|
+
"src/auth/dto/login.dto.ts",
|
|
10
|
+
"src/auth/strategies/jwt.strategy.ts",
|
|
11
|
+
"src/main.ts",
|
|
12
|
+
"src/users/users.controller.ts",
|
|
13
|
+
"src/users/users.module.ts",
|
|
14
|
+
"src/users/users.service.ts"
|
|
15
|
+
],
|
|
16
|
+
"entrypoints": [
|
|
17
|
+
"src/auth/auth.controller.ts",
|
|
18
|
+
"src/auth/auth.service.ts",
|
|
19
|
+
"src/users/users.controller.ts",
|
|
20
|
+
"src/users/users.service.ts"
|
|
21
|
+
],
|
|
22
|
+
"dependencies": []
|
|
23
|
+
}
|