Merge pull request from aleleba/PR-393405

PR-393405
This commit is contained in:
Alejandro Lembke Barrientos 2025-04-21 12:51:59 -06:00 committed by GitHub
commit 5c11a46b3b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
15 changed files with 2318 additions and 2708 deletions

View File

@ -1,6 +1,6 @@
{
"presets": [
"@babel/preset-env",
["@babel/preset-env", {"targets": {"node": "current"}}],
"@babel/preset-typescript"
]
}

View File

@ -1,7 +0,0 @@
#Eslint
.eslintrc.js
#Build
build
#Webpack
webpack.config.ts
webpack.config.dev.ts

View File

@ -1,37 +0,0 @@
module.exports = {
'env': {
'browser': true,
'es2021': true,
'node': true,
},
'extends': [
'eslint:recommended',
'plugin:@typescript-eslint/recommended'
],
'parser': '@typescript-eslint/parser',
'parserOptions': {
'ecmaVersion': 'latest',
'sourceType': 'module'
},
'plugins': [
'@typescript-eslint'
],
'rules': {
'indent': [
'error',
'tab'
],
'linebreak-style': [
'error',
'unix'
],
'quotes': [
'error',
'single'
],
'semi': [
'error',
'always'
]
}
};

View File

@ -26,7 +26,7 @@ jobs:
node-version: 16
cache: 'npm'
registry-url: https://registry.npmjs.org/
- run: npm ci
- run: npm ci --legacy-peer-deps
- run: npm test
# Job to build the package
@ -40,7 +40,7 @@ jobs:
with:
node-version: 16
registry-url: https://registry.npmjs.org/
- run: npm ci
- run: npm ci --legacy-peer-deps
- run: npm run build
# Job to publish the package to npm
@ -54,7 +54,7 @@ jobs:
with:
node-version: 16
registry-url: https://registry.npmjs.org/
- run: npm ci
- run: npm ci --legacy-peer-deps
- run: npm publish --access=public
env:
NPM_PERSONAL_TOKEN: ${{secrets.npm_token}}

View File

@ -67,7 +67,7 @@ if(!checkedOut) process.exit(-1);
const actualVersion = runCommandWithOutput(`cd ${repoName} && node -p "require('./package.json').version"`).toString().trim()
const installDepsCommand = `cd ${repoName} && npm i`;
const installDepsCommand = `cd ${repoName} && npm i --legacy-peer-deps`;
const cleanGitHistoryCommand = `cd ${repoName} && rm -rf .git && git init && git add --all -- ":!.github" ":!bin" && git commit -m "Initial commit"`
const cleanGitHistoryCommandWindows = `cd ${repoName} && rmdir .git /s /q && git init && git add --all -- ":!.github" ":!bin" && git commit -m "Initial commit"`
const deleteFoldersCommand = `cd ${repoName} && rm -rf .github && rm -rf bin`

55
eslint.config.js Normal file
View File

@ -0,0 +1,55 @@
import globals from 'globals';
import tseslint from 'typescript-eslint';
import js from '@eslint/js';
export default [
// Ignorar archivos y carpetas especificados en el antiguo .eslintignore
{
ignores: [
'.eslintrc.js', // Aunque se eliminará, es bueno mantenerlo por si acaso
'build/',
'webpack.config.ts',
'webpack.config.dev.ts',
],
},
// Configuración recomendada por ESLint
js.configs.recommended,
// Configuraciones recomendadas por typescript-eslint
...tseslint.configs.recommended,
// Configuración personalizada
{
languageOptions: {
ecmaVersion: 2021,
sourceType: 'module',
globals: {
...globals.browser,
...globals.node,
},
// El parser ya está configurado por tseslint.configs.recommended
},
// Los plugins ya están configurados por tseslint.configs.recommended
rules: {
// Reglas personalizadas del antiguo .eslintrc.js
'indent': [
'error',
'tab'
],
'linebreak-style': [
'error',
'unix'
],
'quotes': [
'error',
'single'
],
'semi': [
'error',
'always'
],
// Puedes añadir o sobrescribir reglas de las configuraciones recomendadas aquí si es necesario
},
}
];

4789
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -1,6 +1,6 @@
{
"name": "@aleleba/create-node-ts-graphql-server",
"version": "1.5.19",
"version": "1.6.0",
"description": "Node with Typescript and GraphQL Server",
"bin": "./bin/cli.js",
"main": "index.js",
@ -13,7 +13,7 @@
"lint:fix": "eslint ./ --ext .js --ext .ts --fix",
"test": "jest",
"test:watch": "jest --watch",
"check-updates": "npx npm-check-updates -u && npm i"
"check-updates": "npx npm-check-updates -u && npm i --legacy-peer-deps"
},
"repository": {
"type": "git",
@ -33,58 +33,58 @@
},
"homepage": "https://github.com/aleleba/node-ts-graphql-server#readme",
"dependencies": {
"@graphql-tools/schema": "^10.0.8",
"body-parser": "^1.20.3",
"@graphql-tools/schema": "^10.0.23",
"body-parser": "^2.2.0",
"class-validator": "^0.14.1",
"cookie-parse": "^0.4.0",
"cookie-parser": "^1.4.7",
"cors": "^2.8.5",
"dotenv": "^16.4.5",
"express": "^4.21.1",
"graphql": "^16.9.0",
"graphql-http": "^1.22.2",
"dotenv": "^16.5.0",
"express": "^5.1.0",
"graphql": "^16.10.0",
"graphql-http": "^1.22.4",
"graphql-playground-middleware-express": "^1.7.23",
"graphql-scalars": "^1.23.0",
"graphql-scalars": "^1.24.2",
"graphql-subscriptions": "^3.0.0",
"graphql-tools": "^9.0.3",
"graphql-ws": "^5.16.0",
"graphql-tools": "^9.0.18",
"graphql-ws": "^6.0.4",
"reflect-metadata": "^0.2.2",
"type-graphql": "^2.0.0-rc.2",
"web-push": "^3.6.7",
"ws": "^8.18.0"
"ws": "^8.18.1"
},
"devDependencies": {
"@babel/core": "^7.26.0",
"@babel/preset-env": "^7.26.0",
"@babel/preset-typescript": "^7.26.0",
"@babel/core": "^7.26.10",
"@babel/preset-env": "^7.26.9",
"@babel/preset-typescript": "^7.27.0",
"@babel/register": "^7.25.9",
"@types/body-parser": "^1.19.5",
"@types/cookie-parser": "^1.4.7",
"@types/cookie-parser": "^1.4.8",
"@types/cors": "^2.8.17",
"@types/express": "^5.0.0",
"@types/express": "^5.0.1",
"@types/jest": "^29.5.14",
"@types/node": "^22.9.0",
"@types/supertest": "^6.0.2",
"@types/node": "^22.14.1",
"@types/supertest": "^6.0.3",
"@types/webpack": "^5.28.5",
"@types/webpack-node-externals": "^3.0.4",
"@types/ws": "^8.5.13",
"@typescript-eslint/eslint-plugin": "^8.14.0",
"@typescript-eslint/parser": "^8.14.0",
"babel-loader": "^9.2.1",
"@types/ws": "^8.18.1",
"@typescript-eslint/eslint-plugin": "^8.30.1",
"@typescript-eslint/parser": "^8.30.1",
"babel-loader": "^10.0.0",
"clean-webpack-plugin": "^4.0.0",
"compression-webpack-plugin": "^11.1.0",
"eslint": "^9.14.0",
"eslint-webpack-plugin": "^4.2.0",
"eslint": "^9.25.0",
"eslint-webpack-plugin": "^5.0.1",
"jest": "^29.7.0",
"nodemon": "^3.1.7",
"nodemon": "^3.1.9",
"resolve-ts-aliases": "^1.0.1",
"supertest": "^7.0.0",
"ts-jest": "^29.2.5",
"ts-loader": "^9.5.1",
"typescript": "^5.6.3",
"webpack": "^5.96.1",
"webpack-cli": "^5.1.4",
"webpack-manifest-plugin": "^5.0.0",
"supertest": "^7.1.0",
"ts-jest": "^29.3.2",
"ts-loader": "^9.5.2",
"typescript": "^5.8.3",
"webpack": "^5.99.6",
"webpack-cli": "^6.0.1",
"webpack-manifest-plugin": "^5.0.1",
"webpack-node-externals": "^3.0.0",
"webpack-shell-plugin-next": "^2.3.2"
}

View File

@ -7,4 +7,8 @@ declare module "*.gql" {
declare module 'cookie-parse' {
const content: any;
export default content;
}
declare module 'graphql-ws/use/ws' {
export * from 'graphql-ws/dist/use/ws';
}

View File

@ -0,0 +1 @@
export * from './test.resolver';

View File

@ -1,19 +1,33 @@
/* eslint-disable no-mixed-spaces-and-tabs */
'use strict';
import { Query, Resolver, Mutation } from 'type-graphql';
import { Test, TestMutation } from '@GraphQL/schema/test.schema';
import { Query, Resolver, Mutation, FieldResolver, Root, Arg } from 'type-graphql';
import { Test, TestMutation } from '@GraphQL/schema';
import { getTest, addText } from '@controllerGraphQL';
@Resolver(() => Test)
export class TestResolver {
export class TestResolverQuery {
@Query(() => Test)
async test() {
return Test;
return {};
}
@Mutation(() => TestMutation)
async testMutation() {
return TestMutation;
}
@FieldResolver(() => String)
async text() {
return await getTest({});
}
}
@Resolver(() => TestMutation)
export class TestResolverMutation {
@Mutation(() => TestMutation)
async testMutation() {
return {};
}
@FieldResolver(() => String)
async text(@Arg('text') text?: string){
return await addText({text});
}
}

View File

@ -1,10 +1,18 @@
'use strict'
import { buildSchemaSync } from "type-graphql"
import { TestResolver } from "@GraphQL/resolvers/test.resolver";
import {
TestResolverQuery,
TestResolverMutation
} from "@GraphQL/resolvers";
export * from './test.schema'
const schema = buildSchemaSync({
resolvers: [TestResolver],
resolvers: [
TestResolverQuery,
TestResolverMutation,
],
emitSchemaFile: true,
})
export default schema

View File

@ -1,21 +1,16 @@
/* eslint-disable no-mixed-spaces-and-tabs */
'use strict';
import { Field, ObjectType, Arg } from 'type-graphql';
import { getTest, addText } from '@controllerGraphQL';
import { Field, ObjectType } from 'type-graphql';
@ObjectType()
export class Test {
@Field(() => String)
async text(){
return await getTest({});
}
text?: string;
}
@ObjectType()
export class TestMutation {
@Field(() => String)
async text(@Arg('text') text?: string){
return await addText({text});
}
text?: string;
}

View File

@ -5,7 +5,7 @@ import ws from 'ws'; // yarn add ws
import express from 'express'; //express
import cors from 'cors';
import cookieParser from 'cookie-parser';
import { useServer } from 'graphql-ws/lib/use/ws';
import { useServer } from 'graphql-ws/use/ws';
import { execute, subscribe } from 'graphql';
import GraphQLserver from '@GraphQL/server';// Server of GraphQL,
import expressPlayground from 'graphql-playground-middleware-express';

View File

@ -2,7 +2,7 @@
"compilerOptions": {
"module": "commonjs",
"esModuleInterop": true,
"target": "es2018",
"target": "es2021",
"moduleResolution": "node",
"sourceMap": true,
"typeRoots" : ["./src/@types", "./node_modules/@types"],