diff --git a/generators/app/templates/infrastructure/package.json b/generators/app/templates/infrastructure/package.json index 466ab45..7eb846c 100644 --- a/generators/app/templates/infrastructure/package.json +++ b/generators/app/templates/infrastructure/package.json @@ -28,7 +28,7 @@ <%_} _%> }, "lint-staged": { - "**/*.+(js|md|css|graphql|json)": "prettier --write" + "**/*.+(js|md|css|graphql|json)": "prettier --write" }, "author": "", "license": "ISC", @@ -65,6 +65,10 @@ "mssql": "^8.1.2", "knex": "^0.95.0", "async-mutex": "^0.4.0", + "colors": "^1.4.0", + <%_ if(addTracing){ _%> + "@opentelemetry/instrumentation-knex": "^0.38.0", + <%_} _%> <%_ if(withMultiTenancy && hasSharedDb) {_%> "@totalsoft/knex-filters": "^2.4.1", <%_} _%> @@ -74,7 +78,6 @@ "@totalsoft/messaging-host": "^2.5.0", <%_}_%> "bluebird": "^3.7.2", - "colors": "^1.4.0", "console-stamp": "^3.1.2", "dotenv": "^16.4.5", "graphql": "^16.9.0", @@ -84,6 +87,10 @@ "graphql-ws": "^5.16.0", "ioredis": "^5.4.1", "ws": "^8.18.0", + <%_ if(addTracing){ _%> + "@opentelemetry/instrumentation-ioredis": "^0.42.0", + "@totalsoft/opentelemetry-instrumentation-ws": "^2.0.0", + <%_}_%> <%_}_%> <%_ if(withRights){ _%> "graphql-middleware": "^6.1.35", @@ -103,14 +110,9 @@ "@opentelemetry/instrumentation-dataloader": "^0.11.0", "@opentelemetry/instrumentation-graphql": "^0.42.0", "@opentelemetry/instrumentation-http": "^0.52.1", - "@opentelemetry/instrumentation-ioredis": "^0.42.0", - "@opentelemetry/instrumentation-knex": "^0.38.0", - "@opentelemetry/instrumentation-koa": "^0.42.0", "@opentelemetry/instrumentation-pino": "^0.41.0", - "@opentelemetry/sdk-trace-base": "^1.25.1", "@opentelemetry/sdk-trace-node": "^1.25.1", "@opentelemetry/propagator-jaeger": "^1.25.1", - "@totalsoft/opentelemetry-instrumentation-ws": "^2.0.0", "@totalsoft/pino-opentelemetry": "^2.0.0", <%_}_%> "jsonwebtoken": "9.0.2", @@ -134,7 +136,6 @@ "eslint-plugin-import": "^2.29.1", "eslint-plugin-jest": "^28.6.0", "eslint-plugin-node": "^11.1.0", - "graphql-schema-linter": "^3.0.1", "husky": "^9.1.1", "jest": "^29.7.0", "jest-extended": "^4.0.2", diff --git a/generators/app/templates/infrastructure/src/features/common/paginationSchema.graphql b/generators/app/templates/infrastructure/src/features/common/paginationSchema.graphql deleted file mode 100644 index 882bbe3..0000000 --- a/generators/app/templates/infrastructure/src/features/common/paginationSchema.graphql +++ /dev/null @@ -1,19 +0,0 @@ - input PagerInput { - afterId: ID - sortBy: String - direction: Int - pageSize: Int - } - - type Page { - afterId: ID - sortBy: String - direction: Int - pageSize: Int - } - - type Pagination { - totalCount: Int - prevPage: Page - nextPage: Page - } \ No newline at end of file diff --git a/generators/app/templates/infrastructure/src/features/common/rootSchema.graphql b/generators/app/templates/infrastructure/src/features/common/rootSchema.graphql index 804682e..77fe34d 100644 --- a/generators/app/templates/infrastructure/src/features/common/rootSchema.graphql +++ b/generators/app/templates/infrastructure/src/features/common/rootSchema.graphql @@ -14,3 +14,22 @@ <%_}_%> } + input PagerInput { + afterId: ID + sortBy: String + direction: Int + pageSize: Int + } + + type Page { + afterId: ID + sortBy: String + direction: Int + pageSize: Int + } + + type Pagination { + totalCount: Int + prevPage: Page + nextPage: Page + } diff --git a/generators/app/templates/infrastructure/src/middleware/index.js b/generators/app/templates/infrastructure/src/middleware/index.js index a562ef7..e4346c8 100644 --- a/generators/app/templates/infrastructure/src/middleware/index.js +++ b/generators/app/templates/infrastructure/src/middleware/index.js @@ -11,10 +11,16 @@ const tenantIdentification = require("./tenantIdentification"); const tracingMiddleware = require('./tracing/tracingMiddleware'); <%_}_%> const loggingMiddleware = require('./logger/loggingMiddleware') +<%_ if(withRights){ _%> +const permissionsMiddleware = require('./permissions') +<%_}_%> module.exports = { ...validateToken, + <%_ if(withRights){ _%> + ...permissionsMiddleware, + <%_}_%> <%_ if(dataLayer == "knex") {_%> contextDbInstance, <%_}_%> diff --git a/generators/app/templates/infrastructure/src/startup/schema.js b/generators/app/templates/infrastructure/src/startup/schema.js index a36af43..024aa33 100644 --- a/generators/app/templates/infrastructure/src/startup/schema.js +++ b/generators/app/templates/infrastructure/src/startup/schema.js @@ -5,7 +5,7 @@ const { makeExecutableSchema } = require('@graphql-tools/schema'), <%_ if(withRights){ _%> const { applyMiddleware } = require('graphql-middleware'), - { permissionsMiddleware } = require('../middleware/permissions/index') + { permissionsMiddleware } = require('../middleware') <%_}_%> diff --git a/generators/app/templates/infrastructure/src/startup/tracing.js b/generators/app/templates/infrastructure/src/startup/tracing.js index 9881194..c4c6d98 100644 --- a/generators/app/templates/infrastructure/src/startup/tracing.js +++ b/generators/app/templates/infrastructure/src/startup/tracing.js @@ -3,13 +3,17 @@ const { Resource } = require("@opentelemetry/resources") const { JaegerPropagator } = require("@opentelemetry/propagator-jaeger") <%_ if(addSubscriptions) {_%> const { WSInstrumentation } = require("@totalsoft/opentelemetry-instrumentation-ws") +const { IORedisInstrumentation } = require('@opentelemetry/instrumentation-ioredis') <%_} _%> const { SEMRESATTRS_SERVICE_NAME, SEMATTRS_PEER_SERVICE } = require('@opentelemetry/semantic-conventions') const { OTLPTraceExporter } = require('@opentelemetry/exporter-trace-otlp-grpc') const { ParentBasedSampler, AlwaysOnSampler } = require('@opentelemetry/sdk-trace-node') const { HttpInstrumentation } = require('@opentelemetry/instrumentation-http') const { PinoInstrumentation } = require('@opentelemetry/instrumentation-pino') -const { IORedisInstrumentation } = require('@opentelemetry/instrumentation-ioredis') +<%_ if(dataLayer == 'knex') {_%> + const { KnexInstrumentation } = require("@opentelemetry/instrumentation-knex"); +<%_}_%> +const { DataloaderInstrumentation } = require("@opentelemetry/instrumentation-dataloader"); const { GraphQLInstrumentation } = require('@opentelemetry/instrumentation-graphql') const { context, trace } = require('@opentelemetry/api') const { getRPCMetadata, RPCType } = require('@opentelemetry/core') @@ -54,15 +58,18 @@ const sdk = new opentelemetry.NodeSDK({ mergeItems: true, responseHook: (span, _) => { const rpcMetadata = getRPCMetadata(context.active()) - if (rpcMetadata?.type === RPCType.HTTP) { rpcMetadata?.span?.updateName(`${rpcMetadata?.span?.name} ${span.name}`) } } }), new PinoInstrumentation(), - new IORedisInstrumentation(), + <%_ if(dataLayer == 'knex') {_%> + new KnexInstrumentation(), + <%_} _%> + new DataloaderInstrumentation(), <%_ if(addSubscriptions) {_%> + new IORedisInstrumentation(), new WSInstrumentation(), <%_} _%> <%_ if(dataLayer == 'prisma') {_%>