@aleleba/create-node-ts-graphql-server 1.1.7 → 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 +1 -1
- package/README.md +2 -2
- package/config/index.ts +14 -8
- package/package.json +10 -10
- package/src/GraphQL/server.ts +1 -1
- package/src/index.ts +4 -4
- package/webpack.config.dev.ts +4 -6
- package/webpack.config.ts +3 -5
package/.env.example
CHANGED
package/README.md
CHANGED
|
@@ -4,8 +4,8 @@ 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) |
|
|
8
|
-
Typescript | 4.
|
|
7
|
+
Jest (Testing) | 29.0.1
|
|
8
|
+
Typescript | 4.8.2
|
|
9
9
|
GraphQL | 16.6.0
|
|
10
10
|
|
|
11
11
|
## Setup
|
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
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
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.
|
|
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,7 +32,7 @@
|
|
|
32
32
|
},
|
|
33
33
|
"homepage": "https://github.com/aleleba/node-ts-graphql-server#readme",
|
|
34
34
|
"dependencies": {
|
|
35
|
-
"@graphql-tools/schema": "^9.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",
|
|
@@ -42,7 +42,7 @@
|
|
|
42
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.
|
|
45
|
+
"graphql-tools": "^8.3.4",
|
|
46
46
|
"graphql-ws": "^5.10.1",
|
|
47
47
|
"web-push": "^3.5.0",
|
|
48
48
|
"ws": "^8.8.1"
|
|
@@ -52,23 +52,23 @@
|
|
|
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": "^
|
|
56
|
-
"@types/node": "^18.7.
|
|
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.
|
|
60
|
-
"@typescript-eslint/parser": "^5.
|
|
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.
|
|
64
|
+
"eslint": "^8.23.0",
|
|
65
65
|
"eslint-webpack-plugin": "^3.2.0",
|
|
66
|
-
"jest": "^
|
|
66
|
+
"jest": "^29.0.1",
|
|
67
67
|
"nodemon": "^2.0.19",
|
|
68
68
|
"supertest": "^6.2.4",
|
|
69
69
|
"ts-jest": "^28.0.8",
|
|
70
70
|
"ts-loader": "^9.3.1",
|
|
71
|
-
"typescript": "^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",
|
package/src/GraphQL/server.ts
CHANGED
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.
|
|
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.
|
|
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.
|
|
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.
|
|
77
|
+
console.log(`Starting Express on port ${config.PORT} and iniciating server of web sockets`);
|
|
78
78
|
|
|
79
79
|
});
|
|
80
80
|
|
package/webpack.config.dev.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 { 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.
|
|
54
|
-
|
|
51
|
+
new webpack.EnvironmentPlugin({
|
|
52
|
+
...deFaultValues
|
|
55
53
|
}),
|
|
56
54
|
new WebpackShellPluginNext({
|
|
57
55
|
onBuildEnd: {
|
|
58
|
-
scripts: ['
|
|
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.
|
|
53
|
-
|
|
50
|
+
new webpack.EnvironmentPlugin({
|
|
51
|
+
...deFaultValues
|
|
54
52
|
}),
|
|
55
53
|
],
|
|
56
54
|
optimization: {
|