You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@@ -134,6 +135,59 @@ Several scripts have been configured in the package.json file in this project to
134
135
- .env: Environment variables.
135
136
- .gitignore: gitignore configuration file.
136
137
138
+
<aname="database-configuration"></a>
139
+
## **Database Configuration** 🗄️
140
+
During the execution of the script, you will be prompted to choose the database configuration. Here are the available options:
141
+
- PostgreSQL with Sequelize
142
+
- PostgreSQL with TypeORM
143
+
- MySQL with Sequelize
144
+
- MongoDB with Mongoose
145
+
- No database engine
146
+
Depending on your choice, the corresponding dependencies will be installed, and the necessary environment variables will be configured.
147
+
- Configuration Example
148
+
If you choose PostgreSQL with Sequelize, the pg and sequelize dependencies will be installed, and the following configuration will be added to your .env file:
149
+
```makefile
150
+
#PostgreSQL Configuration
151
+
DB_HOST=localhost
152
+
DB_PORT=5432
153
+
DB_NAME=your_database
154
+
DB_USER=your_username
155
+
DB_PASSWORD=your_password
156
+
```
157
+
For MongoDB with Mongoose, the added configuration will be:
158
+
```bash
159
+
# MongoDB Configuration
160
+
MONGO_URI=mongodb://localhost:27017/your_database
161
+
```
162
+
For PostgreSQL with TypeORM, in addition to installing the dependencies, the tsconfig.json file will be updated, and the src/config/data-source.ts file will be created with the basic TypeORM configuration:
163
+
164
+
`src/config/data-source.ts`
165
+
```typescrypt
166
+
import { DataSource } from "typeorm";
167
+
168
+
export const AppDataSource = new DataSource({
169
+
type: "postgres",
170
+
host: process.env.DB_HOST,
171
+
port: Number(process.env.DB_PORT),
172
+
username: process.env.DB_USER,
173
+
password: process.env.DB_PASSWORD,
174
+
database: process.env.DB_NAME,
175
+
synchronize: true,
176
+
logging: false,
177
+
entities: ["src/entity/**/*.ts"],
178
+
migrations: ["src/migration/**/*.ts"],
179
+
subscribers: ["src/subscriber/**/*.ts"],
180
+
});
181
+
182
+
AppDataSource.initialize()
183
+
.then(() => {
184
+
console.log("Data Source has been initialized!");
185
+
})
186
+
.catch((err) => {
187
+
console.error("Error during Data Source initialization:", err);
188
+
});
189
+
```
190
+
137
191
<aname="configuration"></a>
138
192
## **Configuration ** 🔧
139
193
@@ -254,6 +308,7 @@ Este script instala Node, Express, TypeScript, ESLint y Prettier automáticament
254
308
-[Instalación](#instalacion) ⚙️
255
309
-[Scripts](#scripts) 📜
256
310
-[Estructura del Proyecto](#estructura-del-proyecto) 🏗️
311
+
-[Configuración de Base de Datos](#configuracion-de-base-de-datos) 🗄️
257
312
-[Configuración](#configuración) 🔧
258
313
-[Contribuciones](#contribuciones) 💡
259
314
-[Contacto](#contacto) 📬
@@ -376,6 +431,63 @@ En este proyecto se han configurado varios scripts en el archivo package.json pa
376
431
- .env: Variables de entorno.
377
432
- .gitignore: Archivo de configuración de gitignore.
378
433
434
+
<aname="configuracion-de-base-de-datos"></a>
435
+
## **Configuración de Bases de Datos** 🗄️
436
+
437
+
Durante la ejecución del script, se te pedirá que elijas la configuración de base de datos. Aquí tienes las opciones disponibles:
438
+
439
+
- PostgreSQL con Sequelize
440
+
- PostgreSQL con TypeORM
441
+
- MySQL con Sequelize
442
+
- MongoDB con Mongoose
443
+
- Sin motor de base de datos
444
+
445
+
Dependiendo de tu elección, se instalarán las dependencias correspondientes y se configurarán las variables de entorno necesarias.
446
+
447
+
-_Ejemplo de Configuración_
448
+
Si eliges PostgreSQL con Sequelize, las dependencias pg y sequelize se instalarán, y se añadirá la siguiente configuración a tu archivo .env:
449
+
```makefile
450
+
#PostgreSQL Configuration
451
+
DB_HOST=localhost
452
+
DB_PORT=5432
453
+
DB_NAME=your_database
454
+
DB_USER=your_username
455
+
DB_PASSWORD=your_password
456
+
```
457
+
Para MongoDB con Mongoose, la configuración añadida será:
458
+
```bash
459
+
# MongoDB Configuration
460
+
MONGO_URI=mongodb://localhost:27017/your_database
461
+
```
462
+
Para PostgreSQL con TypeORM, además de instalar las dependencias, se actualizará el archivo tsconfig.json y se creará el archivo src/config/data-source.ts con la configuración básica de TypeORM:
463
+
464
+
`src/config/data-source.ts`
465
+
```typescript
466
+
import { DataSource } from"typeorm";
467
+
468
+
exportconst AppDataSource =newDataSource({
469
+
type: "postgres",
470
+
host: process.env.DB_HOST,
471
+
port: Number(process.env.DB_PORT),
472
+
username: process.env.DB_USER,
473
+
password: process.env.DB_PASSWORD,
474
+
database: process.env.DB_NAME,
475
+
synchronize: true,
476
+
logging: false,
477
+
entities: ["src/entity/**/*.ts"],
478
+
migrations: ["src/migration/**/*.ts"],
479
+
subscribers: ["src/subscriber/**/*.ts"],
480
+
});
481
+
482
+
AppDataSource.initialize()
483
+
.then(() => {
484
+
console.log("Data Source has been initialized!");
485
+
})
486
+
.catch((err) => {
487
+
console.error("Error during Data Source initialization:", err);
488
+
});
489
+
```
490
+
379
491
<aname="configuracion"></a>
380
492
## **Configuración** 🔧
381
493
@@ -479,7 +591,7 @@ Estamos listos para escuchar tus ideas y explorar cómo podemos trabajar juntos
479
591
480
592
481
593
-**Synergy2Devs**
482
-
- <ahref="mailto:synergy2devs@gmail.com">Escríbenos un email 📧</a>
594
+
- <ahref="mailto:info@synergy2devs.com">Escríbenos un email 📧</a>
0 commit comments