mirror of
https://github.com/aleleba/create-node-ts-graphql-server.git
synced 2025-01-09 05:26:50 -06:00
PR-934611: making some changes to webpack and updating packages.
This commit is contained in:
parent
5262aac33c
commit
af983a8032
@ -1,5 +1,5 @@
|
||||
#ENVIRONMENT Defauld production
|
||||
ENVIRONMENT=
|
||||
ENV=
|
||||
#WHITELIST URLS Default to http://localhost
|
||||
WHITELIST_URLS=
|
||||
#GRAPHIQL Default to "false"
|
||||
|
@ -4,8 +4,8 @@ This project aims to have a starter kit for creating a new Node with typescript,
|
||||
|
||||
Tech(Library or Framework) | Version |
|
||||
--- | --- |
|
||||
Jest (Testing) | 28.1.3
|
||||
Typescript | 4.7.4
|
||||
Jest (Testing) | 29.0.1
|
||||
Typescript | 4.8.2
|
||||
GraphQL | 16.6.0
|
||||
|
||||
## Setup
|
||||
|
@ -3,11 +3,17 @@ import * as dotenv from 'dotenv';
|
||||
dotenv.config();
|
||||
|
||||
export const config = {
|
||||
env: process.env.ENVIRONMENT ? process.env.ENVIRONMENT : 'production',
|
||||
graphiQL: process.env.GRAPHIQL === 'true' ? true : false,
|
||||
playgroundGraphQL: process.env.PLAYGROUND_GRAPHQL === 'true' ? true : false,
|
||||
whiteList: process.env.WHITELIST_URLS ? process.env.WHITELIST_URLS.split(',') : [
|
||||
'http://localhost'
|
||||
],
|
||||
port: process.env.PORT || 4000,
|
||||
};
|
||||
ENV: process.env.ENV,
|
||||
GRAPHIQL: process.env.GRAPHIQL === 'true' ? true : false,
|
||||
PLAYGROUND_GRAPHQL: process.env.PLAYGROUND_GRAPHQL === 'true' ? true : false,
|
||||
WHITELIST_URLS: process.env.WHITELIST_URLS && process.env.WHITELIST_URLS.split(','),
|
||||
PORT: process.env.PORT,
|
||||
};
|
||||
|
||||
export const deFaultValues = {
|
||||
ENV: 'production',
|
||||
GRAPHIQL: 'false',
|
||||
PLAYGROUND_GRAPHQL: 'false',
|
||||
WHITELIST_URLS: 'http://localhost',
|
||||
PORT: 4000,
|
||||
}
|
4918
package-lock.json
generated
4918
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
20
package.json
20
package.json
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@aleleba/create-node-ts-graphql-server",
|
||||
"version": "1.1.7",
|
||||
"version": "1.2.0",
|
||||
"description": "Node with Typescript and GraphQL Server",
|
||||
"bin": "./bin/cli.js",
|
||||
"main": "index.js",
|
||||
@ -32,7 +32,7 @@
|
||||
},
|
||||
"homepage": "https://github.com/aleleba/node-ts-graphql-server#readme",
|
||||
"dependencies": {
|
||||
"@graphql-tools/schema": "^9.0.1",
|
||||
"@graphql-tools/schema": "^9.0.2",
|
||||
"body-parser": "^1.20.0",
|
||||
"cookie-parser": "^1.4.6",
|
||||
"cors": "^2.8.5",
|
||||
@ -42,7 +42,7 @@
|
||||
"graphql": "^16.6.0",
|
||||
"graphql-playground-middleware-express": "^1.7.23",
|
||||
"graphql-subscriptions": "^2.0.0",
|
||||
"graphql-tools": "^8.3.3",
|
||||
"graphql-tools": "^8.3.4",
|
||||
"graphql-ws": "^5.10.1",
|
||||
"web-push": "^3.5.0",
|
||||
"ws": "^8.8.1"
|
||||
@ -52,23 +52,23 @@
|
||||
"@babel/preset-env": "^7.18.10",
|
||||
"@babel/preset-typescript": "^7.18.6",
|
||||
"@babel/register": "^7.18.9",
|
||||
"@types/jest": "^28.1.7",
|
||||
"@types/node": "^18.7.11",
|
||||
"@types/jest": "^29.0.0",
|
||||
"@types/node": "^18.7.14",
|
||||
"@types/webpack": "^5.28.0",
|
||||
"@types/webpack-node-externals": "^2.5.3",
|
||||
"@typescript-eslint/eslint-plugin": "^5.34.0",
|
||||
"@typescript-eslint/parser": "^5.34.0",
|
||||
"@typescript-eslint/eslint-plugin": "^5.36.1",
|
||||
"@typescript-eslint/parser": "^5.36.1",
|
||||
"babel-loader": "^8.2.5",
|
||||
"clean-webpack-plugin": "^4.0.0",
|
||||
"compression-webpack-plugin": "^10.0.0",
|
||||
"eslint": "^8.22.0",
|
||||
"eslint": "^8.23.0",
|
||||
"eslint-webpack-plugin": "^3.2.0",
|
||||
"jest": "^28.1.3",
|
||||
"jest": "^29.0.1",
|
||||
"nodemon": "^2.0.19",
|
||||
"supertest": "^6.2.4",
|
||||
"ts-jest": "^28.0.8",
|
||||
"ts-loader": "^9.3.1",
|
||||
"typescript": "^4.7.4",
|
||||
"typescript": "^4.8.2",
|
||||
"webpack": "^5.74.0",
|
||||
"webpack-cli": "^4.10.0",
|
||||
"webpack-manifest-plugin": "^5.0.0",
|
||||
|
@ -11,7 +11,7 @@ server.use(
|
||||
graphqlHTTP( (req, res) => {
|
||||
return {
|
||||
schema,
|
||||
graphiql: config.graphiQL,
|
||||
graphiql: config.GRAPHIQL,
|
||||
context: { req, res }
|
||||
};
|
||||
}),
|
||||
|
@ -13,7 +13,7 @@ import { config } from '../config';
|
||||
import apiRouter from './routes';
|
||||
|
||||
const app = express(), //creating app
|
||||
whitelist = config.whiteList,
|
||||
whitelist = config.WHITELIST_URLS,
|
||||
corsOptions = {
|
||||
origin: function (origin, callback) {
|
||||
if (whitelist.indexOf(origin) !== -1 || !origin) {
|
||||
@ -34,14 +34,14 @@ app
|
||||
.use(apiRouter)//Routes de App
|
||||
.use('/graphql', GraphQLserver);//Server of Graphql
|
||||
|
||||
if(config.playgroundGraphQL === true){
|
||||
if(config.PLAYGROUND_GRAPHQL === true){
|
||||
app.get('/playground', expressPlayground({ endpoint: '/graphql' }));
|
||||
}
|
||||
|
||||
// DO NOT DO app.listen() unless we're testing this directly
|
||||
if (require.main === module) {
|
||||
|
||||
const server = app.listen(config.port, () => {
|
||||
const server = app.listen(config.PORT, () => {
|
||||
// create and use the websocket server
|
||||
const wsServer = new ws.Server({
|
||||
server,
|
||||
@ -74,7 +74,7 @@ if (require.main === module) {
|
||||
},
|
||||
}, wsServer);
|
||||
|
||||
console.log(`Starting Express on port ${config.port} and iniciating server of web sockets`);
|
||||
console.log(`Starting Express on port ${config.PORT} and iniciating server of web sockets`);
|
||||
|
||||
});
|
||||
|
||||
|
@ -1,12 +1,10 @@
|
||||
import path from 'path';
|
||||
import * as dotenv from 'dotenv';
|
||||
import webpack from 'webpack';
|
||||
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';
|
||||
|
||||
const dotEnvToParse = dotenv.config();
|
||||
import { deFaultValues } from './config';
|
||||
|
||||
const ROOT_DIR = path.resolve(__dirname);
|
||||
const resolvePath = (...args) => path.resolve(ROOT_DIR, ...args);
|
||||
@ -50,12 +48,12 @@ const config = {
|
||||
plugins: [
|
||||
new CleanWebpackPlugin(),
|
||||
new ESLintPlugin(),
|
||||
new webpack.DefinePlugin({
|
||||
'process.env': JSON.stringify(dotEnvToParse.parsed),
|
||||
new webpack.EnvironmentPlugin({
|
||||
...deFaultValues
|
||||
}),
|
||||
new WebpackShellPluginNext({
|
||||
onBuildEnd: {
|
||||
scripts: ['npm run start:nodemon'],
|
||||
scripts: ['nodemon build/index.js'],
|
||||
blocking: false,
|
||||
parallel: true
|
||||
}
|
||||
|
@ -1,12 +1,10 @@
|
||||
import path from 'path';
|
||||
import * as dotenv from 'dotenv';
|
||||
import webpack from 'webpack';
|
||||
import TerserPlugin from 'terser-webpack-plugin';
|
||||
import { CleanWebpackPlugin } from 'clean-webpack-plugin';
|
||||
import ESLintPlugin from 'eslint-webpack-plugin';
|
||||
import nodeExternals from 'webpack-node-externals';
|
||||
|
||||
const dotEnvToParse = dotenv.config();
|
||||
import { deFaultValues } from './config';
|
||||
|
||||
const ROOT_DIR = path.resolve(__dirname);
|
||||
const resolvePath = (...args) => path.resolve(ROOT_DIR, ...args);
|
||||
@ -49,8 +47,8 @@ const config = {
|
||||
plugins: [
|
||||
new CleanWebpackPlugin(),
|
||||
new ESLintPlugin(),
|
||||
new webpack.DefinePlugin({
|
||||
'process.env': JSON.stringify(dotEnvToParse.parsed),
|
||||
new webpack.EnvironmentPlugin({
|
||||
...deFaultValues
|
||||
}),
|
||||
],
|
||||
optimization: {
|
||||
|
Loading…
Reference in New Issue
Block a user