mirror of
https://github.com/aleleba/create-node-ts-graphql-server.git
synced 2025-06-01 19:52:05 -06:00
commit
5c11a46b3b
2
.babelrc
2
.babelrc
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"presets": [
|
"presets": [
|
||||||
"@babel/preset-env",
|
["@babel/preset-env", {"targets": {"node": "current"}}],
|
||||||
"@babel/preset-typescript"
|
"@babel/preset-typescript"
|
||||||
]
|
]
|
||||||
}
|
}
|
@ -1,7 +0,0 @@
|
|||||||
#Eslint
|
|
||||||
.eslintrc.js
|
|
||||||
#Build
|
|
||||||
build
|
|
||||||
#Webpack
|
|
||||||
webpack.config.ts
|
|
||||||
webpack.config.dev.ts
|
|
37
.eslintrc.js
37
.eslintrc.js
@ -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'
|
|
||||||
]
|
|
||||||
}
|
|
||||||
};
|
|
6
.github/workflows/main-workflow.yml
vendored
6
.github/workflows/main-workflow.yml
vendored
@ -26,7 +26,7 @@ jobs:
|
|||||||
node-version: 16
|
node-version: 16
|
||||||
cache: 'npm'
|
cache: 'npm'
|
||||||
registry-url: https://registry.npmjs.org/
|
registry-url: https://registry.npmjs.org/
|
||||||
- run: npm ci
|
- run: npm ci --legacy-peer-deps
|
||||||
- run: npm test
|
- run: npm test
|
||||||
|
|
||||||
# Job to build the package
|
# Job to build the package
|
||||||
@ -40,7 +40,7 @@ jobs:
|
|||||||
with:
|
with:
|
||||||
node-version: 16
|
node-version: 16
|
||||||
registry-url: https://registry.npmjs.org/
|
registry-url: https://registry.npmjs.org/
|
||||||
- run: npm ci
|
- run: npm ci --legacy-peer-deps
|
||||||
- run: npm run build
|
- run: npm run build
|
||||||
|
|
||||||
# Job to publish the package to npm
|
# Job to publish the package to npm
|
||||||
@ -54,7 +54,7 @@ jobs:
|
|||||||
with:
|
with:
|
||||||
node-version: 16
|
node-version: 16
|
||||||
registry-url: https://registry.npmjs.org/
|
registry-url: https://registry.npmjs.org/
|
||||||
- run: npm ci
|
- run: npm ci --legacy-peer-deps
|
||||||
- run: npm publish --access=public
|
- run: npm publish --access=public
|
||||||
env:
|
env:
|
||||||
NPM_PERSONAL_TOKEN: ${{secrets.npm_token}}
|
NPM_PERSONAL_TOKEN: ${{secrets.npm_token}}
|
@ -67,7 +67,7 @@ if(!checkedOut) process.exit(-1);
|
|||||||
|
|
||||||
const actualVersion = runCommandWithOutput(`cd ${repoName} && node -p "require('./package.json').version"`).toString().trim()
|
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 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 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`
|
const deleteFoldersCommand = `cd ${repoName} && rm -rf .github && rm -rf bin`
|
||||||
|
55
eslint.config.js
Normal file
55
eslint.config.js
Normal 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
4789
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
66
package.json
66
package.json
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@aleleba/create-node-ts-graphql-server",
|
"name": "@aleleba/create-node-ts-graphql-server",
|
||||||
"version": "1.5.19",
|
"version": "1.6.0",
|
||||||
"description": "Node with Typescript and GraphQL Server",
|
"description": "Node with Typescript and GraphQL Server",
|
||||||
"bin": "./bin/cli.js",
|
"bin": "./bin/cli.js",
|
||||||
"main": "index.js",
|
"main": "index.js",
|
||||||
@ -13,7 +13,7 @@
|
|||||||
"lint:fix": "eslint ./ --ext .js --ext .ts --fix",
|
"lint:fix": "eslint ./ --ext .js --ext .ts --fix",
|
||||||
"test": "jest",
|
"test": "jest",
|
||||||
"test:watch": "jest --watch",
|
"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": {
|
"repository": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
@ -33,58 +33,58 @@
|
|||||||
},
|
},
|
||||||
"homepage": "https://github.com/aleleba/node-ts-graphql-server#readme",
|
"homepage": "https://github.com/aleleba/node-ts-graphql-server#readme",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@graphql-tools/schema": "^10.0.8",
|
"@graphql-tools/schema": "^10.0.23",
|
||||||
"body-parser": "^1.20.3",
|
"body-parser": "^2.2.0",
|
||||||
"class-validator": "^0.14.1",
|
"class-validator": "^0.14.1",
|
||||||
"cookie-parse": "^0.4.0",
|
"cookie-parse": "^0.4.0",
|
||||||
"cookie-parser": "^1.4.7",
|
"cookie-parser": "^1.4.7",
|
||||||
"cors": "^2.8.5",
|
"cors": "^2.8.5",
|
||||||
"dotenv": "^16.4.5",
|
"dotenv": "^16.5.0",
|
||||||
"express": "^4.21.1",
|
"express": "^5.1.0",
|
||||||
"graphql": "^16.9.0",
|
"graphql": "^16.10.0",
|
||||||
"graphql-http": "^1.22.2",
|
"graphql-http": "^1.22.4",
|
||||||
"graphql-playground-middleware-express": "^1.7.23",
|
"graphql-playground-middleware-express": "^1.7.23",
|
||||||
"graphql-scalars": "^1.23.0",
|
"graphql-scalars": "^1.24.2",
|
||||||
"graphql-subscriptions": "^3.0.0",
|
"graphql-subscriptions": "^3.0.0",
|
||||||
"graphql-tools": "^9.0.3",
|
"graphql-tools": "^9.0.18",
|
||||||
"graphql-ws": "^5.16.0",
|
"graphql-ws": "^6.0.4",
|
||||||
"reflect-metadata": "^0.2.2",
|
"reflect-metadata": "^0.2.2",
|
||||||
"type-graphql": "^2.0.0-rc.2",
|
"type-graphql": "^2.0.0-rc.2",
|
||||||
"web-push": "^3.6.7",
|
"web-push": "^3.6.7",
|
||||||
"ws": "^8.18.0"
|
"ws": "^8.18.1"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@babel/core": "^7.26.0",
|
"@babel/core": "^7.26.10",
|
||||||
"@babel/preset-env": "^7.26.0",
|
"@babel/preset-env": "^7.26.9",
|
||||||
"@babel/preset-typescript": "^7.26.0",
|
"@babel/preset-typescript": "^7.27.0",
|
||||||
"@babel/register": "^7.25.9",
|
"@babel/register": "^7.25.9",
|
||||||
"@types/body-parser": "^1.19.5",
|
"@types/body-parser": "^1.19.5",
|
||||||
"@types/cookie-parser": "^1.4.7",
|
"@types/cookie-parser": "^1.4.8",
|
||||||
"@types/cors": "^2.8.17",
|
"@types/cors": "^2.8.17",
|
||||||
"@types/express": "^5.0.0",
|
"@types/express": "^5.0.1",
|
||||||
"@types/jest": "^29.5.14",
|
"@types/jest": "^29.5.14",
|
||||||
"@types/node": "^22.9.0",
|
"@types/node": "^22.14.1",
|
||||||
"@types/supertest": "^6.0.2",
|
"@types/supertest": "^6.0.3",
|
||||||
"@types/webpack": "^5.28.5",
|
"@types/webpack": "^5.28.5",
|
||||||
"@types/webpack-node-externals": "^3.0.4",
|
"@types/webpack-node-externals": "^3.0.4",
|
||||||
"@types/ws": "^8.5.13",
|
"@types/ws": "^8.18.1",
|
||||||
"@typescript-eslint/eslint-plugin": "^8.14.0",
|
"@typescript-eslint/eslint-plugin": "^8.30.1",
|
||||||
"@typescript-eslint/parser": "^8.14.0",
|
"@typescript-eslint/parser": "^8.30.1",
|
||||||
"babel-loader": "^9.2.1",
|
"babel-loader": "^10.0.0",
|
||||||
"clean-webpack-plugin": "^4.0.0",
|
"clean-webpack-plugin": "^4.0.0",
|
||||||
"compression-webpack-plugin": "^11.1.0",
|
"compression-webpack-plugin": "^11.1.0",
|
||||||
"eslint": "^9.14.0",
|
"eslint": "^9.25.0",
|
||||||
"eslint-webpack-plugin": "^4.2.0",
|
"eslint-webpack-plugin": "^5.0.1",
|
||||||
"jest": "^29.7.0",
|
"jest": "^29.7.0",
|
||||||
"nodemon": "^3.1.7",
|
"nodemon": "^3.1.9",
|
||||||
"resolve-ts-aliases": "^1.0.1",
|
"resolve-ts-aliases": "^1.0.1",
|
||||||
"supertest": "^7.0.0",
|
"supertest": "^7.1.0",
|
||||||
"ts-jest": "^29.2.5",
|
"ts-jest": "^29.3.2",
|
||||||
"ts-loader": "^9.5.1",
|
"ts-loader": "^9.5.2",
|
||||||
"typescript": "^5.6.3",
|
"typescript": "^5.8.3",
|
||||||
"webpack": "^5.96.1",
|
"webpack": "^5.99.6",
|
||||||
"webpack-cli": "^5.1.4",
|
"webpack-cli": "^6.0.1",
|
||||||
"webpack-manifest-plugin": "^5.0.0",
|
"webpack-manifest-plugin": "^5.0.1",
|
||||||
"webpack-node-externals": "^3.0.0",
|
"webpack-node-externals": "^3.0.0",
|
||||||
"webpack-shell-plugin-next": "^2.3.2"
|
"webpack-shell-plugin-next": "^2.3.2"
|
||||||
}
|
}
|
||||||
|
4
src/@types/custom.d.ts
vendored
4
src/@types/custom.d.ts
vendored
@ -7,4 +7,8 @@ declare module "*.gql" {
|
|||||||
declare module 'cookie-parse' {
|
declare module 'cookie-parse' {
|
||||||
const content: any;
|
const content: any;
|
||||||
export default content;
|
export default content;
|
||||||
|
}
|
||||||
|
|
||||||
|
declare module 'graphql-ws/use/ws' {
|
||||||
|
export * from 'graphql-ws/dist/use/ws';
|
||||||
}
|
}
|
1
src/GraphQL/resolvers/index.ts
Normal file
1
src/GraphQL/resolvers/index.ts
Normal file
@ -0,0 +1 @@
|
|||||||
|
export * from './test.resolver';
|
@ -1,19 +1,33 @@
|
|||||||
/* eslint-disable no-mixed-spaces-and-tabs */
|
/* eslint-disable no-mixed-spaces-and-tabs */
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
import { Query, Resolver, Mutation } from 'type-graphql';
|
import { Query, Resolver, Mutation, FieldResolver, Root, Arg } from 'type-graphql';
|
||||||
import { Test, TestMutation } from '@GraphQL/schema/test.schema';
|
import { Test, TestMutation } from '@GraphQL/schema';
|
||||||
|
import { getTest, addText } from '@controllerGraphQL';
|
||||||
|
|
||||||
@Resolver(() => Test)
|
@Resolver(() => Test)
|
||||||
export class TestResolver {
|
export class TestResolverQuery {
|
||||||
@Query(() => Test)
|
@Query(() => Test)
|
||||||
async test() {
|
async test() {
|
||||||
return Test;
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
@Mutation(() => TestMutation)
|
@FieldResolver(() => String)
|
||||||
async testMutation() {
|
async text() {
|
||||||
return TestMutation;
|
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});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,10 +1,18 @@
|
|||||||
'use strict'
|
'use strict'
|
||||||
|
|
||||||
import { buildSchemaSync } from "type-graphql"
|
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({
|
const schema = buildSchemaSync({
|
||||||
resolvers: [TestResolver],
|
resolvers: [
|
||||||
|
TestResolverQuery,
|
||||||
|
TestResolverMutation,
|
||||||
|
],
|
||||||
emitSchemaFile: true,
|
emitSchemaFile: true,
|
||||||
})
|
})
|
||||||
export default schema
|
export default schema
|
@ -1,21 +1,16 @@
|
|||||||
/* eslint-disable no-mixed-spaces-and-tabs */
|
/* eslint-disable no-mixed-spaces-and-tabs */
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
import { Field, ObjectType, Arg } from 'type-graphql';
|
import { Field, ObjectType } from 'type-graphql';
|
||||||
import { getTest, addText } from '@controllerGraphQL';
|
|
||||||
|
|
||||||
@ObjectType()
|
@ObjectType()
|
||||||
export class Test {
|
export class Test {
|
||||||
@Field(() => String)
|
@Field(() => String)
|
||||||
async text(){
|
text?: string;
|
||||||
return await getTest({});
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ObjectType()
|
@ObjectType()
|
||||||
export class TestMutation {
|
export class TestMutation {
|
||||||
@Field(() => String)
|
@Field(() => String)
|
||||||
async text(@Arg('text') text?: string){
|
text?: string;
|
||||||
return await addText({text});
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -5,7 +5,7 @@ import ws from 'ws'; // yarn add ws
|
|||||||
import express from 'express'; //express
|
import express from 'express'; //express
|
||||||
import cors from 'cors';
|
import cors from 'cors';
|
||||||
import cookieParser from 'cookie-parser';
|
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 { execute, subscribe } from 'graphql';
|
||||||
import GraphQLserver from '@GraphQL/server';// Server of GraphQL,
|
import GraphQLserver from '@GraphQL/server';// Server of GraphQL,
|
||||||
import expressPlayground from 'graphql-playground-middleware-express';
|
import expressPlayground from 'graphql-playground-middleware-express';
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
"compilerOptions": {
|
"compilerOptions": {
|
||||||
"module": "commonjs",
|
"module": "commonjs",
|
||||||
"esModuleInterop": true,
|
"esModuleInterop": true,
|
||||||
"target": "es2018",
|
"target": "es2021",
|
||||||
"moduleResolution": "node",
|
"moduleResolution": "node",
|
||||||
"sourceMap": true,
|
"sourceMap": true,
|
||||||
"typeRoots" : ["./src/@types", "./node_modules/@types"],
|
"typeRoots" : ["./src/@types", "./node_modules/@types"],
|
||||||
|
Loading…
Reference in New Issue
Block a user