Merge pull request #25 from aleleba/PR-780243

PR-780243: Adding strict mode to typescript and only one source of truth to aliases.
This commit is contained in:
Alejandro Lembke Barrientos 2023-03-06 17:27:01 -06:00 committed by GitHub
commit 6ff6edaaf4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
13 changed files with 338 additions and 43 deletions

View File

@ -1,6 +1,15 @@
const { pathsToModuleNameMapper } = require('ts-jest');
const { compilerOptions } = require('./tsconfig');
const aliases = pathsToModuleNameMapper(compilerOptions.paths, {
prefix: '<rootDir>'
});
module.exports = { module.exports = {
testEnvironment: 'node', testEnvironment: 'node',
transform: { transform: {
"^.+\\.ts$": "ts-jest" "^.+\\.ts$": "ts-jest"
},moduleNameMapper: {
...aliases,
}, },
}; };

267
package-lock.json generated
View File

@ -1,12 +1,12 @@
{ {
"name": "@aleleba/create-node-ts-graphql-server", "name": "@aleleba/create-node-ts-graphql-server",
"version": "1.2.11", "version": "1.2.12",
"lockfileVersion": 2, "lockfileVersion": 2,
"requires": true, "requires": true,
"packages": { "packages": {
"": { "": {
"name": "@aleleba/create-node-ts-graphql-server", "name": "@aleleba/create-node-ts-graphql-server",
"version": "1.2.11", "version": "1.2.12",
"license": "MIT", "license": "MIT",
"dependencies": { "dependencies": {
"@graphql-tools/schema": "^9.0.16", "@graphql-tools/schema": "^9.0.16",
@ -32,10 +32,16 @@
"@babel/preset-env": "^7.20.2", "@babel/preset-env": "^7.20.2",
"@babel/preset-typescript": "^7.21.0", "@babel/preset-typescript": "^7.21.0",
"@babel/register": "^7.21.0", "@babel/register": "^7.21.0",
"@types/body-parser": "^1.19.2",
"@types/cookie-parser": "^1.4.3",
"@types/cors": "^2.8.13",
"@types/express": "^4.17.17",
"@types/jest": "^29.4.0", "@types/jest": "^29.4.0",
"@types/node": "^18.14.6", "@types/node": "^18.14.6",
"@types/supertest": "^2.0.12",
"@types/webpack": "^5.28.0", "@types/webpack": "^5.28.0",
"@types/webpack-node-externals": "^3.0.0", "@types/webpack-node-externals": "^3.0.0",
"@types/ws": "^8.5.4",
"@typescript-eslint/eslint-plugin": "^5.54.0", "@typescript-eslint/eslint-plugin": "^5.54.0",
"@typescript-eslint/parser": "^5.54.0", "@typescript-eslint/parser": "^5.54.0",
"babel-loader": "^9.1.2", "babel-loader": "^9.1.2",
@ -45,6 +51,7 @@
"eslint-webpack-plugin": "^4.0.0", "eslint-webpack-plugin": "^4.0.0",
"jest": "^29.5.0", "jest": "^29.5.0",
"nodemon": "^2.0.21", "nodemon": "^2.0.21",
"resolve-ts-aliases": "^1.0.1",
"supertest": "^6.3.3", "supertest": "^6.3.3",
"ts-jest": "^29.0.5", "ts-jest": "^29.0.5",
"ts-loader": "^9.4.2", "ts-loader": "^9.4.2",
@ -3056,6 +3063,49 @@
"@babel/types": "^7.3.0" "@babel/types": "^7.3.0"
} }
}, },
"node_modules/@types/body-parser": {
"version": "1.19.2",
"resolved": "https://registry.npmjs.org/@types/body-parser/-/body-parser-1.19.2.tgz",
"integrity": "sha512-ALYone6pm6QmwZoAgeyNksccT9Q4AWZQ6PvfwR37GT6r6FWUPguq6sUmNGSMV2Wr761oQoBxwGGa6DR5o1DC9g==",
"dev": true,
"dependencies": {
"@types/connect": "*",
"@types/node": "*"
}
},
"node_modules/@types/connect": {
"version": "3.4.35",
"resolved": "https://registry.npmjs.org/@types/connect/-/connect-3.4.35.tgz",
"integrity": "sha512-cdeYyv4KWoEgpBISTxWvqYsVy444DOqehiF3fM3ne10AmJ62RSyNkUnxMJXHQWRQQX2eR94m5y1IZyDwBjV9FQ==",
"dev": true,
"dependencies": {
"@types/node": "*"
}
},
"node_modules/@types/cookie-parser": {
"version": "1.4.3",
"resolved": "https://registry.npmjs.org/@types/cookie-parser/-/cookie-parser-1.4.3.tgz",
"integrity": "sha512-CqSKwFwefj4PzZ5n/iwad/bow2hTCh0FlNAeWLtQM3JA/NX/iYagIpWG2cf1bQKQ2c9gU2log5VUCrn7LDOs0w==",
"dev": true,
"dependencies": {
"@types/express": "*"
}
},
"node_modules/@types/cookiejar": {
"version": "2.1.2",
"resolved": "https://registry.npmjs.org/@types/cookiejar/-/cookiejar-2.1.2.tgz",
"integrity": "sha512-t73xJJrvdTjXrn4jLS9VSGRbz0nUY3cl2DMGDU48lKl+HR9dbbjW2A9r3g40VA++mQpy6uuHg33gy7du2BKpog==",
"dev": true
},
"node_modules/@types/cors": {
"version": "2.8.13",
"resolved": "https://registry.npmjs.org/@types/cors/-/cors-2.8.13.tgz",
"integrity": "sha512-RG8AStHlUiV5ysZQKq97copd2UmVYw3/pRMLefISZ3S1hK104Cwm7iLQ3fTKx+lsUH2CE8FlLaYeEA2LSeqYUA==",
"dev": true,
"dependencies": {
"@types/node": "*"
}
},
"node_modules/@types/eslint": { "node_modules/@types/eslint": {
"version": "8.21.0", "version": "8.21.0",
"resolved": "https://registry.npmjs.org/@types/eslint/-/eslint-8.21.0.tgz", "resolved": "https://registry.npmjs.org/@types/eslint/-/eslint-8.21.0.tgz",
@ -3082,6 +3132,29 @@
"integrity": "sha512-CuPgU6f3eT/XgKKPqKd/gLZV1Xmvf1a2R5POBOGQa6uv82xpls89HU5zKeVoyR8XzHd1RGNOlQlvUe3CFkjWNQ==", "integrity": "sha512-CuPgU6f3eT/XgKKPqKd/gLZV1Xmvf1a2R5POBOGQa6uv82xpls89HU5zKeVoyR8XzHd1RGNOlQlvUe3CFkjWNQ==",
"dev": true "dev": true
}, },
"node_modules/@types/express": {
"version": "4.17.17",
"resolved": "https://registry.npmjs.org/@types/express/-/express-4.17.17.tgz",
"integrity": "sha512-Q4FmmuLGBG58btUnfS1c1r/NQdlp3DMfGDGig8WhfpA2YRUtEkxAjkZb0yvplJGYdF1fsQ81iMDcH24sSCNC/Q==",
"dev": true,
"dependencies": {
"@types/body-parser": "*",
"@types/express-serve-static-core": "^4.17.33",
"@types/qs": "*",
"@types/serve-static": "*"
}
},
"node_modules/@types/express-serve-static-core": {
"version": "4.17.33",
"resolved": "https://registry.npmjs.org/@types/express-serve-static-core/-/express-serve-static-core-4.17.33.tgz",
"integrity": "sha512-TPBqmR/HRYI3eC2E5hmiivIzv+bidAfXofM+sbonAGvyDhySGw9/PQZFt2BLOrjUUR++4eJVpx6KnLQK1Fk9tA==",
"dev": true,
"dependencies": {
"@types/node": "*",
"@types/qs": "*",
"@types/range-parser": "*"
}
},
"node_modules/@types/glob": { "node_modules/@types/glob": {
"version": "7.2.0", "version": "7.2.0",
"resolved": "https://registry.npmjs.org/@types/glob/-/glob-7.2.0.tgz", "resolved": "https://registry.npmjs.org/@types/glob/-/glob-7.2.0.tgz",
@ -3141,6 +3214,12 @@
"integrity": "sha512-wOuvG1SN4Us4rez+tylwwwCV1psiNVOkJeM3AUWUNWg/jDQY2+HE/444y5gc+jBmRqASOm2Oeh5c1axHobwRKQ==", "integrity": "sha512-wOuvG1SN4Us4rez+tylwwwCV1psiNVOkJeM3AUWUNWg/jDQY2+HE/444y5gc+jBmRqASOm2Oeh5c1axHobwRKQ==",
"dev": true "dev": true
}, },
"node_modules/@types/mime": {
"version": "3.0.1",
"resolved": "https://registry.npmjs.org/@types/mime/-/mime-3.0.1.tgz",
"integrity": "sha512-Y4XFY5VJAuw0FgAqPNd6NNoV44jbq9Bz2L7Rh/J6jLTiHBSBJa9fxqQIvkIld4GsoDOcCbvzOUAbLPsSKKg+uA==",
"dev": true
},
"node_modules/@types/minimatch": { "node_modules/@types/minimatch": {
"version": "3.0.5", "version": "3.0.5",
"resolved": "https://registry.npmjs.org/@types/minimatch/-/minimatch-3.0.5.tgz", "resolved": "https://registry.npmjs.org/@types/minimatch/-/minimatch-3.0.5.tgz",
@ -3159,18 +3238,59 @@
"integrity": "sha512-KufADq8uQqo1pYKVIYzfKbJfBAc0sOeXqGbFaSpv8MRmC/zXgowNZmFcbngndGk922QDmOASEXUZCaY48gs4cg==", "integrity": "sha512-KufADq8uQqo1pYKVIYzfKbJfBAc0sOeXqGbFaSpv8MRmC/zXgowNZmFcbngndGk922QDmOASEXUZCaY48gs4cg==",
"dev": true "dev": true
}, },
"node_modules/@types/qs": {
"version": "6.9.7",
"resolved": "https://registry.npmjs.org/@types/qs/-/qs-6.9.7.tgz",
"integrity": "sha512-FGa1F62FT09qcrueBA6qYTrJPVDzah9a+493+o2PCXsesWHIn27G98TsSMs3WPNbZIEj4+VJf6saSFpvD+3Zsw==",
"dev": true
},
"node_modules/@types/range-parser": {
"version": "1.2.4",
"resolved": "https://registry.npmjs.org/@types/range-parser/-/range-parser-1.2.4.tgz",
"integrity": "sha512-EEhsLsD6UsDM1yFhAvy0Cjr6VwmpMWqFBCb9w07wVugF7w9nfajxLuVmngTIpgS6svCnm6Vaw+MZhoDCKnOfsw==",
"dev": true
},
"node_modules/@types/semver": { "node_modules/@types/semver": {
"version": "7.3.13", "version": "7.3.13",
"resolved": "https://registry.npmjs.org/@types/semver/-/semver-7.3.13.tgz", "resolved": "https://registry.npmjs.org/@types/semver/-/semver-7.3.13.tgz",
"integrity": "sha512-21cFJr9z3g5dW8B0CVI9g2O9beqaThGQ6ZFBqHfwhzLDKUxaqTIy3vnfah/UPkfOiF2pLq+tGz+W8RyCskuslw==", "integrity": "sha512-21cFJr9z3g5dW8B0CVI9g2O9beqaThGQ6ZFBqHfwhzLDKUxaqTIy3vnfah/UPkfOiF2pLq+tGz+W8RyCskuslw==",
"dev": true "dev": true
}, },
"node_modules/@types/serve-static": {
"version": "1.15.1",
"resolved": "https://registry.npmjs.org/@types/serve-static/-/serve-static-1.15.1.tgz",
"integrity": "sha512-NUo5XNiAdULrJENtJXZZ3fHtfMolzZwczzBbnAeBbqBwG+LaG6YaJtuwzwGSQZ2wsCrxjEhNNjAkKigy3n8teQ==",
"dev": true,
"dependencies": {
"@types/mime": "*",
"@types/node": "*"
}
},
"node_modules/@types/stack-utils": { "node_modules/@types/stack-utils": {
"version": "2.0.1", "version": "2.0.1",
"resolved": "https://registry.npmjs.org/@types/stack-utils/-/stack-utils-2.0.1.tgz", "resolved": "https://registry.npmjs.org/@types/stack-utils/-/stack-utils-2.0.1.tgz",
"integrity": "sha512-Hl219/BT5fLAaz6NDkSuhzasy49dwQS/DSdu4MdggFB8zcXv7vflBI3xp7FEmkmdDkBUI2bPUNeMttp2knYdxw==", "integrity": "sha512-Hl219/BT5fLAaz6NDkSuhzasy49dwQS/DSdu4MdggFB8zcXv7vflBI3xp7FEmkmdDkBUI2bPUNeMttp2knYdxw==",
"dev": true "dev": true
}, },
"node_modules/@types/superagent": {
"version": "4.1.16",
"resolved": "https://registry.npmjs.org/@types/superagent/-/superagent-4.1.16.tgz",
"integrity": "sha512-tLfnlJf6A5mB6ddqF159GqcDizfzbMUB1/DeT59/wBNqzRTNNKsaw79A/1TZ84X+f/EwWH8FeuSkjlCLyqS/zQ==",
"dev": true,
"dependencies": {
"@types/cookiejar": "*",
"@types/node": "*"
}
},
"node_modules/@types/supertest": {
"version": "2.0.12",
"resolved": "https://registry.npmjs.org/@types/supertest/-/supertest-2.0.12.tgz",
"integrity": "sha512-X3HPWTwXRerBZS7Mo1k6vMVR1Z6zmJcDVn5O/31whe0tnjE4te6ZJSJGq1RiqHPjzPdMTfjCFogDJmwng9xHaQ==",
"dev": true,
"dependencies": {
"@types/superagent": "*"
}
},
"node_modules/@types/webpack": { "node_modules/@types/webpack": {
"version": "5.28.0", "version": "5.28.0",
"resolved": "https://registry.npmjs.org/@types/webpack/-/webpack-5.28.0.tgz", "resolved": "https://registry.npmjs.org/@types/webpack/-/webpack-5.28.0.tgz",
@ -3192,6 +3312,15 @@
"webpack": "^5" "webpack": "^5"
} }
}, },
"node_modules/@types/ws": {
"version": "8.5.4",
"resolved": "https://registry.npmjs.org/@types/ws/-/ws-8.5.4.tgz",
"integrity": "sha512-zdQDHKUgcX/zBc4GrwsE/7dVdAD8JR4EuiAXiiUhhfyIJXXb2+PrGshFyeXWQPMmmZ2XxgaqclgpIC7eTXc1mg==",
"dev": true,
"dependencies": {
"@types/node": "*"
}
},
"node_modules/@types/yargs": { "node_modules/@types/yargs": {
"version": "17.0.10", "version": "17.0.10",
"resolved": "https://registry.npmjs.org/@types/yargs/-/yargs-17.0.10.tgz", "resolved": "https://registry.npmjs.org/@types/yargs/-/yargs-17.0.10.tgz",
@ -9425,6 +9554,12 @@
"node": ">=4" "node": ">=4"
} }
}, },
"node_modules/resolve-ts-aliases": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/resolve-ts-aliases/-/resolve-ts-aliases-1.0.1.tgz",
"integrity": "sha512-BEFJ2lO9FhuJ+QVK8ZJxuDaFM2/oXt0YJJU9bS2R4zoWfMQOmrT0fLeSClXo7PMAD/kEbRfcGUHqhYKn/ZFPOg==",
"dev": true
},
"node_modules/resolve.exports": { "node_modules/resolve.exports": {
"version": "2.0.0", "version": "2.0.0",
"resolved": "https://registry.npmjs.org/resolve.exports/-/resolve.exports-2.0.0.tgz", "resolved": "https://registry.npmjs.org/resolve.exports/-/resolve.exports-2.0.0.tgz",
@ -13127,6 +13262,49 @@
"@babel/types": "^7.3.0" "@babel/types": "^7.3.0"
} }
}, },
"@types/body-parser": {
"version": "1.19.2",
"resolved": "https://registry.npmjs.org/@types/body-parser/-/body-parser-1.19.2.tgz",
"integrity": "sha512-ALYone6pm6QmwZoAgeyNksccT9Q4AWZQ6PvfwR37GT6r6FWUPguq6sUmNGSMV2Wr761oQoBxwGGa6DR5o1DC9g==",
"dev": true,
"requires": {
"@types/connect": "*",
"@types/node": "*"
}
},
"@types/connect": {
"version": "3.4.35",
"resolved": "https://registry.npmjs.org/@types/connect/-/connect-3.4.35.tgz",
"integrity": "sha512-cdeYyv4KWoEgpBISTxWvqYsVy444DOqehiF3fM3ne10AmJ62RSyNkUnxMJXHQWRQQX2eR94m5y1IZyDwBjV9FQ==",
"dev": true,
"requires": {
"@types/node": "*"
}
},
"@types/cookie-parser": {
"version": "1.4.3",
"resolved": "https://registry.npmjs.org/@types/cookie-parser/-/cookie-parser-1.4.3.tgz",
"integrity": "sha512-CqSKwFwefj4PzZ5n/iwad/bow2hTCh0FlNAeWLtQM3JA/NX/iYagIpWG2cf1bQKQ2c9gU2log5VUCrn7LDOs0w==",
"dev": true,
"requires": {
"@types/express": "*"
}
},
"@types/cookiejar": {
"version": "2.1.2",
"resolved": "https://registry.npmjs.org/@types/cookiejar/-/cookiejar-2.1.2.tgz",
"integrity": "sha512-t73xJJrvdTjXrn4jLS9VSGRbz0nUY3cl2DMGDU48lKl+HR9dbbjW2A9r3g40VA++mQpy6uuHg33gy7du2BKpog==",
"dev": true
},
"@types/cors": {
"version": "2.8.13",
"resolved": "https://registry.npmjs.org/@types/cors/-/cors-2.8.13.tgz",
"integrity": "sha512-RG8AStHlUiV5ysZQKq97copd2UmVYw3/pRMLefISZ3S1hK104Cwm7iLQ3fTKx+lsUH2CE8FlLaYeEA2LSeqYUA==",
"dev": true,
"requires": {
"@types/node": "*"
}
},
"@types/eslint": { "@types/eslint": {
"version": "8.21.0", "version": "8.21.0",
"resolved": "https://registry.npmjs.org/@types/eslint/-/eslint-8.21.0.tgz", "resolved": "https://registry.npmjs.org/@types/eslint/-/eslint-8.21.0.tgz",
@ -13153,6 +13331,29 @@
"integrity": "sha512-CuPgU6f3eT/XgKKPqKd/gLZV1Xmvf1a2R5POBOGQa6uv82xpls89HU5zKeVoyR8XzHd1RGNOlQlvUe3CFkjWNQ==", "integrity": "sha512-CuPgU6f3eT/XgKKPqKd/gLZV1Xmvf1a2R5POBOGQa6uv82xpls89HU5zKeVoyR8XzHd1RGNOlQlvUe3CFkjWNQ==",
"dev": true "dev": true
}, },
"@types/express": {
"version": "4.17.17",
"resolved": "https://registry.npmjs.org/@types/express/-/express-4.17.17.tgz",
"integrity": "sha512-Q4FmmuLGBG58btUnfS1c1r/NQdlp3DMfGDGig8WhfpA2YRUtEkxAjkZb0yvplJGYdF1fsQ81iMDcH24sSCNC/Q==",
"dev": true,
"requires": {
"@types/body-parser": "*",
"@types/express-serve-static-core": "^4.17.33",
"@types/qs": "*",
"@types/serve-static": "*"
}
},
"@types/express-serve-static-core": {
"version": "4.17.33",
"resolved": "https://registry.npmjs.org/@types/express-serve-static-core/-/express-serve-static-core-4.17.33.tgz",
"integrity": "sha512-TPBqmR/HRYI3eC2E5hmiivIzv+bidAfXofM+sbonAGvyDhySGw9/PQZFt2BLOrjUUR++4eJVpx6KnLQK1Fk9tA==",
"dev": true,
"requires": {
"@types/node": "*",
"@types/qs": "*",
"@types/range-parser": "*"
}
},
"@types/glob": { "@types/glob": {
"version": "7.2.0", "version": "7.2.0",
"resolved": "https://registry.npmjs.org/@types/glob/-/glob-7.2.0.tgz", "resolved": "https://registry.npmjs.org/@types/glob/-/glob-7.2.0.tgz",
@ -13212,6 +13413,12 @@
"integrity": "sha512-wOuvG1SN4Us4rez+tylwwwCV1psiNVOkJeM3AUWUNWg/jDQY2+HE/444y5gc+jBmRqASOm2Oeh5c1axHobwRKQ==", "integrity": "sha512-wOuvG1SN4Us4rez+tylwwwCV1psiNVOkJeM3AUWUNWg/jDQY2+HE/444y5gc+jBmRqASOm2Oeh5c1axHobwRKQ==",
"dev": true "dev": true
}, },
"@types/mime": {
"version": "3.0.1",
"resolved": "https://registry.npmjs.org/@types/mime/-/mime-3.0.1.tgz",
"integrity": "sha512-Y4XFY5VJAuw0FgAqPNd6NNoV44jbq9Bz2L7Rh/J6jLTiHBSBJa9fxqQIvkIld4GsoDOcCbvzOUAbLPsSKKg+uA==",
"dev": true
},
"@types/minimatch": { "@types/minimatch": {
"version": "3.0.5", "version": "3.0.5",
"resolved": "https://registry.npmjs.org/@types/minimatch/-/minimatch-3.0.5.tgz", "resolved": "https://registry.npmjs.org/@types/minimatch/-/minimatch-3.0.5.tgz",
@ -13230,18 +13437,59 @@
"integrity": "sha512-KufADq8uQqo1pYKVIYzfKbJfBAc0sOeXqGbFaSpv8MRmC/zXgowNZmFcbngndGk922QDmOASEXUZCaY48gs4cg==", "integrity": "sha512-KufADq8uQqo1pYKVIYzfKbJfBAc0sOeXqGbFaSpv8MRmC/zXgowNZmFcbngndGk922QDmOASEXUZCaY48gs4cg==",
"dev": true "dev": true
}, },
"@types/qs": {
"version": "6.9.7",
"resolved": "https://registry.npmjs.org/@types/qs/-/qs-6.9.7.tgz",
"integrity": "sha512-FGa1F62FT09qcrueBA6qYTrJPVDzah9a+493+o2PCXsesWHIn27G98TsSMs3WPNbZIEj4+VJf6saSFpvD+3Zsw==",
"dev": true
},
"@types/range-parser": {
"version": "1.2.4",
"resolved": "https://registry.npmjs.org/@types/range-parser/-/range-parser-1.2.4.tgz",
"integrity": "sha512-EEhsLsD6UsDM1yFhAvy0Cjr6VwmpMWqFBCb9w07wVugF7w9nfajxLuVmngTIpgS6svCnm6Vaw+MZhoDCKnOfsw==",
"dev": true
},
"@types/semver": { "@types/semver": {
"version": "7.3.13", "version": "7.3.13",
"resolved": "https://registry.npmjs.org/@types/semver/-/semver-7.3.13.tgz", "resolved": "https://registry.npmjs.org/@types/semver/-/semver-7.3.13.tgz",
"integrity": "sha512-21cFJr9z3g5dW8B0CVI9g2O9beqaThGQ6ZFBqHfwhzLDKUxaqTIy3vnfah/UPkfOiF2pLq+tGz+W8RyCskuslw==", "integrity": "sha512-21cFJr9z3g5dW8B0CVI9g2O9beqaThGQ6ZFBqHfwhzLDKUxaqTIy3vnfah/UPkfOiF2pLq+tGz+W8RyCskuslw==",
"dev": true "dev": true
}, },
"@types/serve-static": {
"version": "1.15.1",
"resolved": "https://registry.npmjs.org/@types/serve-static/-/serve-static-1.15.1.tgz",
"integrity": "sha512-NUo5XNiAdULrJENtJXZZ3fHtfMolzZwczzBbnAeBbqBwG+LaG6YaJtuwzwGSQZ2wsCrxjEhNNjAkKigy3n8teQ==",
"dev": true,
"requires": {
"@types/mime": "*",
"@types/node": "*"
}
},
"@types/stack-utils": { "@types/stack-utils": {
"version": "2.0.1", "version": "2.0.1",
"resolved": "https://registry.npmjs.org/@types/stack-utils/-/stack-utils-2.0.1.tgz", "resolved": "https://registry.npmjs.org/@types/stack-utils/-/stack-utils-2.0.1.tgz",
"integrity": "sha512-Hl219/BT5fLAaz6NDkSuhzasy49dwQS/DSdu4MdggFB8zcXv7vflBI3xp7FEmkmdDkBUI2bPUNeMttp2knYdxw==", "integrity": "sha512-Hl219/BT5fLAaz6NDkSuhzasy49dwQS/DSdu4MdggFB8zcXv7vflBI3xp7FEmkmdDkBUI2bPUNeMttp2knYdxw==",
"dev": true "dev": true
}, },
"@types/superagent": {
"version": "4.1.16",
"resolved": "https://registry.npmjs.org/@types/superagent/-/superagent-4.1.16.tgz",
"integrity": "sha512-tLfnlJf6A5mB6ddqF159GqcDizfzbMUB1/DeT59/wBNqzRTNNKsaw79A/1TZ84X+f/EwWH8FeuSkjlCLyqS/zQ==",
"dev": true,
"requires": {
"@types/cookiejar": "*",
"@types/node": "*"
}
},
"@types/supertest": {
"version": "2.0.12",
"resolved": "https://registry.npmjs.org/@types/supertest/-/supertest-2.0.12.tgz",
"integrity": "sha512-X3HPWTwXRerBZS7Mo1k6vMVR1Z6zmJcDVn5O/31whe0tnjE4te6ZJSJGq1RiqHPjzPdMTfjCFogDJmwng9xHaQ==",
"dev": true,
"requires": {
"@types/superagent": "*"
}
},
"@types/webpack": { "@types/webpack": {
"version": "5.28.0", "version": "5.28.0",
"resolved": "https://registry.npmjs.org/@types/webpack/-/webpack-5.28.0.tgz", "resolved": "https://registry.npmjs.org/@types/webpack/-/webpack-5.28.0.tgz",
@ -13263,6 +13511,15 @@
"webpack": "^5" "webpack": "^5"
} }
}, },
"@types/ws": {
"version": "8.5.4",
"resolved": "https://registry.npmjs.org/@types/ws/-/ws-8.5.4.tgz",
"integrity": "sha512-zdQDHKUgcX/zBc4GrwsE/7dVdAD8JR4EuiAXiiUhhfyIJXXb2+PrGshFyeXWQPMmmZ2XxgaqclgpIC7eTXc1mg==",
"dev": true,
"requires": {
"@types/node": "*"
}
},
"@types/yargs": { "@types/yargs": {
"version": "17.0.10", "version": "17.0.10",
"resolved": "https://registry.npmjs.org/@types/yargs/-/yargs-17.0.10.tgz", "resolved": "https://registry.npmjs.org/@types/yargs/-/yargs-17.0.10.tgz",
@ -17885,6 +18142,12 @@
"integrity": "sha512-pb/MYmXstAkysRFx8piNI1tGFNQIFA3vkE3Gq4EuA1dF6gHp/+vgZqsCGJapvy8N3Q+4o7FwvquPJcnZ7RYy4g==", "integrity": "sha512-pb/MYmXstAkysRFx8piNI1tGFNQIFA3vkE3Gq4EuA1dF6gHp/+vgZqsCGJapvy8N3Q+4o7FwvquPJcnZ7RYy4g==",
"dev": true "dev": true
}, },
"resolve-ts-aliases": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/resolve-ts-aliases/-/resolve-ts-aliases-1.0.1.tgz",
"integrity": "sha512-BEFJ2lO9FhuJ+QVK8ZJxuDaFM2/oXt0YJJU9bS2R4zoWfMQOmrT0fLeSClXo7PMAD/kEbRfcGUHqhYKn/ZFPOg==",
"dev": true
},
"resolve.exports": { "resolve.exports": {
"version": "2.0.0", "version": "2.0.0",
"resolved": "https://registry.npmjs.org/resolve.exports/-/resolve.exports-2.0.0.tgz", "resolved": "https://registry.npmjs.org/resolve.exports/-/resolve.exports-2.0.0.tgz",

View File

@ -1,6 +1,6 @@
{ {
"name": "@aleleba/create-node-ts-graphql-server", "name": "@aleleba/create-node-ts-graphql-server",
"version": "1.2.11", "version": "1.3.0",
"description": "Node with Typescript and GraphQL Server", "description": "Node with Typescript and GraphQL Server",
"bin": "./bin/cli.js", "bin": "./bin/cli.js",
"main": "index.js", "main": "index.js",
@ -53,10 +53,16 @@
"@babel/preset-env": "^7.20.2", "@babel/preset-env": "^7.20.2",
"@babel/preset-typescript": "^7.21.0", "@babel/preset-typescript": "^7.21.0",
"@babel/register": "^7.21.0", "@babel/register": "^7.21.0",
"@types/body-parser": "^1.19.2",
"@types/cookie-parser": "^1.4.3",
"@types/cors": "^2.8.13",
"@types/express": "^4.17.17",
"@types/jest": "^29.4.0", "@types/jest": "^29.4.0",
"@types/node": "^18.14.6", "@types/node": "^18.14.6",
"@types/supertest": "^2.0.12",
"@types/webpack": "^5.28.0", "@types/webpack": "^5.28.0",
"@types/webpack-node-externals": "^3.0.0", "@types/webpack-node-externals": "^3.0.0",
"@types/ws": "^8.5.4",
"@typescript-eslint/eslint-plugin": "^5.54.0", "@typescript-eslint/eslint-plugin": "^5.54.0",
"@typescript-eslint/parser": "^5.54.0", "@typescript-eslint/parser": "^5.54.0",
"babel-loader": "^9.1.2", "babel-loader": "^9.1.2",
@ -66,6 +72,7 @@
"eslint-webpack-plugin": "^4.0.0", "eslint-webpack-plugin": "^4.0.0",
"jest": "^29.5.0", "jest": "^29.5.0",
"nodemon": "^2.0.21", "nodemon": "^2.0.21",
"resolve-ts-aliases": "^1.0.1",
"supertest": "^6.3.3", "supertest": "^6.3.3",
"ts-jest": "^29.0.5", "ts-jest": "^29.0.5",
"ts-loader": "^9.4.2", "ts-loader": "^9.4.2",

View File

@ -1,22 +1,22 @@
'use strict'; 'use strict';
import { getTest, addText } from '../../controllers/controllerGraphQL'; import { getTest, addText } from '@controllerGraphQL';
// A map of functions which return data for the schema. // A map of functions which return data for the schema.
const resolvers = { const resolvers = {
Query: { Query: {
// eslint-disable-next-line // eslint-disable-next-line
test: (rootValue, args, context) => ({}), test: (rootValue: any, args: any, context: any) => ({}),
}, },
Mutation: { Mutation: {
// eslint-disable-next-line // eslint-disable-next-line
testMutation: (rootValue, args, context) => ({}), testMutation: (rootValue: any, args: any, context: any) => ({}),
}, },
Test: { Test: {
test: (rootValue, args, context) => getTest({rootValue, args, context}) test: (rootValue: any, args: any, context: any) => getTest({rootValue, args, context})
}, },
TestMutation: { TestMutation: {
testMutation: (rootValue, args, context) => addText({rootValue, args, context}) testMutation: (rootValue: any, args: any, context: any) => addText({rootValue, args, context})
} }
}; };

View File

@ -1,6 +1,6 @@
import { makeExecutableSchema } from '@graphql-tools/schema'; import { makeExecutableSchema } from '@graphql-tools/schema';
import resolvers from'../resolvers'; import resolvers from'@GraphQL/resolvers';
import Test from './Test.gql'; import Test from '@GraphQL/schema/Test.gql';
// The GraphQL schema // The GraphQL schema
const rootTypes = ` const rootTypes = `

View File

@ -1,8 +1,8 @@
'use strict'; 'use strict';
import express from 'express'; //express import express from 'express'; //express
import { graphqlHTTP } from 'express-graphql'; import { graphqlHTTP } from 'express-graphql';
import { config } from '../../config'; import { config } from '@config';
import schema from './schema'; import schema from '@GraphQL/schema';
const server = express.Router();//Router de Express const server = express.Router();//Router de Express
@ -21,8 +21,9 @@ server.use(
// DO NOT DO app.listen() unless we're testing this directly // DO NOT DO app.listen() unless we're testing this directly
if (require.main === module) { if (require.main === module) {
server.listen((process.env.PORT || 4000), () => { const app = express();
console.log(`Iniciando Express en el puerto 4000${server.graphqlPath}`); /*${app.get('port')}*/ app.listen((process.env.PORT || 4000), () => {
console.log(`Iniciando Express en el puerto 4000`); /*${app.get('port')}*/
}); });
} }

View File

@ -1,14 +1,18 @@
'use strict'; 'use strict';
import { getTestModel, addTextModel } from '../../models'; import { getTestModel, addTextModel } from '@models';
// eslint-disable-next-line // eslint-disable-next-line
export const getTest = async ({rootValue, args, context}) => { export const getTest = async ({}) => {
return getTestModel(); return getTestModel();
}; };
// eslint-disable-next-line // eslint-disable-next-line
export const addText = async ({rootValue, args, context}) => { export const addText = async ({args}: {
rootValue: any
args: { text: string }
context: any
}) => {
const text = args.text; const text = args.text;
return addTextModel({ text }); return addTextModel({ text });
}; };

View File

@ -6,17 +6,17 @@ import cors from 'cors';
import cookieParser from 'cookie-parser'; import cookieParser from 'cookie-parser';
import { useServer } from 'graphql-ws/lib/use/ws'; import { useServer } from 'graphql-ws/lib/use/ws';
import { execute, subscribe } from 'graphql'; import { execute, subscribe } from 'graphql';
import GraphQLserver from './GraphQL/server';// Server of GraphQL, import GraphQLserver from '@GraphQL/server';// Server of GraphQL,
import expressPlayground from 'graphql-playground-middleware-express'; import expressPlayground from 'graphql-playground-middleware-express';
import schema from './GraphQL/schema'; import schema from '@GraphQL/schema';
import { config } from '../config'; import { config } from '@config';
import apiRouter from './routes'; import apiRouter from '@routes';
const app = express(), //creating app const app = express(), //creating app
whitelist = config.WHITELIST_URLS, whitelist = config.WHITELIST_URLS,
corsOptions = { corsOptions = {
origin: function (origin, callback) { origin: function (origin: string | undefined, callback: (arg0: Error | null, arg1?: boolean) => void) {
if (whitelist.indexOf(origin) !== -1 || !origin) { if (whitelist.indexOf(origin as string) !== -1 || !origin) {
callback(null, true); callback(null, true);
} else { } else {
callback(new Error('Not allowed by CORS')); callback(new Error('Not allowed by CORS'));
@ -29,7 +29,7 @@ const app = express(), //creating app
app app
.use(cookieParser()) .use(cookieParser())
.use(express.urlencoded({limit: '500mb', extended: true})) .use(express.urlencoded({limit: '500mb', extended: true}))
.use(express.json({limit: '500mb', extended: true})) .use(express.json({limit: '500mb'}))
.use(cors(corsOptions)) .use(cors(corsOptions))
.use(apiRouter)//Routes de App .use(apiRouter)//Routes de App
.use('/graphql', GraphQLserver);//Server of Graphql .use('/graphql', GraphQLserver);//Server of Graphql

View File

@ -4,6 +4,6 @@ export const getTestModel = async () => {
return 'This is the text response for Test Query from a model'; return 'This is the text response for Test Query from a model';
}; };
export const addTextModel = async ({ text }) => { export const addTextModel = async ({ text }: {text: string}) => {
return `Simulate to insert some text: ${text} from a model`; return `Simulate to insert some text: ${text} from a model`;
}; };

View File

@ -1,7 +1,7 @@
import server from '../../index'; import server from '@src';
import supertest from 'supertest'; import supertest from 'supertest';
describe('global server tests', () => { describe('global server tests', () => {
let request; let request: supertest.SuperTest<supertest.Test>;
beforeEach(() => { beforeEach(() => {
request = supertest(server); request = supertest(server);
}); });

View File

@ -6,6 +6,25 @@
"moduleResolution": "node", "moduleResolution": "node",
"sourceMap": true, "sourceMap": true,
"typeRoots" : ["./src/@types", "./node_modules/@types"], "typeRoots" : ["./src/@types", "./node_modules/@types"],
"strict": true,
"forceConsistentCasingInFileNames": true,
"baseUrl": ".",
"paths": {
"@src/*": ["src/*"],
"@src": ["src"],
"@routes*": ["src/routes/*"],
"@routes": ["src/routes"],
"@controllers/*": ["src/controllers/*"],
"@controllers": ["src/controllers"],
"@models/*": ["src/models/*"],
"@models": ["src/models"],
"@controllerGraphQL/*": ["src/controllers/controllerGraphQL/*"],
"@controllerGraphQL": ["src/controllers/controllerGraphQL"],
"@GraphQL/*": ["src/GraphQL/*"],
"@GraphQL": ["src/GraphQL"],
"@config/*": ["config/*"],
"@config": ["config"]
}
}, },
"lib": ["es2015"] "lib": ["es2015"]
} }

View File

@ -4,11 +4,13 @@ import { CleanWebpackPlugin } from 'clean-webpack-plugin';
import ESLintPlugin from 'eslint-webpack-plugin'; import ESLintPlugin from 'eslint-webpack-plugin';
import nodeExternals from 'webpack-node-externals'; import nodeExternals from 'webpack-node-externals';
import WebpackShellPluginNext from 'webpack-shell-plugin-next'; import WebpackShellPluginNext from 'webpack-shell-plugin-next';
import { resolveTsAliases } from 'resolve-ts-aliases';
import { deFaultValues } from './config'; import { deFaultValues } from './config';
const ROOT_DIR = path.resolve(__dirname); const ROOT_DIR = path.resolve(__dirname);
const resolvePath = (...args) => path.resolve(ROOT_DIR, ...args); const resolvePath = (...args: string[]) => path.resolve(ROOT_DIR, ...args);
const BUILD_DIR = resolvePath('build'); const BUILD_DIR = resolvePath('build');
const alias = resolveTsAliases(path.resolve('tsconfig.json'));
const config = { const config = {
entry: './src/index.ts', entry: './src/index.ts',
@ -21,13 +23,7 @@ const config = {
}, },
resolve: { resolve: {
extensions: ['.js', '.ts', '.json', '.gql'], extensions: ['.js', '.ts', '.json', '.gql'],
alias: { alias,
'@controllers': path.resolve(__dirname, 'controllers/'),
'@models': path.resolve(__dirname, 'models/'),
'@controllerGraphQL': path.resolve(__dirname, 'controllers/controllerGraphQL/'),
'@GraphQL': path.resolve(__dirname, 'GraphQL/'),
'@config': path.resolve(__dirname, 'config/'),
}
}, },
mode: 'development', mode: 'development',
module: { module: {

View File

@ -4,11 +4,13 @@ import TerserPlugin from 'terser-webpack-plugin';
import { CleanWebpackPlugin } from 'clean-webpack-plugin'; import { CleanWebpackPlugin } from 'clean-webpack-plugin';
import ESLintPlugin from 'eslint-webpack-plugin'; import ESLintPlugin from 'eslint-webpack-plugin';
import nodeExternals from 'webpack-node-externals'; import nodeExternals from 'webpack-node-externals';
import { resolveTsAliases } from 'resolve-ts-aliases';
import { deFaultValues } from './config'; import { deFaultValues } from './config';
const ROOT_DIR = path.resolve(__dirname); const ROOT_DIR = path.resolve(__dirname);
const resolvePath = (...args) => path.resolve(ROOT_DIR, ...args); const resolvePath = (...args: string[]) => path.resolve(ROOT_DIR, ...args);
const BUILD_DIR = resolvePath('build'); const BUILD_DIR = resolvePath('build');
const alias = resolveTsAliases(path.resolve('tsconfig.json'));
const config = { const config = {
entry: './src/index.ts', entry: './src/index.ts',
@ -20,13 +22,7 @@ const config = {
}, },
resolve: { resolve: {
extensions: ['.js', '.ts', '.json', '.gql'], extensions: ['.js', '.ts', '.json', '.gql'],
alias: { alias,
'@controllers': path.resolve(__dirname, 'controllers/'),
'@models': path.resolve(__dirname, 'models/'),
'@controllerGraphQL': path.resolve(__dirname, 'controllers/controllerGraphQL/'),
'@GraphQL': path.resolve(__dirname, 'GraphQL/'),
'@config': path.resolve(__dirname, 'config/'),
}
}, },
mode: 'production', mode: 'production',
module: { module: {