PR-780243: adding only one source of truth.

This commit is contained in:
Alejandro Lembke Barrientos 2023-03-06 22:19:22 +00:00
parent d65cbe8b37
commit 4881de8667
12 changed files with 56 additions and 24 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 = {
testEnvironment: 'node',
transform: {
"^.+\\.ts$": "ts-jest"
},moduleNameMapper: {
...aliases,
},
};

13
package-lock.json generated
View File

@ -45,6 +45,7 @@
"eslint-webpack-plugin": "^4.0.0",
"jest": "^29.5.0",
"nodemon": "^2.0.21",
"resolve-ts-aliases": "^1.0.1",
"supertest": "^6.3.3",
"ts-jest": "^29.0.5",
"ts-loader": "^9.4.2",
@ -9425,6 +9426,12 @@
"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": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/resolve.exports/-/resolve.exports-2.0.0.tgz",
@ -17885,6 +17892,12 @@
"integrity": "sha512-pb/MYmXstAkysRFx8piNI1tGFNQIFA3vkE3Gq4EuA1dF6gHp/+vgZqsCGJapvy8N3Q+4o7FwvquPJcnZ7RYy4g==",
"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": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/resolve.exports/-/resolve.exports-2.0.0.tgz",

View File

@ -66,6 +66,7 @@
"eslint-webpack-plugin": "^4.0.0",
"jest": "^29.5.0",
"nodemon": "^2.0.21",
"resolve-ts-aliases": "^1.0.1",
"supertest": "^6.3.3",
"ts-jest": "^29.0.5",
"ts-loader": "^9.4.2",

View File

@ -1,6 +1,6 @@
'use strict';
import { getTest, addText } from '../../controllers/controllerGraphQL';
import { getTest, addText } from '@controllerGraphQL';
// A map of functions which return data for the schema.
const resolvers = {

View File

@ -1,5 +1,5 @@
import { makeExecutableSchema } from '@graphql-tools/schema';
import resolvers from'../resolvers';
import resolvers from'@GraphQL/resolvers';
import Test from './Test.gql';
// The GraphQL schema

View File

@ -1,8 +1,8 @@
'use strict';
import express from 'express'; //express
import { graphqlHTTP } from 'express-graphql';
import { config } from '../../config';
import schema from './schema';
import { config } from '@config';
import schema from '@GraphQL/schema';
const server = express.Router();//Router de Express

View File

@ -1,6 +1,6 @@
'use strict';
import { getTestModel, addTextModel } from '../../models';
import { getTestModel, addTextModel } from '@models';
// eslint-disable-next-line
export const getTest = async ({rootValue, args, context}) => {

View File

@ -6,11 +6,11 @@ import cors from 'cors';
import cookieParser from 'cookie-parser';
import { useServer } from 'graphql-ws/lib/use/ws';
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 schema from './GraphQL/schema';
import { config } from '../config';
import apiRouter from './routes';
import schema from '@GraphQL/schema';
import { config } from '@config';
import apiRouter from '@routes';
const app = express(), //creating app
whitelist = config.WHITELIST_URLS,

View File

@ -1,4 +1,4 @@
import server from '../../index';
import server from '@src';
import supertest from 'supertest';
describe('global server tests', () => {
let request;

View File

@ -6,6 +6,23 @@
"moduleResolution": "node",
"sourceMap": true,
"typeRoots" : ["./src/@types", "./node_modules/@types"],
"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"]
}

View File

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

View File

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