nodejs-quickstart-structure 1.3.5 → 1.4.1
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 +4 -4
- package/docs/generateCase.md +54 -38
- package/docs/generatorFlow.md +171 -0
- package/lib/generator.js +46 -18
- package/lib/prompts.js +1 -1
- package/package.json +4 -3
- package/templates/clean-architecture/js/src/index.js.ejs +5 -0
- package/templates/clean-architecture/js/src/infrastructure/repositories/UserRepository.js.ejs +11 -2
- package/templates/clean-architecture/ts/src/domain/user.ts +1 -1
- package/templates/clean-architecture/ts/src/index.ts.ejs +10 -5
- package/templates/clean-architecture/ts/src/infrastructure/repositories/userRepository.ts.ejs +13 -4
- package/templates/clean-architecture/ts/src/interfaces/controllers/userController.ts +5 -5
- package/templates/clean-architecture/ts/src/interfaces/routes/userRoutes.ts +1 -1
- package/templates/clean-architecture/ts/src/usecases/createUser.ts +2 -2
- package/templates/clean-architecture/ts/src/usecases/getAllUsers.ts +1 -1
- package/templates/common/Dockerfile +1 -0
- package/templates/common/README.md.ejs +1 -1
- package/templates/common/database/js/models/User.js.mongoose.ejs +19 -0
- package/templates/common/database/js/mongoose.js.ejs +32 -0
- package/templates/common/database/ts/models/User.ts.ejs +1 -1
- package/templates/common/database/ts/models/User.ts.mongoose.ejs +25 -0
- package/templates/common/database/ts/mongoose.ts.ejs +27 -0
- package/templates/common/docker-compose.yml.ejs +31 -8
- package/templates/common/jest.config.js.ejs +4 -1
- package/templates/common/kafka/ts/services/kafkaService.ts.ejs +1 -1
- package/templates/common/migrate-mongo-config.js.ejs +31 -0
- package/templates/common/migrations/init.js.ejs +23 -0
- package/templates/common/package.json.ejs +12 -6
- package/templates/common/public/css/style.css +147 -0
- package/templates/common/tsconfig.json +5 -1
- package/templates/common/views/ejs/index.ejs +44 -20
- package/templates/common/views/pug/index.pug +32 -18
- package/templates/mvc/js/src/controllers/userController.js.ejs +3 -1
- package/templates/mvc/js/src/index.js.ejs +6 -1
- package/templates/mvc/ts/src/controllers/userController.ts.ejs +6 -4
- package/templates/mvc/ts/src/index.ts.ejs +11 -7
- package/templates/mvc/ts/src/routes/api.ts +1 -1
|
@@ -4,12 +4,12 @@ import helmet from 'helmet';
|
|
|
4
4
|
import hpp from 'hpp';
|
|
5
5
|
import rateLimit from 'express-rate-limit';
|
|
6
6
|
import dotenv from 'dotenv';
|
|
7
|
-
import logger from '
|
|
8
|
-
<% if (communication === 'REST APIs' || (viewEngine && viewEngine !== 'None')) { %>import apiRoutes from '
|
|
7
|
+
import logger from '@/utils/logger';
|
|
8
|
+
<% if (communication === 'REST APIs' || (viewEngine && viewEngine !== 'None')) { %>import apiRoutes from '@/routes/api';<% } -%>
|
|
9
9
|
<% if (communication === 'REST APIs') { %>
|
|
10
10
|
import swaggerUi from 'swagger-ui-express';
|
|
11
|
-
import swaggerSpecs from '
|
|
12
|
-
<% if (communication === 'Kafka') { %>import { KafkaService } from '
|
|
11
|
+
import swaggerSpecs from '@/config/swagger';<% } -%>
|
|
12
|
+
<% if (communication === 'Kafka') { %>import { KafkaService } from '@/services/kafkaService';<% } -%>
|
|
13
13
|
|
|
14
14
|
dotenv.config();
|
|
15
15
|
|
|
@@ -34,7 +34,7 @@ app.use('/api-docs', swaggerUi.serve, swaggerUi.setup(swaggerSpecs));
|
|
|
34
34
|
import path from 'path';
|
|
35
35
|
app.set('views', path.join(__dirname, 'views'));
|
|
36
36
|
app.set('view engine', '<%= viewEngine.toLowerCase() %>');
|
|
37
|
-
|
|
37
|
+
app.use(express.static(path.join(__dirname, '../public')));<% } -%>
|
|
38
38
|
|
|
39
39
|
// Routes
|
|
40
40
|
<% if (communication === 'REST APIs' || (viewEngine && viewEngine !== 'None')) { -%>
|
|
@@ -60,10 +60,14 @@ const syncDatabase = async () => {
|
|
|
60
60
|
let retries = 30;
|
|
61
61
|
while (retries) {
|
|
62
62
|
try {
|
|
63
|
-
|
|
63
|
+
<% if (database === 'MongoDB') { %>
|
|
64
|
+
const connectDB = (await import('@/config/database')).default;
|
|
65
|
+
await connectDB();
|
|
66
|
+
<% } else { %>
|
|
67
|
+
const sequelize = (await import('@/config/database')).default;
|
|
64
68
|
await sequelize.sync();
|
|
69
|
+
<% } %>
|
|
65
70
|
logger.info('Database synced');
|
|
66
|
-
|
|
67
71
|
// Start Server after DB is ready
|
|
68
72
|
app.listen(port, async () => {
|
|
69
73
|
logger.info(`Server running on port ${port}`);
|