nodejs-quickstart-structure 1.18.1 → 1.19.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/CHANGELOG.md +7 -0
- package/README.md +2 -1
- package/lib/modules/caching-setup.js +76 -73
- package/lib/modules/kafka-setup.js +249 -191
- package/lib/modules/project-setup.js +1 -0
- package/package.json +13 -2
- package/templates/clean-architecture/js/src/errors/BadRequestError.js +11 -10
- package/templates/clean-architecture/js/src/errors/BadRequestError.spec.js.ejs +22 -21
- package/templates/clean-architecture/js/src/errors/NotFoundError.js +11 -10
- package/templates/clean-architecture/js/src/errors/NotFoundError.spec.js.ejs +22 -21
- package/templates/clean-architecture/js/src/infrastructure/repositories/UserRepository.js.ejs +69 -39
- package/templates/clean-architecture/js/src/infrastructure/repositories/UserRepository.spec.js.ejs +142 -81
- package/templates/clean-architecture/js/src/interfaces/controllers/userController.js.ejs +156 -75
- package/templates/clean-architecture/js/src/interfaces/controllers/userController.spec.js.ejs +234 -138
- package/templates/clean-architecture/js/src/interfaces/graphql/resolvers/user.resolvers.js.ejs +27 -21
- package/templates/clean-architecture/js/src/interfaces/graphql/resolvers/user.resolvers.spec.js.ejs +66 -49
- package/templates/clean-architecture/js/src/interfaces/graphql/typeDefs/user.types.js.ejs +19 -17
- package/templates/clean-architecture/js/src/interfaces/routes/api.js +12 -10
- package/templates/clean-architecture/js/src/usecases/DeleteUser.js +11 -0
- package/templates/clean-architecture/js/src/usecases/DeleteUser.spec.js.ejs +47 -0
- package/templates/clean-architecture/js/src/usecases/UpdateUser.js +11 -0
- package/templates/clean-architecture/js/src/usecases/UpdateUser.spec.js.ejs +48 -0
- package/templates/clean-architecture/js/src/utils/errorMessages.js +14 -0
- package/templates/clean-architecture/ts/src/errors/BadRequestError.spec.ts.ejs +22 -21
- package/templates/clean-architecture/ts/src/errors/BadRequestError.ts +9 -8
- package/templates/clean-architecture/ts/src/errors/NotFoundError.spec.ts.ejs +22 -21
- package/templates/clean-architecture/ts/src/errors/NotFoundError.ts +9 -8
- package/templates/clean-architecture/ts/src/infrastructure/repositories/UserRepository.spec.ts.ejs +175 -85
- package/templates/clean-architecture/ts/src/infrastructure/repositories/userRepository.ts.ejs +74 -0
- package/templates/clean-architecture/ts/src/interfaces/controllers/userController.spec.ts.ejs +331 -185
- package/templates/clean-architecture/ts/src/interfaces/controllers/userController.ts.ejs +173 -84
- package/templates/clean-architecture/ts/src/interfaces/graphql/resolvers/user.resolvers.spec.ts.ejs +68 -51
- package/templates/clean-architecture/ts/src/interfaces/graphql/resolvers/user.resolvers.ts.ejs +29 -21
- package/templates/clean-architecture/ts/src/interfaces/graphql/typeDefs/user.types.ts.ejs +17 -15
- package/templates/clean-architecture/ts/src/interfaces/routes/userRoutes.ts +13 -11
- package/templates/clean-architecture/ts/src/usecases/deleteUser.spec.ts.ejs +47 -0
- package/templates/clean-architecture/ts/src/usecases/deleteUser.ts +9 -0
- package/templates/clean-architecture/ts/src/usecases/updateUser.spec.ts.ejs +48 -0
- package/templates/clean-architecture/ts/src/usecases/updateUser.ts +9 -0
- package/templates/clean-architecture/ts/src/utils/errorMessages.ts +12 -0
- package/templates/common/.gitattributes +46 -0
- package/templates/common/README.md.ejs +294 -270
- package/templates/common/caching/clean/js/DeleteUser.js.ejs +27 -0
- package/templates/common/caching/clean/js/UpdateUser.js.ejs +27 -0
- package/templates/common/caching/clean/ts/deleteUser.ts.ejs +24 -0
- package/templates/common/caching/clean/ts/updateUser.ts.ejs +25 -0
- package/templates/common/caching/ts/memoryCache.ts.ejs +73 -64
- package/templates/common/caching/ts/redisClient.ts.ejs +89 -80
- package/templates/common/database/js/models/User.js.ejs +79 -53
- package/templates/common/database/js/models/User.js.mongoose.ejs +23 -19
- package/templates/common/database/js/models/User.spec.js.ejs +94 -84
- package/templates/common/database/ts/models/User.spec.ts.ejs +100 -84
- package/templates/common/database/ts/models/User.ts.ejs +87 -61
- package/templates/common/database/ts/models/User.ts.mongoose.ejs +30 -25
- package/templates/common/health/js/healthRoute.js.ejs +50 -47
- package/templates/common/health/ts/healthRoute.ts.ejs +49 -46
- package/templates/common/jest.e2e.config.js.ejs +8 -8
- package/templates/common/kafka/js/messaging/baseConsumer.js.ejs +30 -30
- package/templates/common/kafka/js/messaging/userEventSchema.js.ejs +12 -11
- package/templates/common/kafka/js/messaging/welcomeEmailConsumer.js.ejs +44 -31
- package/templates/common/kafka/js/messaging/welcomeEmailConsumer.spec.js.ejs +86 -49
- package/templates/common/kafka/js/services/kafkaService.js.ejs +93 -93
- package/templates/common/kafka/js/utils/kafkaEvents.js.ejs +7 -0
- package/templates/common/kafka/ts/messaging/userEventSchema.spec.ts.ejs +51 -51
- package/templates/common/kafka/ts/messaging/userEventSchema.ts.ejs +12 -11
- package/templates/common/kafka/ts/messaging/welcomeEmailConsumer.spec.ts.ejs +86 -49
- package/templates/common/kafka/ts/messaging/welcomeEmailConsumer.ts.ejs +38 -25
- package/templates/common/kafka/ts/services/kafkaService.ts.ejs +95 -95
- package/templates/common/kafka/ts/utils/kafkaEvents.ts.ejs +5 -0
- package/templates/common/shutdown/js/gracefulShutdown.js.ejs +65 -61
- package/templates/common/shutdown/js/gracefulShutdown.spec.js.ejs +149 -160
- package/templates/common/shutdown/ts/gracefulShutdown.spec.ts.ejs +179 -158
- package/templates/common/shutdown/ts/gracefulShutdown.ts.ejs +59 -55
- package/templates/common/src/tests/e2e/e2e.users.test.js.ejs +120 -49
- package/templates/common/src/tests/e2e/e2e.users.test.ts.ejs +120 -49
- package/templates/common/swagger.yml.ejs +118 -66
- package/templates/db/mysql/V1__Initial_Setup.sql.ejs +10 -9
- package/templates/db/postgres/V1__Initial_Setup.sql.ejs +10 -9
- package/templates/mvc/js/src/controllers/userController.js.ejs +246 -105
- package/templates/mvc/js/src/controllers/userController.spec.js.ejs +481 -209
- package/templates/mvc/js/src/errors/BadRequestError.js +11 -10
- package/templates/mvc/js/src/errors/BadRequestError.spec.js.ejs +22 -21
- package/templates/mvc/js/src/errors/NotFoundError.js +11 -10
- package/templates/mvc/js/src/errors/NotFoundError.spec.js.ejs +22 -21
- package/templates/mvc/js/src/graphql/resolvers/user.resolvers.js.ejs +25 -19
- package/templates/mvc/js/src/graphql/resolvers/user.resolvers.spec.js.ejs +64 -47
- package/templates/mvc/js/src/graphql/typeDefs/user.types.js.ejs +19 -17
- package/templates/mvc/js/src/routes/api.js +10 -8
- package/templates/mvc/js/src/routes/api.spec.js.ejs +41 -36
- package/templates/mvc/js/src/utils/errorMessages.js +14 -0
- package/templates/mvc/ts/src/controllers/userController.spec.ts.ejs +481 -203
- package/templates/mvc/ts/src/controllers/userController.ts.ejs +248 -107
- package/templates/mvc/ts/src/errors/BadRequestError.spec.ts.ejs +22 -21
- package/templates/mvc/ts/src/errors/BadRequestError.ts +9 -8
- package/templates/mvc/ts/src/errors/NotFoundError.spec.ts.ejs +27 -21
- package/templates/mvc/ts/src/errors/NotFoundError.ts +9 -8
- package/templates/mvc/ts/src/graphql/resolvers/user.resolvers.spec.ts.ejs +68 -51
- package/templates/mvc/ts/src/graphql/resolvers/user.resolvers.ts.ejs +29 -21
- package/templates/mvc/ts/src/graphql/typeDefs/user.types.ts.ejs +17 -15
- package/templates/mvc/ts/src/index.ts.ejs +156 -153
- package/templates/mvc/ts/src/routes/api.spec.ts.ejs +59 -40
- package/templates/mvc/ts/src/routes/api.ts +12 -10
- package/templates/mvc/ts/src/utils/errorMessages.ts +12 -0
- package/templates/clean-architecture/ts/src/infrastructure/repositories/UserRepository.ts.ejs +0 -37
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,12 @@
|
|
|
1
1
|
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
2
2
|
|
|
3
|
+
## [1.19.0] - 2026-03-28
|
|
4
|
+
|
|
5
|
+
### Added
|
|
6
|
+
- **Security Hardening**: Added `SECURITY.md` file to the project.
|
|
7
|
+
- **Git Attributes**: Added `.gitattributes` file to the project.
|
|
8
|
+
- **Contributing Guide**: Added `CONTRIBUTING.md` file to the project.
|
|
9
|
+
|
|
3
10
|
## [1.18.1] - 2026-03-27
|
|
4
11
|
|
|
5
12
|
### Fixed
|
package/README.md
CHANGED
|
@@ -20,7 +20,7 @@ A powerful CLI tool to scaffold production-ready Node.js microservices with buil
|
|
|
20
20
|
- [⚙️ Configuration Options](#-configuration-options)
|
|
21
21
|
- [🏗️ Generated Project Structure](#-generated-project-structure)
|
|
22
22
|
- [📖 Documentation](#-documentation)
|
|
23
|
-
- [🗺️
|
|
23
|
+
- [🗺️ Support & Roadmap](#️-roadmap--support)
|
|
24
24
|
|
|
25
25
|
---
|
|
26
26
|
|
|
@@ -53,6 +53,7 @@ nodejs-quickstart init
|
|
|
53
53
|
- **Communication Patterns**: Supports **REST**, **GraphQL** (Apollo), and **Kafka** (Event-driven).
|
|
54
54
|
- **Multi-layer Caching**: Integrated **Redis** or built-in **Memory Cache**.
|
|
55
55
|
- **AI-Native Optimized**: specifically designed for **Cursor** and AI agents, including built-in `.cursorrules` and Agent Skill prompts. 🚀
|
|
56
|
+
- **Next Gen Web UI**: (Coming Soon) A modern, browser-based project selector featuring real-time virtualization — set for release in v2.0.0!
|
|
56
57
|
|
|
57
58
|
---
|
|
58
59
|
|
|
@@ -1,73 +1,76 @@
|
|
|
1
|
-
import fs from 'fs-extra';
|
|
2
|
-
import path from 'path';
|
|
3
|
-
import ejs from 'ejs';
|
|
4
|
-
|
|
5
|
-
export const setupCaching = async (templatesDir, targetDir, config) => {
|
|
6
|
-
const { caching, language, architecture } = config;
|
|
7
|
-
if (!caching || caching === 'None') return;
|
|
8
|
-
|
|
9
|
-
if (caching === 'Redis' || caching === 'Memory Cache') {
|
|
10
|
-
const langExt = language === 'TypeScript' ? 'ts' : 'js';
|
|
11
|
-
const clientObj = caching === 'Redis'
|
|
12
|
-
? (language === 'TypeScript' ? 'redisClient.ts' : 'redisClient.js')
|
|
13
|
-
: (language === 'TypeScript' ? 'memoryCache.ts' : 'memoryCache.js');
|
|
14
|
-
const cacheSource = path.join(templatesDir, 'common', 'caching', langExt, `${clientObj}.ejs`);
|
|
15
|
-
|
|
16
|
-
let cacheTarget;
|
|
17
|
-
let loggerPath;
|
|
18
|
-
|
|
19
|
-
if (architecture === 'MVC') {
|
|
20
|
-
await fs.ensureDir(path.join(targetDir, 'src/config'));
|
|
21
|
-
cacheTarget = path.join(targetDir, 'src/config', clientObj);
|
|
22
|
-
loggerPath = language === 'TypeScript' ? '@/utils/logger' : '../utils/logger';
|
|
23
|
-
} else {
|
|
24
|
-
// Clean Architecture
|
|
25
|
-
await fs.ensureDir(path.join(targetDir, 'src/infrastructure/caching'));
|
|
26
|
-
cacheTarget = path.join(targetDir, 'src/infrastructure/caching', clientObj);
|
|
27
|
-
loggerPath = language === 'TypeScript' ? '@/infrastructure/log/logger' : '../log/logger';
|
|
28
|
-
|
|
29
|
-
// Overwrite
|
|
30
|
-
const
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
const
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
const
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
const
|
|
67
|
-
const
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
}
|
|
1
|
+
import fs from 'fs-extra';
|
|
2
|
+
import path from 'path';
|
|
3
|
+
import ejs from 'ejs';
|
|
4
|
+
|
|
5
|
+
export const setupCaching = async (templatesDir, targetDir, config) => {
|
|
6
|
+
const { caching, language, architecture } = config;
|
|
7
|
+
if (!caching || caching === 'None') return;
|
|
8
|
+
|
|
9
|
+
if (caching === 'Redis' || caching === 'Memory Cache') {
|
|
10
|
+
const langExt = language === 'TypeScript' ? 'ts' : 'js';
|
|
11
|
+
const clientObj = caching === 'Redis'
|
|
12
|
+
? (language === 'TypeScript' ? 'redisClient.ts' : 'redisClient.js')
|
|
13
|
+
: (language === 'TypeScript' ? 'memoryCache.ts' : 'memoryCache.js');
|
|
14
|
+
const cacheSource = path.join(templatesDir, 'common', 'caching', langExt, `${clientObj}.ejs`);
|
|
15
|
+
|
|
16
|
+
let cacheTarget;
|
|
17
|
+
let loggerPath;
|
|
18
|
+
|
|
19
|
+
if (architecture === 'MVC') {
|
|
20
|
+
await fs.ensureDir(path.join(targetDir, 'src/config'));
|
|
21
|
+
cacheTarget = path.join(targetDir, 'src/config', clientObj);
|
|
22
|
+
loggerPath = language === 'TypeScript' ? '@/utils/logger' : '../utils/logger';
|
|
23
|
+
} else {
|
|
24
|
+
// Clean Architecture
|
|
25
|
+
await fs.ensureDir(path.join(targetDir, 'src/infrastructure/caching'));
|
|
26
|
+
cacheTarget = path.join(targetDir, 'src/infrastructure/caching', clientObj);
|
|
27
|
+
loggerPath = language === 'TypeScript' ? '@/infrastructure/log/logger' : '../log/logger';
|
|
28
|
+
|
|
29
|
+
// Overwrite UseCases with Caching Enabled
|
|
30
|
+
const useCases = language === 'TypeScript'
|
|
31
|
+
? [
|
|
32
|
+
{ name: 'getAllUsers.ts', src: 'getAllUsers.ts.ejs' },
|
|
33
|
+
{ name: 'createUser.ts', src: 'createUser.ts.ejs' },
|
|
34
|
+
{ name: 'updateUser.ts', src: 'updateUser.ts.ejs' },
|
|
35
|
+
{ name: 'deleteUser.ts', src: 'deleteUser.ts.ejs' }
|
|
36
|
+
]
|
|
37
|
+
: [
|
|
38
|
+
{ name: 'GetAllUsers.js', src: 'GetAllUsers.js.ejs' },
|
|
39
|
+
{ name: 'CreateUser.js', src: 'CreateUser.js.ejs' },
|
|
40
|
+
{ name: 'UpdateUser.js', src: 'UpdateUser.js.ejs' },
|
|
41
|
+
{ name: 'DeleteUser.js', src: 'DeleteUser.js.ejs' }
|
|
42
|
+
];
|
|
43
|
+
|
|
44
|
+
const useCaseTargetDir = path.join(targetDir, 'src/usecases');
|
|
45
|
+
await fs.ensureDir(useCaseTargetDir);
|
|
46
|
+
|
|
47
|
+
for (const uc of useCases) {
|
|
48
|
+
const useCaseSource = path.join(templatesDir, 'common', 'caching', 'clean', langExt, uc.src);
|
|
49
|
+
if (await fs.pathExists(useCaseSource)) {
|
|
50
|
+
const ucContent = await fs.readFile(useCaseSource, 'utf-8');
|
|
51
|
+
const renderedUc = ejs.render(ucContent, { caching });
|
|
52
|
+
await fs.writeFile(path.join(useCaseTargetDir, uc.name), renderedUc);
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
if (await fs.pathExists(cacheSource)) {
|
|
58
|
+
const cacheTemplate = await fs.readFile(cacheSource, 'utf-8');
|
|
59
|
+
const content = ejs.render(cacheTemplate, { loggerPath });
|
|
60
|
+
await fs.writeFile(cacheTarget, content);
|
|
61
|
+
|
|
62
|
+
// Render Spec if exists
|
|
63
|
+
const specTemplateName = clientObj.replace(`.${langExt}`, `.spec.${langExt}.ejs`);
|
|
64
|
+
const specTemplateSource = path.join(templatesDir, 'common', 'caching', langExt, specTemplateName);
|
|
65
|
+
if (await fs.pathExists(specTemplateSource)) {
|
|
66
|
+
const specTemplate = await fs.readFile(specTemplateSource, 'utf-8');
|
|
67
|
+
const specLoggerPath = architecture === 'Clean Architecture' ? '@/infrastructure/log/logger' : '@/utils/logger';
|
|
68
|
+
const specRedisPath = architecture === 'Clean Architecture' ? '@/infrastructure/caching/redisClient' : '@/config/redisClient';
|
|
69
|
+
const specContent = ejs.render(specTemplate, { ...config, loggerPath: specLoggerPath, redisClientPath: specRedisPath });
|
|
70
|
+
const specTarget = cacheTarget.replace(`${path.sep}src${path.sep}`, `${path.sep}tests${path.sep}unit${path.sep}`).replace(`.${langExt}`, `.spec.${langExt}`);
|
|
71
|
+
await fs.ensureDir(path.dirname(specTarget));
|
|
72
|
+
await fs.writeFile(specTarget, specContent);
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
};
|