@aleleba/create-node-ts-graphql-server 1.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/.babelrc ADDED
@@ -0,0 +1,6 @@
1
+ {
2
+ "presets": [
3
+ "@babel/preset-env",
4
+ "@babel/preset-typescript"
5
+ ]
6
+ }
package/.env.example ADDED
@@ -0,0 +1,11 @@
1
+ #ENVIRONMENT Defauld production
2
+ ENVIRONMENT=
3
+
4
+ #WHITELIST URLS Default to http://localhost
5
+ WHITELIST_URLS=
6
+
7
+ #GRAPHIQL Default to "false"
8
+ GRAPHIQL=
9
+
10
+ # PORT EXPOSE APP Default to 4000
11
+ PORT=
package/.eslintignore ADDED
@@ -0,0 +1,7 @@
1
+ #Eslint
2
+ .eslintrc.js
3
+ #Build
4
+ build
5
+ #Webpack
6
+ webpack.config.ts
7
+ webpack.config.dev.ts
package/.eslintrc.js ADDED
@@ -0,0 +1,37 @@
1
+ module.exports = {
2
+ 'env': {
3
+ 'browser': true,
4
+ 'es2021': true,
5
+ 'node': true,
6
+ },
7
+ 'extends': [
8
+ 'eslint:recommended',
9
+ 'plugin:@typescript-eslint/recommended'
10
+ ],
11
+ 'parser': '@typescript-eslint/parser',
12
+ 'parserOptions': {
13
+ 'ecmaVersion': 'latest',
14
+ 'sourceType': 'module'
15
+ },
16
+ 'plugins': [
17
+ '@typescript-eslint'
18
+ ],
19
+ 'rules': {
20
+ 'indent': [
21
+ 'error',
22
+ 'tab'
23
+ ],
24
+ 'linebreak-style': [
25
+ 'error',
26
+ 'unix'
27
+ ],
28
+ 'quotes': [
29
+ 'error',
30
+ 'single'
31
+ ],
32
+ 'semi': [
33
+ 'error',
34
+ 'always'
35
+ ]
36
+ }
37
+ };
@@ -0,0 +1,3 @@
1
+ {
2
+ "typescript.tsdk": "node_modules/typescript/lib"
3
+ }
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2022 Alejandro Lembke Barrientos
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,11 @@
1
+ const PRName = function () {
2
+ let ID = '';
3
+ // let characters = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
4
+ const characters = '0123456789';
5
+ for ( let i = 0; i < 6; i++ ) {
6
+ ID += characters.charAt(Math.floor(Math.random() * 10));
7
+ }
8
+ return 'PR-'+ID;
9
+ };
10
+
11
+ console.log(PRName());
package/README.md ADDED
@@ -0,0 +1,73 @@
1
+ # Create Node TS GraphQL Server
2
+
3
+ This project aims to have a starter kit for creating a new Node with typescript, GraphQl server and tools that generally go along with it.
4
+
5
+ Tech(Library or Framework) | Version |
6
+ --- | --- |
7
+ Jest (Testing) | 28.1.0
8
+ Typescript | 4.7.2
9
+
10
+ ## Setup
11
+ To create a new project run in the terminal:
12
+ ```
13
+ npx @aleleba/create-node-ts-graphql-server server-app-name
14
+ ```
15
+ Then run:
16
+ ```
17
+ cd server-app-name
18
+ ```
19
+ You will need to create a new .env file at the root of the project for global config.
20
+ This is an example of config.
21
+ ```
22
+ #ENVIRONMENT Defauld production
23
+ ENVIRONMENT=development
24
+ #WHITELIST URLS Default to http://localhost
25
+ WHITELIST_URLS=https://someurl.com
26
+ #GRAPHIQL Default to "false"
27
+ GRAPHIQL=true
28
+ # PORT EXPOSE APP Default to 4000
29
+ PORT=4000
30
+ ```
31
+ The default environment is production, the server-app port defauld is 4000, the default whitelist is http://localhost and the default graphiql is false.
32
+
33
+ ### For Development
34
+ In the terminal run:
35
+ ```
36
+ npm run start:dev
37
+ ```
38
+ The ENV enviroment variable should be "development" and choose the port of your preference with the enviroment variable PORT.
39
+
40
+ You will find the controllers on:
41
+ ```
42
+ scr/controllers/
43
+ ```
44
+ You will find the models on:
45
+ ```
46
+ scr/models
47
+ ```
48
+ You will find the GraphQL server, resolvers and schema definition on:
49
+ ```
50
+ scr/GraphQL
51
+ ```
52
+
53
+ The manage of the routes for custom API you should find on:
54
+ ```
55
+ scr/routes
56
+ ```
57
+
58
+ This will start the app in development mode, also use nodemon and webpack to real time coding!
59
+ Enjoy coding!
60
+
61
+ ### For Production
62
+ In the terminal run:
63
+ ```
64
+ npm run build
65
+ ```
66
+ It will create a build folder and run:
67
+ ```
68
+ npm start
69
+ ```
70
+ This will start the app.
71
+
72
+ ## Cheers
73
+ Hope you enjoy this proyect! Sincerely Alejandro Lembke Barrientos.
package/bin/cli.js ADDED
@@ -0,0 +1,29 @@
1
+ #!/usr/bin/env node
2
+ const { execSync } = require('child_process');
3
+
4
+ const runCommand = command => {
5
+ try{
6
+ execSync(`${command}`, {stdio: 'inherit'});
7
+ } catch (e) {
8
+ console.error(`Failed to execute ${command}`, e);
9
+ return false;
10
+ }
11
+ return true;
12
+ }
13
+
14
+ const repoName = process.argv[2];
15
+ const gitCheckoutCommand = `git clone --depth 1 https://github.com/aleleba/create-node-ts-graphql-server ${repoName}`;
16
+ const installDepsCommand = `cd ${repoName} && npm install`;
17
+
18
+ console.log(`Cloning the repository with name ${repoName}`);
19
+ const checkedOut = runCommand(gitCheckoutCommand);
20
+ if(!checkedOut) process.exit(-1);
21
+
22
+ console.log(`Installing dependencies for ${repoName}`);
23
+ const installedDeps = runCommand(installDepsCommand);
24
+ if(!installedDeps) process.exit(-1);
25
+
26
+ console.log("Congratulations! You are ready. Follow the following commands to start");
27
+ console.log(`cd ${repoName}`);
28
+ console.log('Create a .env file with ENV=development(defauld: production), PORT=4000 (default: 4000), WHITELIST_URLS=your_url(default: http://localhost), GRAPHIQL=true(default: false)');
29
+ console.log(`Then you can run: npm start:dev`);
@@ -0,0 +1,12 @@
1
+ import * as dotenv from 'dotenv';
2
+
3
+ dotenv.config();
4
+
5
+ export const config = {
6
+ env: process.env.ENVIRONMENT ? process.env.ENVIRONMENT : 'production',
7
+ graphiQL: process.env.GRAPHIQL === 'true' ? true : false,
8
+ whiteList: process.env.WHITELIST_URLS ? process.env.WHITELIST_URLS.split(',') : [
9
+ 'http://localhost'
10
+ ],
11
+ port: process.env.PORT || 4000,
12
+ };
package/jest.config.js ADDED
@@ -0,0 +1,6 @@
1
+ module.exports = {
2
+ testEnvironment: 'node',
3
+ transform: {
4
+ "^.+\\.ts$": "ts-jest"
5
+ },
6
+ };
package/package.json ADDED
@@ -0,0 +1,77 @@
1
+ {
2
+ "name": "@aleleba/create-node-ts-graphql-server",
3
+ "version": "1.0.3",
4
+ "description": "Node with Typescript and GraphQL Server",
5
+ "bin": "./bin/cli.js",
6
+ "main": "index.js",
7
+ "scripts": {
8
+ "start": "node build/index.js",
9
+ "start:dev": "webpack-cli --config webpack.config.dev.ts",
10
+ "start:nodemon": "nodemon build/index.js",
11
+ "build": "webpack-cli --config webpack.config.ts",
12
+ "lint": "eslint ./ --ext .js --ext .ts",
13
+ "lint:fix": "eslint ./ --ext .js --ext .ts --fix",
14
+ "test": "jest",
15
+ "test:watch": "jest --watch"
16
+ },
17
+ "repository": {
18
+ "type": "git",
19
+ "url": "git+https://github.com/aleleba/node-ts-graphql-server.git"
20
+ },
21
+ "keywords": [
22
+ "node",
23
+ "express",
24
+ "typescript",
25
+ "graphql",
26
+ "server"
27
+ ],
28
+ "author": "Alejandro Lembke Barrientos",
29
+ "license": "MIT",
30
+ "bugs": {
31
+ "url": "https://github.com/aleleba/node-ts-graphql-server/issues"
32
+ },
33
+ "homepage": "https://github.com/aleleba/node-ts-graphql-server#readme",
34
+ "dependencies": {
35
+ "@graphql-tools/schema": "^8.3.13",
36
+ "body-parser": "^1.20.0",
37
+ "cookie-parser": "^1.4.6",
38
+ "cors": "^2.8.5",
39
+ "dotenv": "^16.0.1",
40
+ "express": "^4.18.1",
41
+ "express-graphql": "^0.12.0",
42
+ "graphql": "^15.8.0",
43
+ "graphql-subscriptions": "^2.0.0",
44
+ "graphql-tools": "^8.2.11",
45
+ "graphql-ws": "^5.8.2",
46
+ "web-push": "^3.5.0",
47
+ "ws": "^8.6.0"
48
+ },
49
+ "devDependencies": {
50
+ "@babel/core": "^7.18.2",
51
+ "@babel/preset-env": "^7.18.2",
52
+ "@babel/preset-typescript": "^7.17.12",
53
+ "@babel/register": "^7.17.7",
54
+ "@types/jest": "^27.5.1",
55
+ "@types/node": "^17.0.35",
56
+ "@types/webpack": "^5.28.0",
57
+ "@types/webpack-node-externals": "^2.5.3",
58
+ "@typescript-eslint/eslint-plugin": "^5.26.0",
59
+ "@typescript-eslint/parser": "^5.26.0",
60
+ "babel-loader": "^8.2.5",
61
+ "clean-webpack-plugin": "^4.0.0",
62
+ "compression-webpack-plugin": "^10.0.0",
63
+ "eslint": "^8.16.0",
64
+ "eslint-webpack-plugin": "^3.1.1",
65
+ "jest": "^28.1.0",
66
+ "nodemon": "^2.0.16",
67
+ "supertest": "^6.2.3",
68
+ "ts-jest": "^28.0.3",
69
+ "ts-loader": "^9.3.0",
70
+ "typescript": "^4.7.2",
71
+ "webpack": "^5.72.1",
72
+ "webpack-cli": "^4.9.2",
73
+ "webpack-manifest-plugin": "^5.0.0",
74
+ "webpack-node-externals": "^3.0.0",
75
+ "webpack-shell-plugin-next": "^2.2.2"
76
+ }
77
+ }
@@ -0,0 +1,5 @@
1
+ // index.d.ts
2
+ declare module "*.gql" {
3
+ const content: any;
4
+ export default content;
5
+ }
@@ -0,0 +1,23 @@
1
+ 'use strict';
2
+
3
+ import { getTest, addText } from '../../controllers/controllerGraphQL';
4
+
5
+ // A map of functions which return data for the schema.
6
+ const resolvers = {
7
+ Query: {
8
+ // eslint-disable-next-line
9
+ test: (rootValue, args, context) => ({}),
10
+ },
11
+ Mutation: {
12
+ // eslint-disable-next-line
13
+ testMutation: (rootValue, args, context) => ({}),
14
+ },
15
+ Test: {
16
+ test: (rootValue, args, context) => getTest(rootValue, args, context)
17
+ },
18
+ TestMutation: {
19
+ testMutation: (rootValue, args, context) => addText(rootValue, args, context)
20
+ }
21
+ };
22
+
23
+ export default resolvers;
@@ -0,0 +1,13 @@
1
+ module.exports = `
2
+
3
+ """Test Query"""
4
+ type Test {
5
+ test: String
6
+ }
7
+
8
+ """Esta es la Data de LogIn, Si los datos no son correctos devuelve el usuario Null y la conexion en False"""
9
+ type TestMutation {
10
+ testMutation(text: String): String
11
+ }
12
+
13
+ `
@@ -0,0 +1,17 @@
1
+ import { makeExecutableSchema } from '@graphql-tools/schema';
2
+ import resolvers from'../resolvers';
3
+ import Test from './Test.gql';
4
+
5
+ // The GraphQL schema
6
+ const rootTypes = `
7
+ type Query {
8
+ test: Test
9
+ }
10
+ type Mutation {
11
+ testMutation: TestMutation
12
+ }
13
+ `;
14
+
15
+ const typeDefs = [ rootTypes, Test ];
16
+
17
+ export default makeExecutableSchema({typeDefs, resolvers});
@@ -0,0 +1,30 @@
1
+ 'use strict';
2
+ import express from 'express'; //express
3
+ import { graphqlHTTP } from 'express-graphql';
4
+ import { config } from '../../config';
5
+ import schema from './schema';
6
+
7
+ const server = express.Router();//Router de Express
8
+
9
+ server.use(
10
+ '/',
11
+ graphqlHTTP( (req, res) => {
12
+ return {
13
+ schema,
14
+ graphiql: config.graphiQL,
15
+ context: { req, res }
16
+ };
17
+ }),
18
+ );
19
+
20
+
21
+
22
+ // DO NOT DO app.listen() unless we're testing this directly
23
+ if (require.main === module) {
24
+ server.listen((process.env.PORT || 4000), () => {
25
+ console.log(`Iniciando Express en el puerto 4000${server.graphqlPath}`); /*${app.get('port')}*/
26
+ });
27
+ }
28
+
29
+ // Instead do export the app:
30
+ export default server;
@@ -0,0 +1,14 @@
1
+ 'use strict';
2
+
3
+ import { getTestModel, addTextModel } from '../../models';
4
+
5
+ // eslint-disable-next-line
6
+ export const getTest = async (rootValue, args, context) => {
7
+ return getTestModel();
8
+ };
9
+
10
+ // eslint-disable-next-line
11
+ export const addText = async (rootValue, args, context) => {
12
+ const text = args.text;
13
+ return addTextModel({ text });
14
+ };
package/src/index.ts ADDED
@@ -0,0 +1,80 @@
1
+ 'use strict';
2
+
3
+ import ws from 'ws'; // yarn add ws
4
+ import express from 'express'; //express
5
+ import cors from 'cors';
6
+ import cookieParser from 'cookie-parser';
7
+ import { useServer } from 'graphql-ws/lib/use/ws';
8
+ import { execute, subscribe } from 'graphql';
9
+ import GraphQLserver from './GraphQL/server';// Server of GraphQL,
10
+ import schema from './GraphQL/schema';
11
+ import { config } from '../config';
12
+ import apiRouter from './routes';
13
+
14
+
15
+ const app = express(), //creating app
16
+ whitelist = config.whiteList,
17
+ corsOptions = {
18
+ origin: function (origin, callback) {
19
+ if (whitelist.indexOf(origin) !== -1 || !origin) {
20
+ callback(null, true);
21
+ } else {
22
+ callback(new Error('Not allowed by CORS'));
23
+ }
24
+ },
25
+ credentials: true
26
+ };
27
+
28
+ //Inicialization of services of express
29
+ app
30
+ .use(cookieParser())
31
+ .use(express.urlencoded({limit: '500mb', extended: true}))
32
+ .use(express.json({limit: '500mb', extended: true}))
33
+ .use(cors(corsOptions))
34
+ .use(apiRouter)//Routes de App
35
+ .use('/graphql', GraphQLserver);//Server of Graphql
36
+
37
+ // DO NOT DO app.listen() unless we're testing this directly
38
+ if (require.main === module) {
39
+
40
+ const server = app.listen(config.port, () => {
41
+ // create and use the websocket server
42
+ const wsServer = new ws.Server({
43
+ server,
44
+ path: '/graphql',
45
+ });
46
+
47
+ useServer({
48
+ schema,
49
+ execute,
50
+ subscribe,
51
+ // eslint-disable-next-line
52
+ onConnect: (ctx) => {
53
+ //console.log('Connect');
54
+ },
55
+ // eslint-disable-next-line
56
+ onSubscribe: (ctx, msg) => {
57
+ //console.log('Subscribe');
58
+ },
59
+ // eslint-disable-next-line
60
+ onNext: (ctx, msg, args, result) => {
61
+ //console.debug('Next');
62
+ },
63
+ // eslint-disable-next-line
64
+ onError: (ctx, msg, errors) => {
65
+ //console.error('Error');
66
+ },
67
+ // eslint-disable-next-line
68
+ onComplete: (ctx, msg) => {
69
+ //console.log('Complete');
70
+ },
71
+ }, wsServer);
72
+
73
+ console.log(`Starting Express on port ${config.port} and iniciating server of web sockets`);
74
+
75
+ });
76
+
77
+ }
78
+
79
+ // Instead do export the app:
80
+ export default app;
@@ -0,0 +1,9 @@
1
+ 'use strict';
2
+
3
+ export const getTestModel = async () => {
4
+ return 'This is the text response for Test Query from a model';
5
+ };
6
+
7
+ export const addTextModel = async ({ text }) => {
8
+ return `Simulate to insert some text: ${text} from a model`;
9
+ };
@@ -0,0 +1,13 @@
1
+ 'use strict';
2
+
3
+ // use this to set API REST
4
+ import express from 'express';
5
+ import bodyParser from 'body-parser';//bodyParser conversionde Api REST,
6
+
7
+ const apiRouter = express.Router();//Router de Express
8
+
9
+ apiRouter
10
+ .use(bodyParser.json())
11
+ .use(bodyParser.urlencoded({extended: false}));
12
+
13
+ export default apiRouter;
@@ -0,0 +1,36 @@
1
+ import server from '../../index';
2
+ import supertest from 'supertest';
3
+ describe('global server tests', () => {
4
+ let request;
5
+ beforeEach(() => {
6
+ request = supertest(server);
7
+ });
8
+ test('should return Test data from test Query', async () => {
9
+ const bodyResponse = {
10
+ data: {
11
+ test: { test: 'This is the text response for Test Query from a model' }
12
+ }
13
+ }
14
+
15
+ const response = await request.get('/graphql?query=%7B%0A%20%20test%7B%0A%20%20%20%20test%0A%20%20%7D%0A%7D%0A')
16
+ .set('Accept', 'application/json')
17
+ expect(response.status).toEqual(200);
18
+ expect(response.body).toEqual(bodyResponse);
19
+ });
20
+
21
+ test('should return Test data from test Mutation', async () => {
22
+ const bodyResponse = {
23
+ data: {
24
+ testMutation: {
25
+ testMutation: 'Simulate to insert some text: test text from a model'
26
+ }
27
+ }
28
+ }
29
+
30
+ const response = await request.post('/graphql')
31
+ .send({"query":"mutation{\n testMutation{\n testMutation(text: \"test text\")\n }\n}\n","variables":null})
32
+ .set('Accept', 'application/json')
33
+ expect(response.status).toEqual(200);
34
+ expect(response.body).toEqual(bodyResponse);
35
+ });
36
+ });
package/tsconfig.json ADDED
@@ -0,0 +1,11 @@
1
+ {
2
+ "compilerOptions": {
3
+ "module": "commonjs",
4
+ "esModuleInterop": true,
5
+ "target": "es6",
6
+ "moduleResolution": "node",
7
+ "sourceMap": true,
8
+ "typeRoots" : ["./src/@types", "./node_modules/@types"],
9
+ },
10
+ "lib": ["es2015"]
11
+ }
@@ -0,0 +1,66 @@
1
+ import path from 'path';
2
+ import * as dotenv from 'dotenv';
3
+ import webpack from 'webpack';
4
+ import { CleanWebpackPlugin } from 'clean-webpack-plugin';
5
+ import ESLintPlugin from 'eslint-webpack-plugin';
6
+ import nodeExternals from 'webpack-node-externals';
7
+ import WebpackShellPluginNext from 'webpack-shell-plugin-next';
8
+
9
+ const dotEnvToParse = dotenv.config();
10
+
11
+ const ROOT_DIR = path.resolve(__dirname);
12
+ const resolvePath = (...args) => path.resolve(ROOT_DIR, ...args);
13
+ const BUILD_DIR = resolvePath('build');
14
+
15
+ const config = {
16
+ entry: './src/index.ts',
17
+ target: 'node',
18
+ watch: true,
19
+ externals: [nodeExternals()],
20
+ output: {
21
+ path: BUILD_DIR,
22
+ filename: 'index.js',
23
+ },
24
+ resolve: {
25
+ extensions: ['.js', '.ts', '.json', '.gql'],
26
+ alias: {
27
+ '@controllers': path.resolve(__dirname, 'controllers/'),
28
+ '@models': path.resolve(__dirname, 'models/'),
29
+ '@controllerGraphQL': path.resolve(__dirname, 'controllers/controllerGraphQL/'),
30
+ '@GraphQL': path.resolve(__dirname, 'GraphQL/'),
31
+ '@config': path.resolve(__dirname, 'config/'),
32
+ }
33
+ },
34
+ mode: 'development',
35
+ module: {
36
+ rules: [
37
+ {
38
+ test: /\.(js|ts|mjs|gql)$/,
39
+ exclude: /node_modules/,
40
+ use: {
41
+ loader: 'babel-loader',
42
+ },
43
+ },
44
+ {
45
+ test: /\.(ts)$/, loader: "ts-loader",
46
+ exclude: /node_modules/
47
+ },
48
+ ],
49
+ },
50
+ plugins: [
51
+ new CleanWebpackPlugin(),
52
+ new ESLintPlugin(),
53
+ new webpack.DefinePlugin({
54
+ 'process.env': JSON.stringify(dotEnvToParse.parsed),
55
+ }),
56
+ new WebpackShellPluginNext({
57
+ onBuildEnd: {
58
+ scripts: ['npm run start:nodemon'],
59
+ blocking: false,
60
+ parallel: true
61
+ }
62
+ })
63
+ ],
64
+ };
65
+
66
+ export default config;
@@ -0,0 +1,64 @@
1
+ import path from 'path';
2
+ import * as dotenv from 'dotenv';
3
+ import webpack from 'webpack';
4
+ import TerserPlugin from 'terser-webpack-plugin';
5
+ import { CleanWebpackPlugin } from 'clean-webpack-plugin';
6
+ import ESLintPlugin from 'eslint-webpack-plugin';
7
+ import nodeExternals from 'webpack-node-externals';
8
+
9
+ const dotEnvToParse = dotenv.config();
10
+
11
+ const ROOT_DIR = path.resolve(__dirname);
12
+ const resolvePath = (...args) => path.resolve(ROOT_DIR, ...args);
13
+ const BUILD_DIR = resolvePath('build');
14
+
15
+ const config = {
16
+ entry: './src/index.ts',
17
+ target: 'node',
18
+ externals: [nodeExternals()],
19
+ output: {
20
+ path: BUILD_DIR,
21
+ filename: 'index.js',
22
+ },
23
+ resolve: {
24
+ extensions: ['.js', '.ts', '.json', '.gql'],
25
+ alias: {
26
+ '@controllers': path.resolve(__dirname, 'controllers/'),
27
+ '@models': path.resolve(__dirname, 'models/'),
28
+ '@controllerGraphQL': path.resolve(__dirname, 'controllers/controllerGraphQL/'),
29
+ '@GraphQL': path.resolve(__dirname, 'GraphQL/'),
30
+ '@config': path.resolve(__dirname, 'config/'),
31
+ }
32
+ },
33
+ mode: 'production',
34
+ module: {
35
+ rules: [
36
+ {
37
+ test: /\.(js|ts|mjs|gql)$/,
38
+ exclude: /node_modules/,
39
+ use: {
40
+ loader: 'babel-loader',
41
+ },
42
+ },
43
+ {
44
+ test: /\.(ts)$/, loader: "ts-loader",
45
+ exclude: /node_modules/
46
+ },
47
+ ],
48
+ },
49
+ plugins: [
50
+ new CleanWebpackPlugin(),
51
+ new ESLintPlugin(),
52
+ new webpack.DefinePlugin({
53
+ 'process.env': JSON.stringify(dotEnvToParse.parsed),
54
+ }),
55
+ ],
56
+ optimization: {
57
+ minimize: true,
58
+ minimizer: [
59
+ new TerserPlugin(),
60
+ ],
61
+ },
62
+ };
63
+
64
+ export default config;