@aleleba/create-node-ts-graphql-server 1.1.5 → 1.2.0

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/.env.example CHANGED
@@ -1,5 +1,5 @@
1
1
  #ENVIRONMENT Defauld production
2
- ENVIRONMENT=
2
+ ENV=
3
3
  #WHITELIST URLS Default to http://localhost
4
4
  WHITELIST_URLS=
5
5
  #GRAPHIQL Default to "false"
package/README.md CHANGED
@@ -4,9 +4,9 @@ This project aims to have a starter kit for creating a new Node with typescript,
4
4
 
5
5
  Tech(Library or Framework) | Version |
6
6
  --- | --- |
7
- Jest (Testing) | 28.1.3
8
- Typescript | 4.7.4
9
- GraphQL | 16.5.0
7
+ Jest (Testing) | 29.0.1
8
+ Typescript | 4.8.2
9
+ GraphQL | 16.6.0
10
10
 
11
11
  ## Setup
12
12
  To create a new project run in the terminal:
package/config/index.ts CHANGED
@@ -2,12 +2,18 @@ import * as dotenv from 'dotenv';
2
2
 
3
3
  dotenv.config();
4
4
 
5
+ export const deFaultValues = {
6
+ ENV: 'production',
7
+ GRAPHIQL: 'false',
8
+ PLAYGROUND_GRAPHQL: 'false',
9
+ WHITELIST_URLS: 'http://localhost',
10
+ PORT: 4000,
11
+ };
12
+
5
13
  export const config = {
6
- env: process.env.ENVIRONMENT ? process.env.ENVIRONMENT : 'production',
7
- graphiQL: process.env.GRAPHIQL === 'true' ? true : false,
8
- playgroundGraphQL: process.env.PLAYGROUND_GRAPHQL === 'true' ? true : false,
9
- whiteList: process.env.WHITELIST_URLS ? process.env.WHITELIST_URLS.split(',') : [
10
- 'http://localhost'
11
- ],
12
- port: process.env.PORT || 4000,
13
- };
14
+ ENV: process.env.ENV,
15
+ GRAPHIQL: process.env.GRAPHIQL === 'true' ? true : false,
16
+ PLAYGROUND_GRAPHQL: process.env.PLAYGROUND_GRAPHQL === 'true' ? true : false,
17
+ WHITELIST_URLS: process.env.WHITELIST_URLS ? process.env.WHITELIST_URLS.split(',') : deFaultValues.WHITELIST_URLS,
18
+ PORT: process.env.PORT,
19
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aleleba/create-node-ts-graphql-server",
3
- "version": "1.1.5",
3
+ "version": "1.2.0",
4
4
  "description": "Node with Typescript and GraphQL Server",
5
5
  "bin": "./bin/cli.js",
6
6
  "main": "index.js",
@@ -32,43 +32,43 @@
32
32
  },
33
33
  "homepage": "https://github.com/aleleba/node-ts-graphql-server#readme",
34
34
  "dependencies": {
35
- "@graphql-tools/schema": "^9.0.0",
35
+ "@graphql-tools/schema": "^9.0.2",
36
36
  "body-parser": "^1.20.0",
37
37
  "cookie-parser": "^1.4.6",
38
38
  "cors": "^2.8.5",
39
39
  "dotenv": "^16.0.1",
40
40
  "express": "^4.18.1",
41
41
  "express-graphql": "^0.12.0",
42
- "graphql": "^16.5.0",
42
+ "graphql": "^16.6.0",
43
43
  "graphql-playground-middleware-express": "^1.7.23",
44
44
  "graphql-subscriptions": "^2.0.0",
45
- "graphql-tools": "^8.3.2",
46
- "graphql-ws": "^5.10.0",
45
+ "graphql-tools": "^8.3.4",
46
+ "graphql-ws": "^5.10.1",
47
47
  "web-push": "^3.5.0",
48
48
  "ws": "^8.8.1"
49
49
  },
50
50
  "devDependencies": {
51
- "@babel/core": "^7.18.10",
51
+ "@babel/core": "^7.18.13",
52
52
  "@babel/preset-env": "^7.18.10",
53
53
  "@babel/preset-typescript": "^7.18.6",
54
54
  "@babel/register": "^7.18.9",
55
- "@types/jest": "^28.1.6",
56
- "@types/node": "^18.6.5",
55
+ "@types/jest": "^29.0.0",
56
+ "@types/node": "^18.7.14",
57
57
  "@types/webpack": "^5.28.0",
58
58
  "@types/webpack-node-externals": "^2.5.3",
59
- "@typescript-eslint/eslint-plugin": "^5.33.0",
60
- "@typescript-eslint/parser": "^5.33.0",
59
+ "@typescript-eslint/eslint-plugin": "^5.36.1",
60
+ "@typescript-eslint/parser": "^5.36.1",
61
61
  "babel-loader": "^8.2.5",
62
62
  "clean-webpack-plugin": "^4.0.0",
63
63
  "compression-webpack-plugin": "^10.0.0",
64
- "eslint": "^8.21.0",
64
+ "eslint": "^8.23.0",
65
65
  "eslint-webpack-plugin": "^3.2.0",
66
- "jest": "^28.1.3",
66
+ "jest": "^29.0.1",
67
67
  "nodemon": "^2.0.19",
68
68
  "supertest": "^6.2.4",
69
- "ts-jest": "^28.0.7",
69
+ "ts-jest": "^28.0.8",
70
70
  "ts-loader": "^9.3.1",
71
- "typescript": "^4.7.4",
71
+ "typescript": "^4.8.2",
72
72
  "webpack": "^5.74.0",
73
73
  "webpack-cli": "^4.10.0",
74
74
  "webpack-manifest-plugin": "^5.0.0",
@@ -11,7 +11,7 @@ server.use(
11
11
  graphqlHTTP( (req, res) => {
12
12
  return {
13
13
  schema,
14
- graphiql: config.graphiQL,
14
+ graphiql: config.GRAPHIQL,
15
15
  context: { req, res }
16
16
  };
17
17
  }),
package/src/index.ts CHANGED
@@ -13,7 +13,7 @@ import { config } from '../config';
13
13
  import apiRouter from './routes';
14
14
 
15
15
  const app = express(), //creating app
16
- whitelist = config.whiteList,
16
+ whitelist = config.WHITELIST_URLS,
17
17
  corsOptions = {
18
18
  origin: function (origin, callback) {
19
19
  if (whitelist.indexOf(origin) !== -1 || !origin) {
@@ -34,14 +34,14 @@ app
34
34
  .use(apiRouter)//Routes de App
35
35
  .use('/graphql', GraphQLserver);//Server of Graphql
36
36
 
37
- if(config.playgroundGraphQL === true){
37
+ if(config.PLAYGROUND_GRAPHQL === true){
38
38
  app.get('/playground', expressPlayground({ endpoint: '/graphql' }));
39
39
  }
40
40
 
41
41
  // DO NOT DO app.listen() unless we're testing this directly
42
42
  if (require.main === module) {
43
43
 
44
- const server = app.listen(config.port, () => {
44
+ const server = app.listen(config.PORT, () => {
45
45
  // create and use the websocket server
46
46
  const wsServer = new ws.Server({
47
47
  server,
@@ -74,7 +74,7 @@ if (require.main === module) {
74
74
  },
75
75
  }, wsServer);
76
76
 
77
- console.log(`Starting Express on port ${config.port} and iniciating server of web sockets`);
77
+ console.log(`Starting Express on port ${config.PORT} and iniciating server of web sockets`);
78
78
 
79
79
  });
80
80
 
@@ -1,12 +1,10 @@
1
1
  import path from 'path';
2
- import * as dotenv from 'dotenv';
3
2
  import webpack from 'webpack';
4
3
  import { CleanWebpackPlugin } from 'clean-webpack-plugin';
5
4
  import ESLintPlugin from 'eslint-webpack-plugin';
6
5
  import nodeExternals from 'webpack-node-externals';
7
6
  import WebpackShellPluginNext from 'webpack-shell-plugin-next';
8
-
9
- const dotEnvToParse = dotenv.config();
7
+ import { deFaultValues } from './config';
10
8
 
11
9
  const ROOT_DIR = path.resolve(__dirname);
12
10
  const resolvePath = (...args) => path.resolve(ROOT_DIR, ...args);
@@ -50,12 +48,12 @@ const config = {
50
48
  plugins: [
51
49
  new CleanWebpackPlugin(),
52
50
  new ESLintPlugin(),
53
- new webpack.DefinePlugin({
54
- 'process.env': JSON.stringify(dotEnvToParse.parsed),
51
+ new webpack.EnvironmentPlugin({
52
+ ...deFaultValues
55
53
  }),
56
54
  new WebpackShellPluginNext({
57
55
  onBuildEnd: {
58
- scripts: ['npm run start:nodemon'],
56
+ scripts: ['nodemon build/index.js'],
59
57
  blocking: false,
60
58
  parallel: true
61
59
  }
package/webpack.config.ts CHANGED
@@ -1,12 +1,10 @@
1
1
  import path from 'path';
2
- import * as dotenv from 'dotenv';
3
2
  import webpack from 'webpack';
4
3
  import TerserPlugin from 'terser-webpack-plugin';
5
4
  import { CleanWebpackPlugin } from 'clean-webpack-plugin';
6
5
  import ESLintPlugin from 'eslint-webpack-plugin';
7
6
  import nodeExternals from 'webpack-node-externals';
8
-
9
- const dotEnvToParse = dotenv.config();
7
+ import { deFaultValues } from './config';
10
8
 
11
9
  const ROOT_DIR = path.resolve(__dirname);
12
10
  const resolvePath = (...args) => path.resolve(ROOT_DIR, ...args);
@@ -49,8 +47,8 @@ const config = {
49
47
  plugins: [
50
48
  new CleanWebpackPlugin(),
51
49
  new ESLintPlugin(),
52
- new webpack.DefinePlugin({
53
- 'process.env': JSON.stringify(dotEnvToParse.parsed),
50
+ new webpack.EnvironmentPlugin({
51
+ ...deFaultValues
54
52
  }),
55
53
  ],
56
54
  optimization: {