@aleleba/create-node-ts-graphql-server 1.4.2 → 1.5.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
@@ -2,8 +2,6 @@
2
2
  ENV=
3
3
  #WHITELIST URLS Default to http://localhost
4
4
  WHITELIST_URLS=
5
- #GRAPHIQL Default to "false"
6
- GRAPHIQL=
7
5
  #PLAYGROUND GRAPHQL Default to "false"
8
6
  PLAYGROUND_GRAPHQL=
9
7
  # PORT EXPOSE APP Default to 4000
package/README.md CHANGED
@@ -5,7 +5,7 @@ This project aims to have a starter kit for creating a new Node with typescript,
5
5
  Tech(Library or Framework) | Version |
6
6
  --- | --- |
7
7
  Jest (Testing) | 29.5.0
8
- Typescript | 4.9.5
8
+ Typescript | 5.0.2
9
9
  GraphQL | 16.6.0
10
10
  Type GraphQL | 2.0.0-beta.1
11
11
 
@@ -25,8 +25,6 @@ This is an example of config.
25
25
  ENVIRONMENT=development
26
26
  #WHITELIST URLS Default to http://localhost
27
27
  WHITELIST_URLS=https://someurl.com
28
- #GRAPHIQL Default to "false"
29
- GRAPHIQL=true
30
28
  #PLAYGROUND GRAPHQL Default to "false"
31
29
  PLAYGROUND_GRAPHQL=true
32
30
  # PORT EXPOSE APP Default to 4000
package/bin/cli.js CHANGED
@@ -67,7 +67,7 @@ if(!checkedOut) process.exit(-1);
67
67
 
68
68
  const actualVersion = runCommandWithOutput(`cd ${repoName} && node -p "require('./package.json').version"`).toString().trim()
69
69
 
70
- const installDepsCommand = `cd ${repoName} && npm install --legacy-peer-deps`;
70
+ const installDepsCommand = `cd ${repoName} && npm install`;
71
71
  const cleanGitHistoryCommand = `cd ${repoName} && rm -rf .git && git init && git add --all -- ":!.github" ":!bin" && git commit -m "Initial commit"`
72
72
  const cleanGitHistoryCommandWindows = `cd ${repoName} && rmdir .git /s /q && git init && git add --all -- ":!.github" ":!bin" && git commit -m "Initial commit"`
73
73
  const deleteFoldersCommand = `cd ${repoName} && rm -rf .github && rm -rf bin`
@@ -102,7 +102,7 @@ if(!cleanGitHistory) process.exit(-1);
102
102
 
103
103
  console.log("Congratulations! You are ready. Follow the following commands to start");
104
104
  console.log(`cd ${repoName}`);
105
- 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)');
105
+ console.log('Create a .env file with ENV=development(defauld: production), PORT=4000 (default: 4000), WHITELIST_URLS=your_url(default: http://localhost)');
106
106
  console.log(`Then you can run: npm start:dev`);
107
107
 
108
108
  const deleteFolders = isWin ? runCommand(deleteFoldersCommandWindows) : runCommand(deleteFoldersCommand);
package/config/index.ts CHANGED
@@ -4,7 +4,6 @@ dotenv.config();
4
4
 
5
5
  export const deFaultValues = {
6
6
  ENV: 'production',
7
- GRAPHIQL: 'false',
8
7
  PLAYGROUND_GRAPHQL: 'false',
9
8
  WHITELIST_URLS: 'http://localhost',
10
9
  PORT: 4000,
@@ -12,7 +11,6 @@ export const deFaultValues = {
12
11
 
13
12
  export const config = {
14
13
  ENV: process.env.ENV,
15
- GRAPHIQL: process.env.GRAPHIQL === 'true' ? true : false,
16
14
  PLAYGROUND_GRAPHQL: process.env.PLAYGROUND_GRAPHQL === 'true' ? true : false,
17
15
  WHITELIST_URLS: process.env.WHITELIST_URLS ? process.env.WHITELIST_URLS.split(',') : deFaultValues.WHITELIST_URLS,
18
16
  PORT: process.env.PORT,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aleleba/create-node-ts-graphql-server",
3
- "version": "1.4.2",
3
+ "version": "1.5.0",
4
4
  "description": "Node with Typescript and GraphQL Server",
5
5
  "bin": "./bin/cli.js",
6
6
  "main": "index.js",
@@ -13,7 +13,7 @@
13
13
  "lint:fix": "eslint ./ --ext .js --ext .ts --fix",
14
14
  "test": "jest",
15
15
  "test:watch": "jest --watch",
16
- "check-updates": "npx npm-check-updates -u && npm i --legacy-peer-deps"
16
+ "check-updates": "npx npm-check-updates -u && npm i"
17
17
  },
18
18
  "repository": {
19
19
  "type": "git",
@@ -36,12 +36,13 @@
36
36
  "@graphql-tools/schema": "^9.0.17",
37
37
  "body-parser": "^1.20.2",
38
38
  "class-validator": "^0.14.0",
39
+ "cookie-parse": "^0.4.0",
39
40
  "cookie-parser": "^1.4.6",
40
41
  "cors": "^2.8.5",
41
42
  "dotenv": "^16.0.3",
42
43
  "express": "^4.18.2",
43
- "express-graphql": "^0.12.0",
44
44
  "graphql": "^16.6.0",
45
+ "graphql-http": "^1.17.0",
45
46
  "graphql-playground-middleware-express": "^1.7.23",
46
47
  "graphql-subscriptions": "^2.0.0",
47
48
  "graphql-tools": "^8.3.19",
@@ -52,7 +53,7 @@
52
53
  "ws": "^8.13.0"
53
54
  },
54
55
  "devDependencies": {
55
- "@babel/core": "^7.21.0",
56
+ "@babel/core": "^7.21.3",
56
57
  "@babel/preset-env": "^7.20.2",
57
58
  "@babel/preset-typescript": "^7.21.0",
58
59
  "@babel/register": "^7.21.0",
@@ -60,27 +61,27 @@
60
61
  "@types/cookie-parser": "^1.4.3",
61
62
  "@types/cors": "^2.8.13",
62
63
  "@types/express": "^4.17.17",
63
- "@types/jest": "^29.4.1",
64
- "@types/node": "^18.15.3",
64
+ "@types/jest": "^29.5.0",
65
+ "@types/node": "^18.15.10",
65
66
  "@types/supertest": "^2.0.12",
66
- "@types/webpack": "^5.28.0",
67
+ "@types/webpack": "^5.28.1",
67
68
  "@types/webpack-node-externals": "^3.0.0",
68
69
  "@types/ws": "^8.5.4",
69
- "@typescript-eslint/eslint-plugin": "^5.55.0",
70
- "@typescript-eslint/parser": "^5.55.0",
70
+ "@typescript-eslint/eslint-plugin": "^5.57.0",
71
+ "@typescript-eslint/parser": "^5.57.0",
71
72
  "babel-loader": "^9.1.2",
72
73
  "clean-webpack-plugin": "^4.0.0",
73
74
  "compression-webpack-plugin": "^10.0.0",
74
75
  "eslint": "^8.36.0",
75
76
  "eslint-webpack-plugin": "^4.0.0",
76
77
  "jest": "^29.5.0",
77
- "nodemon": "^2.0.21",
78
+ "nodemon": "^2.0.22",
78
79
  "resolve-ts-aliases": "^1.0.1",
79
80
  "supertest": "^6.3.3",
80
81
  "ts-jest": "^29.0.5",
81
82
  "ts-loader": "^9.4.2",
82
- "typescript": "^4.9.5",
83
- "webpack": "^5.76.1",
83
+ "typescript": "^5.0.2",
84
+ "webpack": "^5.76.3",
84
85
  "webpack-cli": "^5.0.1",
85
86
  "webpack-manifest-plugin": "^5.0.0",
86
87
  "webpack-node-externals": "^3.0.0",
@@ -2,4 +2,9 @@
2
2
  declare module "*.gql" {
3
3
  const content: any;
4
4
  export default content;
5
+ }
6
+
7
+ declare module 'cookie-parse' {
8
+ const content: any;
9
+ export default content;
5
10
  }
@@ -1,8 +1,7 @@
1
1
  'use strict';
2
2
 
3
3
  import express from 'express'; //express
4
- import { graphqlHTTP } from 'express-graphql';
5
- import { config } from '@config';
4
+ import { createHandler } from 'graphql-http/lib/use/express';
6
5
  import schema from '@src/GraphQL/schema';
7
6
 
8
7
 
@@ -10,13 +9,13 @@ const server = express.Router();//Router de Express
10
9
 
11
10
  server.use(
12
11
  '/',
13
- graphqlHTTP( (req, res) => {
14
- return {
15
- schema,
16
- graphiql: config.GRAPHIQL,
17
- context: { req, res }
18
- };
19
- }),
12
+ createHandler({
13
+ schema,
14
+ context(req) {
15
+ const res = req.context.res
16
+ return {req, res};
17
+ },
18
+ })
20
19
  );
21
20
 
22
21
  // DO NOT DO app.listen() unless we're testing this directly