Skip to content

Commit

Permalink
Merge pull request #134 from osstotalsoft/features/missing-updates
Browse files Browse the repository at this point in the history
small fixes in middlewares
  • Loading branch information
alexandra-c authored Jul 29, 2024
2 parents ca8b12c + f034946 commit 9339aec
Show file tree
Hide file tree
Showing 6 changed files with 28,275 additions and 13,802 deletions.
16 changes: 8 additions & 8 deletions generators/app/templates/infrastructure/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
"dependencies": {
"@apollo/datasource-rest": "^6.3.0",
"@apollo/server": "^4.10.5",
"@as-integrations/koa": "1.1.1",
"@as-integrations/koa": "^1.1.1",
"@graphql-tools/load-files": "^7.0.0",
"@graphql-tools/merge": "^9.0.4",
"@graphql-tools/schema": "^10.0.4",
Expand Down Expand Up @@ -75,9 +75,9 @@
"async-mutex": "^0.4.0",
"bluebird": "^3.7.2",
"colors": "^1.4.0",
"console-stamp": "^3.1.1",
"console-stamp": "^3.1.2",
"dotenv": "^16.4.5",
"graphql": "16.9.0",
"graphql": "^16.9.0",
<%_ if(addSubscriptions){ _%>
"graphql-redis-subscriptions": "^2.6.1",
"graphql-subscriptions": "^2.0.0",
Expand Down Expand Up @@ -111,21 +111,21 @@
"@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",
"@totalsoft/pino-opentelemetry": "^2.1.0",
<%_}_%>
"jsonwebtoken": "9.0.0",
"jwks-rsa": "^3.0.1",
"koa": "^2.14.1",
"koa-bodyparser": "^4.3.0",
"koa": "^2.15.3",
"koa-bodyparser": "^4.4.1",
"koa-jwt": "^4.0.4",
"numeral": "^2.0.6",
"path": "^0.12.7",
"ramda": "^0.30.1",
"tedious": "^18.3.0",
"uuid": "^10.0.0",
"pino": "^9.3.1",
"pino": "^9.3.2",
"pino-abstract-transport": "^1.2.0",
"pino-pretty": "^11.2.1"
"pino-pretty": "^11.2.2"
},
"devDependencies": {
"@graphql-eslint/eslint-plugin": "^3.20.1",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
const { logger } = require("../../startup");

const loggingMiddleware = async (ctx, next) => {
ctx.logger = logger;
await next();
};
if (!ctx.logger) ctx.logger = require('../../startup/logger')
await next()
}

module.exports = loggingMiddleware;
module.exports = loggingMiddleware
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
const { correlationManager } = require('@totalsoft/correlation')

const correlationPublish = async (ctx, next) => {
ctx.message.headers.pubSubCorrelationId = correlationManager.getCorrelationId()
if (ctx.message.headers) ctx.message.headers.pubSubCorrelationId = correlationManager.getCorrelationId()

return await next()
}
Expand Down
14 changes: 7 additions & 7 deletions generators/app/templates/infrastructure/src/servers/apollo.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,18 +60,18 @@ const startApolloServer = async (httpServer<% if(addSubscriptions) {%>, subscrip
const app = new Koa();
app.use(loggingMiddleware)
app.use(errorHandlingMiddleware())
app.use(bodyParser());
app.use(correlationMiddleware());
app.use(cors({ credentials: true }));
app.use(ignore(jwtTokenValidation, jwtTokenUserIdentification<% if(withMultiTenancy) {%>, tenantIdentification()<%}%>).if(ctx => publicRoute(ctx)))
.use(errorHandlingMiddleware())
.use(bodyParser());
.use(correlationMiddleware());
.use(cors({ credentials: true }));
.use(ignore(jwtTokenValidation, jwtTokenUserIdentification<% if(withMultiTenancy) {%>, tenantIdentification()<%}%>).if(ctx => publicRoute(ctx)))
<%_ if(addTracing){ _%>
tracingEnabled && app.use(tracingMiddleware());
<%_}_%>
<%_ if(dataLayer == "knex") {_%>
app.use(contextDbInstance());
.use(contextDbInstance());
<%_}_%>
app.use(
.use(
koaMiddleware(apolloServer,{
context: async ({ ctx }) => {
const { token, state, <% if(withMultiTenancy){ %>tenant, <%}%><% if(dataLayer == "knex") {%>dbInstance,<%}%> externalUser, request, requestSpan } = ctx;
Expand Down
Loading

0 comments on commit 9339aec

Please sign in to comment.