itlab-internal-services 2.0.0 → 2.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -5,7 +5,8 @@ const common_1 = require("@nestjs/common");
5
5
  function useHttpLogger(app) {
6
6
  app.use((req, res, next) => {
7
7
  const { method, url } = req;
8
- if (url.includes('swagger') || url.startsWith('/api') || url === '/alive') {
8
+ const ignore = ['/alive', '/favicon.ico'];
9
+ if (url.includes('swagger') || url.startsWith('/api') || ignore.includes(url)) {
9
10
  next();
10
11
  return;
11
12
  }
@@ -13,7 +14,7 @@ function useHttpLogger(app) {
13
14
  const { statusCode, statusMessage } = res;
14
15
  const message = `${method} ${url} - ${statusCode} (${statusMessage})`;
15
16
  const level = statusCode >= 400 && statusCode < 500 ? 'warn' : 'log';
16
- if (url !== '/alive')
17
+ if (!ignore.includes(url))
17
18
  new common_1.Logger('HTTP')[level](message);
18
19
  });
19
20
  next();
@@ -1,3 +1,7 @@
1
+ import { Response } from 'express';
1
2
  export declare class LivenessProbe {
3
+ private axios;
4
+ private favicon;
2
5
  getAlive(): string;
6
+ getFavicon(res: Response): Promise<void>;
3
7
  }
@@ -8,14 +8,40 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
8
8
  var __metadata = (this && this.__metadata) || function (k, v) {
9
9
  if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
10
10
  };
11
+ var __param = (this && this.__param) || function (paramIndex, decorator) {
12
+ return function (target, key) { decorator(target, key, paramIndex); }
13
+ };
14
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
15
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
16
+ return new (P || (P = Promise))(function (resolve, reject) {
17
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
18
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
19
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
20
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
21
+ });
22
+ };
23
+ var __importDefault = (this && this.__importDefault) || function (mod) {
24
+ return (mod && mod.__esModule) ? mod : { "default": mod };
25
+ };
11
26
  Object.defineProperty(exports, "__esModule", { value: true });
12
27
  exports.LivenessProbe = void 0;
13
28
  const common_1 = require("@nestjs/common");
14
29
  const swagger_1 = require("@nestjs/swagger");
30
+ const axios_1 = __importDefault(require("axios"));
15
31
  let LivenessProbe = class LivenessProbe {
32
+ constructor() {
33
+ this.axios = axios_1.default.create();
34
+ this.favicon = 'https://file.svi-itlab.com/650d514c58cbe60df3494bc0';
35
+ }
16
36
  getAlive() {
17
37
  return 'service is up and running';
18
38
  }
39
+ getFavicon(res) {
40
+ return __awaiter(this, void 0, void 0, function* () {
41
+ const { data } = yield this.axios.get(this.favicon, { responseType: 'stream' });
42
+ data.pipe(res);
43
+ });
44
+ }
19
45
  };
20
46
  __decorate([
21
47
  (0, common_1.Get)('alive'),
@@ -23,6 +49,13 @@ __decorate([
23
49
  __metadata("design:paramtypes", []),
24
50
  __metadata("design:returntype", String)
25
51
  ], LivenessProbe.prototype, "getAlive", null);
52
+ __decorate([
53
+ (0, common_1.Get)('favicon.ico'),
54
+ __param(0, (0, common_1.Res)()),
55
+ __metadata("design:type", Function),
56
+ __metadata("design:paramtypes", [Object]),
57
+ __metadata("design:returntype", Promise)
58
+ ], LivenessProbe.prototype, "getFavicon", null);
26
59
  LivenessProbe = __decorate([
27
60
  (0, swagger_1.ApiTags)('Kubernetes Liveness Probe'),
28
61
  (0, common_1.Controller)()
@@ -17,13 +17,14 @@ class AvatarModel {
17
17
  const transform = {
18
18
  virtuals: true,
19
19
  transform: (_, ret) => {
20
+ const account = {
21
+ id: ret.id,
22
+ email: ret.email,
23
+ username: ret.username,
24
+ };
20
25
  if (ret.avatar)
21
- ret.avatar = `https://services.svi-itlab.com/account/avatar/${ret.id}`;
22
- delete ret._id;
23
- delete ret.__v;
24
- delete ret.createdAt;
25
- delete ret.updatedAt;
26
- return ret;
26
+ account.avatar = `https://services.svi-itlab.com/account/avatar/${ret.id}`;
27
+ return account;
27
28
  },
28
29
  };
29
30
  let AccountModel = class AccountModel extends mongoose_2.Document {
package/package.json CHANGED
@@ -5,7 +5,7 @@
5
5
  "email": "timo.scheuermann@sv-informatik.de",
6
6
  "url": "https://timos.design"
7
7
  },
8
- "version": "2.0.0",
8
+ "version": "2.0.2",
9
9
  "type": "commonjs",
10
10
  "files": [
11
11
  "dist"