From 9a0fbea4a2b8f5f23d03012bc7c93c50bbd1b7da Mon Sep 17 00:00:00 2001 From: Gisela Torres Date: Mon, 10 Jun 2024 12:20:07 +0200 Subject: [PATCH 1/5] Add sample data for dev container environment --- .devcontainer/db-init.sql | 15 +++++++++++++++ .devcontainer/docker-compose.yaml | 2 ++ README.md | 12 ++++++++++++ 3 files changed, 29 insertions(+) create mode 100644 .devcontainer/db-init.sql diff --git a/.devcontainer/db-init.sql b/.devcontainer/db-init.sql new file mode 100644 index 0000000..f7f35a9 --- /dev/null +++ b/.devcontainer/db-init.sql @@ -0,0 +1,15 @@ +-- SQL script to initialize the database with sample data + +CREATE TABLE Heroes ( + Id INT PRIMARY KEY, + Name NVARCHAR(100), + AlterEgo NVARCHAR(100), + Description NVARCHAR(255) +); + +INSERT INTO Heroes (Id, Name, AlterEgo, Description) VALUES +(1, 'Batman', 'Bruce Wayne', 'A wealthy American playboy, philanthropist, and owner of Wayne Enterprises.'), +(2, 'Superman', 'Clark Kent', 'A superhero who was born on the planet Krypton and was given the name Kal-El at birth.'), +(3, 'Wonder Woman', 'Diana Prince', 'A demigoddess and warrior princess of the Amazons.'), +(4, 'Flash', 'Barry Allen', 'A superhero with the power of super speed.'), +(5, 'Green Lantern', 'Hal Jordan', 'A test pilot who was chosen to become the first human member of the Green Lantern Corps.'); diff --git a/.devcontainer/docker-compose.yaml b/.devcontainer/docker-compose.yaml index bde12f5..f281635 100644 --- a/.devcontainer/docker-compose.yaml +++ b/.devcontainer/docker-compose.yaml @@ -22,3 +22,5 @@ services: environment: SA_PASSWORD: P@ssword ACCEPT_EULA: Y + volumes: + - ./db-init.sql:/docker-entrypoint-initdb.d/db-init.sql diff --git a/README.md b/README.md index 7bd8854..e27fd3f 100644 --- a/README.md +++ b/README.md @@ -74,3 +74,15 @@ npm start ``` El proceso arrancará y estará disponible en esta dirección: [http://localhost:4200/](http://localhost:4200/) + +## Uso de Datos de Muestra para Pruebas + +Para facilitar las pruebas en el entorno de desarrollo, se ha incluido un conjunto de datos de muestra en la base de datos del contenedor de desarrollo. Estos datos permiten probar la aplicación sin necesidad de configurar una base de datos externa o realizar inserciones manuales de datos. + +Para utilizar estos datos de muestra, asegúrate de que el contenedor de desarrollo esté en ejecución y sigue estos pasos: + +1. Accede al contenedor de la base de datos utilizando tu herramienta de gestión de bases de datos preferida. +2. Verifica que los datos de muestra se han insertado correctamente ejecutando consultas de selección en las tablas relevantes. +3. Utiliza estos datos para realizar pruebas de funcionalidad en la aplicación. + +Estos datos de muestra están diseñados para cubrir casos de uso comunes y facilitar el proceso de desarrollo y pruebas. From b0501cbadc4c7d3f5c3f17a67b59ff43df7cf468 Mon Sep 17 00:00:00 2001 From: Gisela Torres Date: Mon, 10 Jun 2024 12:33:58 +0000 Subject: [PATCH 2/5] chore: Update TypeScript target to ES2022 and add useDefineForClassFields flag --- package-lock.json | 288 +++++++++++++++++++++++++++++++++++++++------- 1 file changed, 245 insertions(+), 43 deletions(-) diff --git a/package-lock.json b/package-lock.json index e888500..42b2595 100644 --- a/package-lock.json +++ b/package-lock.json @@ -8,7 +8,6 @@ "name": "angular-tour-of-heroes", "version": "1.0.0", "dependencies": { - "@typescript-eslint/parser": "^7.12.0", "@angular/animations": "^15.2.10", "@angular/common": "^15.2.10", "@angular/compiler": "^15.2.10", @@ -18,6 +17,7 @@ "@angular/platform-browser-dynamic": "^15.2.10", "@angular/router": "^15.2.10", "@typescript-eslint/eslint-plugin": "^6.16.0", + "@typescript-eslint/parser": "^6.21.0", "prettier": "^3.0.0", "rxjs": "~6.6.0", "tslib": "^2.6.2", @@ -4479,8 +4479,7 @@ "node_modules/@types/json-schema": { "version": "7.0.15", "resolved": "https://registry.npmjs.org/@types/json-schema/-/json-schema-7.0.15.tgz", - "integrity": "sha512-5+fP8P8MFNC+AyZCDxrB2pkZFPGzqQWUzpSeuuVLvm8VMcorNYavBqoFcxK8bQz4Qsbn4oUEEem4wDLfcysGHA==", - "dev": true + "integrity": "sha512-5+fP8P8MFNC+AyZCDxrB2pkZFPGzqQWUzpSeuuVLvm8VMcorNYavBqoFcxK8bQz4Qsbn4oUEEem4wDLfcysGHA==" }, "node_modules/@types/mime": { "version": "1.3.5", @@ -4533,8 +4532,7 @@ "node_modules/@types/semver": { "version": "7.5.0", "resolved": "https://registry.npmjs.org/@types/semver/-/semver-7.5.0.tgz", - "integrity": "sha512-G8hZ6XJiHnuhQKR7ZmysCeJWE08o8T0AXtk5darsCaTVsYZhhgUrq53jizaR2FvsoeCwJhlmwTjkXBY5Pn/ZHw==", - "dev": true + "integrity": "sha512-G8hZ6XJiHnuhQKR7ZmysCeJWE08o8T0AXtk5darsCaTVsYZhhgUrq53jizaR2FvsoeCwJhlmwTjkXBY5Pn/ZHw==" }, "node_modules/@types/send": { "version": "0.17.4", @@ -4584,26 +4582,230 @@ "@types/node": "*" } }, + "node_modules/@typescript-eslint/eslint-plugin": { + "version": "6.21.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/eslint-plugin/-/eslint-plugin-6.21.0.tgz", + "integrity": "sha512-oy9+hTPCUFpngkEZUSzbf9MxI65wbKFoQYsgPdILTfbUldp5ovUuphZVe4i30emU9M/kP+T64Di0mxl7dSw3MA==", + "dependencies": { + "@eslint-community/regexpp": "^4.5.1", + "@typescript-eslint/scope-manager": "6.21.0", + "@typescript-eslint/type-utils": "6.21.0", + "@typescript-eslint/utils": "6.21.0", + "@typescript-eslint/visitor-keys": "6.21.0", + "debug": "^4.3.4", + "graphemer": "^1.4.0", + "ignore": "^5.2.4", + "natural-compare": "^1.4.0", + "semver": "^7.5.4", + "ts-api-utils": "^1.0.1" + }, + "engines": { + "node": "^16.0.0 || >=18.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/typescript-eslint" + }, + "peerDependencies": { + "@typescript-eslint/parser": "^6.0.0 || ^6.0.0-alpha", + "eslint": "^7.0.0 || ^8.0.0" + }, + "peerDependenciesMeta": { + "typescript": { + "optional": true + } + } + }, + "node_modules/@typescript-eslint/eslint-plugin/node_modules/@typescript-eslint/scope-manager": { + "version": "6.21.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/scope-manager/-/scope-manager-6.21.0.tgz", + "integrity": "sha512-OwLUIWZJry80O99zvqXVEioyniJMa+d2GrqpUTqi5/v5D5rOrppJVBPa0yKCblcigC0/aYAzxxqQ1B+DS2RYsg==", + "dependencies": { + "@typescript-eslint/types": "6.21.0", + "@typescript-eslint/visitor-keys": "6.21.0" + }, + "engines": { + "node": "^16.0.0 || >=18.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/typescript-eslint" + } + }, + "node_modules/@typescript-eslint/eslint-plugin/node_modules/@typescript-eslint/type-utils": { + "version": "6.21.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/type-utils/-/type-utils-6.21.0.tgz", + "integrity": "sha512-rZQI7wHfao8qMX3Rd3xqeYSMCL3SoiSQLBATSiVKARdFGCYSRvmViieZjqc58jKgs8Y8i9YvVVhRbHSTA4VBag==", + "dependencies": { + "@typescript-eslint/typescript-estree": "6.21.0", + "@typescript-eslint/utils": "6.21.0", + "debug": "^4.3.4", + "ts-api-utils": "^1.0.1" + }, + "engines": { + "node": "^16.0.0 || >=18.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/typescript-eslint" + }, + "peerDependencies": { + "eslint": "^7.0.0 || ^8.0.0" + }, + "peerDependenciesMeta": { + "typescript": { + "optional": true + } + } + }, + "node_modules/@typescript-eslint/eslint-plugin/node_modules/@typescript-eslint/types": { + "version": "6.21.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-6.21.0.tgz", + "integrity": "sha512-1kFmZ1rOm5epu9NZEZm1kckCDGj5UJEf7P1kliH4LKu/RkwpsfqqGmY2OOcUs18lSlQBKLDYBOGxRVtrMN5lpg==", + "engines": { + "node": "^16.0.0 || >=18.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/typescript-eslint" + } + }, + "node_modules/@typescript-eslint/eslint-plugin/node_modules/@typescript-eslint/typescript-estree": { + "version": "6.21.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-6.21.0.tgz", + "integrity": "sha512-6npJTkZcO+y2/kr+z0hc4HwNfrrP4kNYh57ek7yCNlrBjWQ1Y0OS7jiZTkgumrvkX5HkEKXFZkkdFNkaW2wmUQ==", + "dependencies": { + "@typescript-eslint/types": "6.21.0", + "@typescript-eslint/visitor-keys": "6.21.0", + "debug": "^4.3.4", + "globby": "^11.1.0", + "is-glob": "^4.0.3", + "minimatch": "9.0.3", + "semver": "^7.5.4", + "ts-api-utils": "^1.0.1" + }, + "engines": { + "node": "^16.0.0 || >=18.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/typescript-eslint" + }, + "peerDependenciesMeta": { + "typescript": { + "optional": true + } + } + }, + "node_modules/@typescript-eslint/eslint-plugin/node_modules/@typescript-eslint/utils": { + "version": "6.21.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/utils/-/utils-6.21.0.tgz", + "integrity": "sha512-NfWVaC8HP9T8cbKQxHcsJBY5YE1O33+jpMwN45qzWWaPDZgLIbo12toGMWnmhvCpd3sIxkpDw3Wv1B3dYrbDQQ==", + "dependencies": { + "@eslint-community/eslint-utils": "^4.4.0", + "@types/json-schema": "^7.0.12", + "@types/semver": "^7.5.0", + "@typescript-eslint/scope-manager": "6.21.0", + "@typescript-eslint/types": "6.21.0", + "@typescript-eslint/typescript-estree": "6.21.0", + "semver": "^7.5.4" + }, + "engines": { + "node": "^16.0.0 || >=18.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/typescript-eslint" + }, + "peerDependencies": { + "eslint": "^7.0.0 || ^8.0.0" + } + }, + "node_modules/@typescript-eslint/eslint-plugin/node_modules/@typescript-eslint/visitor-keys": { + "version": "6.21.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-6.21.0.tgz", + "integrity": "sha512-JJtkDduxLi9bivAB+cYOVMtbkqdPOhZ+ZI5LC47MIRrDV4Yn2o+ZnW10Nkmr28xRpSpdJ6Sm42Hjf2+REYXm0A==", + "dependencies": { + "@typescript-eslint/types": "6.21.0", + "eslint-visitor-keys": "^3.4.1" + }, + "engines": { + "node": "^16.0.0 || >=18.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/typescript-eslint" + } + }, + "node_modules/@typescript-eslint/eslint-plugin/node_modules/brace-expansion": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-2.0.1.tgz", + "integrity": "sha512-XnAIvQ8eM+kC6aULx6wuQiwVsnzsi9d3WxzV3FpWTGA19F621kwdbsAcFKXgKUHZWsy+mY6iL1sHTxWEFCytDA==", + "dependencies": { + "balanced-match": "^1.0.0" + } + }, + "node_modules/@typescript-eslint/eslint-plugin/node_modules/globby": { + "version": "11.1.0", + "resolved": "https://registry.npmjs.org/globby/-/globby-11.1.0.tgz", + "integrity": "sha512-jhIXaOzy1sb8IyocaruWSn1TjmnBVs8Ayhcy83rmxNJ8q2uWKCAj3CnJY+KpGSXCueAPc0i05kVvVKtP1t9S3g==", + "dependencies": { + "array-union": "^2.1.0", + "dir-glob": "^3.0.1", + "fast-glob": "^3.2.9", + "ignore": "^5.2.0", + "merge2": "^1.4.1", + "slash": "^3.0.0" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/@typescript-eslint/eslint-plugin/node_modules/minimatch": { + "version": "9.0.3", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-9.0.3.tgz", + "integrity": "sha512-RHiac9mvaRw0x3AYRgDC1CxAP7HTcNrrECeA8YYJeWnpo+2Q5CegtZjaotWTWxDG3UeGA1coE05iH1mPjT/2mg==", + "dependencies": { + "brace-expansion": "^2.0.1" + }, + "engines": { + "node": ">=16 || 14 >=14.17" + }, + "funding": { + "url": "https://github.com/sponsors/isaacs" + } + }, + "node_modules/@typescript-eslint/eslint-plugin/node_modules/slash": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/slash/-/slash-3.0.0.tgz", + "integrity": "sha512-g9Q1haeby36OSStwb4ntCGGGaKsaVSjQ68fBxoQcutl5fS1vuY18H3wSt3jFyFtrkx+Kz0V1G85A4MyAdDMi2Q==", + "engines": { + "node": ">=8" + } + }, "node_modules/@typescript-eslint/parser": { - "version": "7.12.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/parser/-/parser-7.12.0.tgz", - "integrity": "sha512-dm/J2UDY3oV3TKius2OUZIFHsomQmpHtsV0FTh1WO8EKgHLQ1QCADUqscPgTpU+ih1e21FQSRjXckHn3txn6kQ==", - "dependencies": { - "@typescript-eslint/scope-manager": "7.12.0", - "@typescript-eslint/types": "7.12.0", - "@typescript-eslint/typescript-estree": "7.12.0", - "@typescript-eslint/visitor-keys": "7.12.0", + "version": "6.21.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/parser/-/parser-6.21.0.tgz", + "integrity": "sha512-tbsV1jPne5CkFQCgPBcDOt30ItF7aJoZL997JSF7MhGQqOeT3svWRYxiqlfA5RUdlHN6Fi+EI9bxqbdyAUZjYQ==", + "dependencies": { + "@typescript-eslint/scope-manager": "6.21.0", + "@typescript-eslint/types": "6.21.0", + "@typescript-eslint/typescript-estree": "6.21.0", + "@typescript-eslint/visitor-keys": "6.21.0", "debug": "^4.3.4" }, "engines": { - "node": "^18.18.0 || >=20.0.0" + "node": "^16.0.0 || >=18.0.0" }, "funding": { "type": "opencollective", "url": "https://opencollective.com/typescript-eslint" }, "peerDependencies": { - "eslint": "^8.56.0" + "eslint": "^7.0.0 || ^8.0.0" }, "peerDependenciesMeta": { "typescript": { @@ -4612,15 +4814,15 @@ } }, "node_modules/@typescript-eslint/parser/node_modules/@typescript-eslint/scope-manager": { - "version": "7.12.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/scope-manager/-/scope-manager-7.12.0.tgz", - "integrity": "sha512-itF1pTnN6F3unPak+kutH9raIkL3lhH1YRPGgt7QQOh43DQKVJXmWkpb+vpc/TiDHs6RSd9CTbDsc/Y+Ygq7kg==", + "version": "6.21.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/scope-manager/-/scope-manager-6.21.0.tgz", + "integrity": "sha512-OwLUIWZJry80O99zvqXVEioyniJMa+d2GrqpUTqi5/v5D5rOrppJVBPa0yKCblcigC0/aYAzxxqQ1B+DS2RYsg==", "dependencies": { - "@typescript-eslint/types": "7.12.0", - "@typescript-eslint/visitor-keys": "7.12.0" + "@typescript-eslint/types": "6.21.0", + "@typescript-eslint/visitor-keys": "6.21.0" }, "engines": { - "node": "^18.18.0 || >=20.0.0" + "node": "^16.0.0 || >=18.0.0" }, "funding": { "type": "opencollective", @@ -4628,11 +4830,11 @@ } }, "node_modules/@typescript-eslint/parser/node_modules/@typescript-eslint/types": { - "version": "7.12.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-7.12.0.tgz", - "integrity": "sha512-o+0Te6eWp2ppKY3mLCU+YA9pVJxhUJE15FV7kxuD9jgwIAa+w/ycGJBMrYDTpVGUM/tgpa9SeMOugSabWFq7bg==", + "version": "6.21.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-6.21.0.tgz", + "integrity": "sha512-1kFmZ1rOm5epu9NZEZm1kckCDGj5UJEf7P1kliH4LKu/RkwpsfqqGmY2OOcUs18lSlQBKLDYBOGxRVtrMN5lpg==", "engines": { - "node": "^18.18.0 || >=20.0.0" + "node": "^16.0.0 || >=18.0.0" }, "funding": { "type": "opencollective", @@ -4640,21 +4842,21 @@ } }, "node_modules/@typescript-eslint/parser/node_modules/@typescript-eslint/typescript-estree": { - "version": "7.12.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-7.12.0.tgz", - "integrity": "sha512-5bwqLsWBULv1h6pn7cMW5dXX/Y2amRqLaKqsASVwbBHMZSnHqE/HN4vT4fE0aFsiwxYvr98kqOWh1a8ZKXalCQ==", + "version": "6.21.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-6.21.0.tgz", + "integrity": "sha512-6npJTkZcO+y2/kr+z0hc4HwNfrrP4kNYh57ek7yCNlrBjWQ1Y0OS7jiZTkgumrvkX5HkEKXFZkkdFNkaW2wmUQ==", "dependencies": { - "@typescript-eslint/types": "7.12.0", - "@typescript-eslint/visitor-keys": "7.12.0", + "@typescript-eslint/types": "6.21.0", + "@typescript-eslint/visitor-keys": "6.21.0", "debug": "^4.3.4", "globby": "^11.1.0", "is-glob": "^4.0.3", - "minimatch": "^9.0.4", - "semver": "^7.6.0", - "ts-api-utils": "^1.3.0" + "minimatch": "9.0.3", + "semver": "^7.5.4", + "ts-api-utils": "^1.0.1" }, "engines": { - "node": "^18.18.0 || >=20.0.0" + "node": "^16.0.0 || >=18.0.0" }, "funding": { "type": "opencollective", @@ -4667,15 +4869,15 @@ } }, "node_modules/@typescript-eslint/parser/node_modules/@typescript-eslint/visitor-keys": { - "version": "7.12.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-7.12.0.tgz", - "integrity": "sha512-uZk7DevrQLL3vSnfFl5bj4sL75qC9D6EdjemIdbtkuUmIheWpuiiylSY01JxJE7+zGrOWDZrp1WxOuDntvKrHQ==", + "version": "6.21.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-6.21.0.tgz", + "integrity": "sha512-JJtkDduxLi9bivAB+cYOVMtbkqdPOhZ+ZI5LC47MIRrDV4Yn2o+ZnW10Nkmr28xRpSpdJ6Sm42Hjf2+REYXm0A==", "dependencies": { - "@typescript-eslint/types": "7.12.0", - "eslint-visitor-keys": "^3.4.3" + "@typescript-eslint/types": "6.21.0", + "eslint-visitor-keys": "^3.4.1" }, "engines": { - "node": "^18.18.0 || >=20.0.0" + "node": "^16.0.0 || >=18.0.0" }, "funding": { "type": "opencollective", @@ -4710,9 +4912,9 @@ } }, "node_modules/@typescript-eslint/parser/node_modules/minimatch": { - "version": "9.0.4", - "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-9.0.4.tgz", - "integrity": "sha512-KqWh+VchfxcMNRAJjj2tnsSJdNbHsVgnkBhTNrW7AjVo6OvLtxw8zfT9oLw1JSohlFzJ8jCoTgaoXvJ+kHt6fw==", + "version": "9.0.3", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-9.0.3.tgz", + "integrity": "sha512-RHiac9mvaRw0x3AYRgDC1CxAP7HTcNrrECeA8YYJeWnpo+2Q5CegtZjaotWTWxDG3UeGA1coE05iH1mPjT/2mg==", "dependencies": { "brace-expansion": "^2.0.1" }, From 9f1adc59d964cf5b6e8c9f31e0ab290f55586343 Mon Sep 17 00:00:00 2001 From: Gisela Torres Date: Mon, 10 Jun 2024 13:49:31 +0000 Subject: [PATCH 3/5] chore: Update database initialization script and devcontainer configuration This commit updates the database initialization script and devcontainer configuration files. The changes include creating a new database called "heroes" and adding a table called "Heroes" with columns for Id, Name, AlterEgo, and Description. Sample data for heroes is also inserted into the table. Additionally, the devcontainer configuration is updated to include the necessary settings for connecting to the database. These changes ensure that the database is properly initialized and the development environment is configured correctly. --- .devcontainer/db-init.sql | 12 +++++++++++- .devcontainer/devcontainer.json | 17 +++++++++++++++++ .devcontainer/docker-compose.yaml | 22 ++++++++++++++++++++-- 3 files changed, 48 insertions(+), 3 deletions(-) diff --git a/.devcontainer/db-init.sql b/.devcontainer/db-init.sql index f7f35a9..0960e6d 100644 --- a/.devcontainer/db-init.sql +++ b/.devcontainer/db-init.sql @@ -1,4 +1,10 @@ --- SQL script to initialize the database with sample data +CREATE DATABASE heroes; +GO; + + +USE heroes; +GO; + CREATE TABLE Heroes ( Id INT PRIMARY KEY, @@ -7,9 +13,13 @@ CREATE TABLE Heroes ( Description NVARCHAR(255) ); +GO; + INSERT INTO Heroes (Id, Name, AlterEgo, Description) VALUES (1, 'Batman', 'Bruce Wayne', 'A wealthy American playboy, philanthropist, and owner of Wayne Enterprises.'), (2, 'Superman', 'Clark Kent', 'A superhero who was born on the planet Krypton and was given the name Kal-El at birth.'), (3, 'Wonder Woman', 'Diana Prince', 'A demigoddess and warrior princess of the Amazons.'), (4, 'Flash', 'Barry Allen', 'A superhero with the power of super speed.'), (5, 'Green Lantern', 'Hal Jordan', 'A test pilot who was chosen to become the first human member of the Green Lantern Corps.'); + +GO; \ No newline at end of file diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index 6b8028e..03c0fbf 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -15,8 +15,25 @@ ], "customizations": { "vscode": { + "settings": { + "mssql.connections": [ + { + "server": "db,1433", + "database": "heroes", + "authenticationType": "SqlLogin", + "user": "sa", + "password": "P@ssword", + "emptyPasswordInput": false, + "savePassword": false, + "profileName": "mssql-container", + "trustServerCertificate": true + } + ] + }, + "extensions": [ "ms-azuretools.vscode-docker", + "ms-mssql.mssql", "GitHub.copilot", "dbaeumer.vscode-eslint", "DavidAnson.vscode-markdownlint", diff --git a/.devcontainer/docker-compose.yaml b/.devcontainer/docker-compose.yaml index f281635..2a85c62 100644 --- a/.devcontainer/docker-compose.yaml +++ b/.devcontainer/docker-compose.yaml @@ -10,17 +10,35 @@ services: API_URL: https://${CODESPACE_NAME}-5010.${GITHUB_CODESPACES_PORT_FORWARDING_DOMAIN}/api/hero command: sleep infinity api: + depends_on: + - db + - init-db image: ghcr.io/0gis0/tour-of-heroes-dotnet-api/tour-of-heroes-api:6b947c4 environment: - ASPNETCORE_ENVIRONMENT=Development - ConnectionStrings__DefaultConnection=Server=db,1433;Initial Catalog=heroes;Persist Security Info=False;User ID=sa;Password=P@ssword;TrustServerCertificate=True; ports: - "5010:5000" - db: + db: image: mcr.microsoft.com/azure-sql-edge restart: unless-stopped environment: SA_PASSWORD: P@ssword ACCEPT_EULA: Y + init-db: + image: mcr.microsoft.com/azure-sql-edge + command: > + /bin/bash -c " + # Comando para esperar a que SQL esté listo (pseudocódigo) + while ! sqlcmd -U sa -P P@ssword -Q 'SELECT 1'; do + sleep 1 + done; + # Comando para inicializar la base de datos, reemplazar con tu script real + sqlcmd -U sa -P P@ssword -i /init/db-init.sql; + " volumes: - - ./db-init.sql:/docker-entrypoint-initdb.d/db-init.sql + - ./db-init.sql:/init/db-init.sql + environment: + SA_PASSWORD: P@ssword + ACCEPT_EULA: Y + restart: on-failure \ No newline at end of file From 8c8b97e0ca154d9977d24f62e6faf0b35945ce07 Mon Sep 17 00:00:00 2001 From: 0GiS0 Date: Mon, 10 Jun 2024 20:29:44 +0000 Subject: [PATCH 4/5] chore: Update database initialization script and devcontainer configuration --- .devcontainer/db-init.sql | 32 ++++++++++++++++--------------- .devcontainer/docker-compose.yaml | 21 ++++++++++---------- 2 files changed, 28 insertions(+), 25 deletions(-) diff --git a/.devcontainer/db-init.sql b/.devcontainer/db-init.sql index 0960e6d..ea1a65d 100644 --- a/.devcontainer/db-init.sql +++ b/.devcontainer/db-init.sql @@ -1,19 +1,22 @@ -CREATE DATABASE heroes; -GO; - +IF NOT EXISTS(SELECT * FROM sys.databases WHERE name = 'heroes') +BEGIN + CREATE DATABASE heroes; +END +GO USE heroes; -GO; - +GO -CREATE TABLE Heroes ( - Id INT PRIMARY KEY, - Name NVARCHAR(100), - AlterEgo NVARCHAR(100), - Description NVARCHAR(255) -); - -GO; +IF NOT EXISTS (SELECT * FROM sys.tables WHERE name = 'Heroes') +BEGIN + CREATE TABLE Heroes ( + Id INT PRIMARY KEY, + Name NVARCHAR(100), + AlterEgo NVARCHAR(100), + Description NVARCHAR(255) + ); +END +GO INSERT INTO Heroes (Id, Name, AlterEgo, Description) VALUES (1, 'Batman', 'Bruce Wayne', 'A wealthy American playboy, philanthropist, and owner of Wayne Enterprises.'), @@ -21,5 +24,4 @@ INSERT INTO Heroes (Id, Name, AlterEgo, Description) VALUES (3, 'Wonder Woman', 'Diana Prince', 'A demigoddess and warrior princess of the Amazons.'), (4, 'Flash', 'Barry Allen', 'A superhero with the power of super speed.'), (5, 'Green Lantern', 'Hal Jordan', 'A test pilot who was chosen to become the first human member of the Green Lantern Corps.'); - -GO; \ No newline at end of file +GO \ No newline at end of file diff --git a/.devcontainer/docker-compose.yaml b/.devcontainer/docker-compose.yaml index 2a85c62..296d40f 100644 --- a/.devcontainer/docker-compose.yaml +++ b/.devcontainer/docker-compose.yaml @@ -27,17 +27,18 @@ services: ACCEPT_EULA: Y init-db: image: mcr.microsoft.com/azure-sql-edge - command: > - /bin/bash -c " - # Comando para esperar a que SQL esté listo (pseudocódigo) - while ! sqlcmd -U sa -P P@ssword -Q 'SELECT 1'; do - sleep 1 - done; - # Comando para inicializar la base de datos, reemplazar con tu script real - sqlcmd -U sa -P P@ssword -i /init/db-init.sql; - " + command: > + /bin/bash -c " + while ! /opt/mssql-tools/bin/sqlcmd -S db -U sa -P 'P@ssword' -Q 'SELECT * FROM sys.databases' > /dev/null 2>&1; do + echo 'Waiting for SQL Server to become available...' + sleep 1 + done; + echo 'SQL Server is now available.' + + /opt/mssql-tools/bin/sqlcmd -S db -U sa -P 'P@ssword' -i /tmp/db-init.sql; + " volumes: - - ./db-init.sql:/init/db-init.sql + - ./db-init.sql:/tmp/db-init.sql environment: SA_PASSWORD: P@ssword ACCEPT_EULA: Y From 2bb9023660bdfafafcfebe277eb6e45ef77db7ad Mon Sep 17 00:00:00 2001 From: 0GiS0 Date: Mon, 10 Jun 2024 20:31:28 +0000 Subject: [PATCH 5/5] chore: Update devcontainer configuration for connecting to the "heroes" database --- .devcontainer/devcontainer.json | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index 03c0fbf..5a78a6a 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -17,18 +17,18 @@ "vscode": { "settings": { "mssql.connections": [ - { - "server": "db,1433", - "database": "heroes", - "authenticationType": "SqlLogin", - "user": "sa", - "password": "P@ssword", - "emptyPasswordInput": false, - "savePassword": false, - "profileName": "mssql-container", - "trustServerCertificate": true - } - ] + { + "server": "db,1433", + "database": "heroes", + "authenticationType": "SqlLogin", + "user": "sa", + "password": "P@ssword", + "emptyPasswordInput": false, + "savePassword": false, + "profileName": "mssql-container", + "trustServerCertificate": true + } + ] }, "extensions": [