Skip to content

Commit

Permalink
Merge pull request #333 from lenneTech/develop
Browse files Browse the repository at this point in the history
Release 10.1.1
  • Loading branch information
kaihaase authored Nov 7, 2023
2 parents 20c4698 + 4d3372e commit c91756e
Show file tree
Hide file tree
Showing 7 changed files with 60 additions and 12 deletions.
23 changes: 23 additions & 0 deletions k6.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import http from 'k6/http';
import { sleep } from 'k6';

export const options = {
vus: 10,
duration: '30s',
};

export default function () {
const query = `
query HealthCheck {
healthCheck
}`;
const headers = {
'Content-Type': 'application/json',
};
http.post(
'http://localhost:3000/graphql/test',
JSON.stringify({ query }),
{ headers },
);
sleep(1);
}
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 5 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@lenne.tech/nest-server",
"version": "10.1.0",
"version": "10.1.1",
"description": "Modern, fast, powerful Node.js web framework in TypeScript based on Nest with a GraphQL API and a connection to MongoDB (or other databases).",
"keywords": [
"node",
Expand Down Expand Up @@ -33,10 +33,10 @@
"start:prod": "./node_modules/.bin/grunt production",
"start:nodemon": "ts-node -r tsconfig-paths/register src/main.ts",
"start:debug": "nodemon --config nodemon-debug.json",
"start:dev": "nest start -b swc -w --type-check",
"start:dev:ts": "nodemon",
"start:local": "NODE_ENV=local nest start -b swc -w --type-check",
"start:local:ts": "NODE_ENV=local nodemon",
"start:dev": "nodemon",
"start:dev:swc": "nest start -b swc -w --type-check",
"start:local": "NODE_ENV=local nodemon",
"start:local:swc": "NODE_ENV=local nest start -b swc -w --type-check",
"test": "NODE_ENV=local jest",
"test:cov": "NODE_ENV=local jest --coverage",
"test:debug": "NODE_ENV=local node --inspect-brk -r tsconfig-paths/register -r ts-node/register node_modules/.bin/jest --runInBand",
Expand Down
2 changes: 1 addition & 1 deletion spectaql.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ servers:
info:
title: lT Nest Server
description: Modern, fast, powerful Node.js web framework in TypeScript based on Nest with a GraphQL API and a connection to MongoDB (or other databases).
version: 10.0.11
version: 10.1.1
contact:
name: lenne.Tech GmbH
url: https://lenne.tech
Expand Down
2 changes: 1 addition & 1 deletion src/config.env.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ const config: { [env: string]: IServerOptions } = {
},
},
},
hostname: 'localhost',
hostname: '127.0.0.1',
ignoreSelectionsForPopulate: true,
jwt: {
// Each secret should be unique and not reused in other environments,
Expand Down
21 changes: 19 additions & 2 deletions src/core/common/interceptors/check-security.interceptor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { CallHandler, ExecutionContext, Injectable, NestInterceptor } from '@nes
import { Observable } from 'rxjs';
import { map } from 'rxjs/operators';
import { getContextData } from '../helpers/context.helper';
import { getStringIds } from '../helpers/db.helper';
import { processDeep } from '../helpers/input.helper';

/**
Expand All @@ -28,7 +29,15 @@ export class CheckSecurityInterceptor implements NestInterceptor {
map((data) => {
// Check data
if (data && typeof data === 'object' && typeof data.securityCheck === 'function') {
return data.securityCheck(user, force);
const dataJson = JSON.stringify(data);
const response = data.securityCheck(user, force);
new Promise(() => {
if (dataJson !== JSON.stringify(response)) {
const id = getStringIds(data);
console.debug('CheckSecurityInterceptor: securityCheck changed data of type', data.constructor.name, id && !Array.isArray(id) ? `with ID: ${id}` : '');
}
});
return response;
}

// Check if data is writeable (e.g. objects from direct access to json files via http are not writable)
Expand All @@ -49,7 +58,15 @@ export class CheckSecurityInterceptor implements NestInterceptor {
}
return item;
}
return item.securityCheck(user, force);
const itemJson = JSON.stringify(item);
const response = item.securityCheck(user, force);
new Promise(() => {
if (itemJson !== JSON.stringify(response)) {
const id = getStringIds(item);
console.debug('CheckSecurityInterceptor: securityCheck changed item of type', item.constructor.name, id && !Array.isArray(id) ? `with ID: ${id}` : '');
}
});
return response;
},
{ specialFunctions: ['securityCheck'] },
);
Expand Down
10 changes: 9 additions & 1 deletion src/core/common/services/module.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,15 @@ export abstract class ModuleService<T extends CoreModel = any> {
if (!opts.targetModel && config.inputType) {
opts.targetModel = config.inputType;
}
config.input = await this.prepareInput(config.input, config);
const originalInput = config.input;
const inputJSON = JSON.stringify(originalInput);
const preparedInput = await this.prepareInput(config.input, config);
new Promise(() => {
if (inputJSON?.replace(/"password":\s*"[^"]*"/, '') !== JSON.stringify(preparedInput)?.replace(/"password":\s*"[^"]*"/, '')) {
console.debug('CheckSecurityInterceptor: securityCheck changed input of type', originalInput.constructor.name, 'to type', preparedInput.constructor.name);
}
});
config.input = preparedInput;
}

// Get DB object
Expand Down

0 comments on commit c91756e

Please sign in to comment.