Skip to content

Commit f5852be

Browse files
committed
changes
1 parent 017e3c5 commit f5852be

File tree

3 files changed

+36
-10
lines changed

3 files changed

+36
-10
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11

2+
typeOrm.sh

netepscript.sh

Lines changed: 35 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -159,9 +159,9 @@ npx json -I -f package.json -e 'this.scripts["lint:fix"]="eslint . --ext .ts --f
159159

160160
echo -e "${YELLOW}\n12) Choose your database engine:${NC}"
161161
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"
165165
echo "5) No database engine"
166166
read -p "Enter your choice (1-5): " db_choice
167167

@@ -172,21 +172,48 @@ case "$db_choice" in
172172
npm install -D @types/pg @types/sequelize
173173
echo -e "\n# PostgreSQL Configuration\nDB_HOST=localhost\nDB_PORT=5432\nDB_NAME=your_database\nDB_USER=your_username\nDB_PASSWORD=your_password" >> .env
174174
;;
175-
"2")
175+
"3")
176176
echo "Installing MySQL and Sequelize dependencies..."
177177
npm install mysql2 sequelize
178178
npm install -D @types/mysql @types/sequelize
179179
echo -e "\n# MySQL Configuration\nDB_HOST=localhost\nDB_PORT=3306\nDB_NAME=your_database\nDB_USER=your_username\nDB_PASSWORD=your_password" >> .env
180180
;;
181-
"3")
181+
"4")
182182
echo "Installing MongoDB and Mongoose dependencies..."
183183
npm install mongodb mongoose
184184
npm install -D @types/mongodb @types/mongoose
185185
echo -e "\n# MongoDB Configuration\nMONGO_URI=mongodb://localhost:27017/your_database" >> .env
186186
;;
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
190217
;;
191218
"5")
192219
echo "No database dependencies installed."

typeOrm.sh

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
npm install typeorm reflect-metadata pg
22

3-
4-
#Typescript config file modification
53
sed -i.bak '
64
s/\/\/ *"emitDecoratorMetadata": *true,/"emitDecoratorMetadata": true,/g
75
s/\/\/ *"experimentalDecorators": *true,/"experimentalDecorators": true,/g

0 commit comments

Comments
 (0)