@@ -159,9 +159,9 @@ npx json -I -f package.json -e 'this.scripts["lint:fix"]="eslint . --ext .ts --f
159
159
160
160
echo -e " ${YELLOW} \n12) Choose your database engine:${NC} "
161
161
echo " 1) PostgreSQL with Sequelize"
162
- echo " 2) MySQL with Sequelize "
163
- echo " 3) MongoDB with Mongoose "
164
- echo " 4) typeORM with postgres "
162
+ echo " 2) PostgreSQL with typeORM "
163
+ echo " 3) MySQL with Sequelize "
164
+ echo " 4) MongoDB with Mongoose "
165
165
echo " 5) No database engine"
166
166
read -p " Enter your choice (1-5): " db_choice
167
167
@@ -172,21 +172,48 @@ case "$db_choice" in
172
172
npm install -D @types/pg @types/sequelize
173
173
echo -e " \n# PostgreSQL Configuration\nDB_HOST=localhost\nDB_PORT=5432\nDB_NAME=your_database\nDB_USER=your_username\nDB_PASSWORD=your_password" >> .env
174
174
;;
175
- " 2 " )
175
+ " 3 " )
176
176
echo " Installing MySQL and Sequelize dependencies..."
177
177
npm install mysql2 sequelize
178
178
npm install -D @types/mysql @types/sequelize
179
179
echo -e " \n# MySQL Configuration\nDB_HOST=localhost\nDB_PORT=3306\nDB_NAME=your_database\nDB_USER=your_username\nDB_PASSWORD=your_password" >> .env
180
180
;;
181
- " 3 " )
181
+ " 4 " )
182
182
echo " Installing MongoDB and Mongoose dependencies..."
183
183
npm install mongodb mongoose
184
184
npm install -D @types/mongodb @types/mongoose
185
185
echo -e " \n# MongoDB Configuration\nMONGO_URI=mongodb://localhost:27017/your_database" >> .env
186
186
;;
187
- " 4" )
188
- echo " Installing typeORM dependencies..."
189
- bash typeOrm.sh
187
+ " 2" )
188
+ echo " Installing PostgreSQL and typeORM dependencies..."
189
+ npm install typeorm reflect-metadata pg
190
+
191
+ sed -i.bak '
192
+ s/\/\/ *"emitDecoratorMetadata": *true,/"emitDecoratorMetadata": true,/g
193
+ s/\/\/ *"experimentalDecorators": *true,/"experimentalDecorators": true,/g
194
+ s/\/\/ *"lib": *\[\],/"lib": ["ES6"],/g
195
+ s/\/\/ *"strictPropertyInitialization": *true,/"strictPropertyInitialization": false,/g
196
+ ' tsconfig.json && rm tsconfig.json.bak
197
+
198
+
199
+ cat << EOF > src/config/data-source.ts
200
+ import { DataSource } from 'typeorm';
201
+
202
+ export const AppDataSource = new DataSource({
203
+ type: 'postgres',
204
+ host: 'localhost',
205
+ port: 5432,
206
+ username: 'postgres',
207
+ password: 'postgres',
208
+ database: 'new_database', //This database must be created before initialize the typeorm
209
+ dropSchema: false, //Erase database content when the server starts
210
+ synchronize: true,
211
+ logging: false, // Don't log queries in the console
212
+ entities: [],
213
+ subscribers: [],
214
+ migrations: [],
215
+ });
216
+ EOF
190
217
;;
191
218
" 5" )
192
219
echo " No database dependencies installed."
0 commit comments