rlz-engine 1.0.26 → 1.0.28

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.
@@ -1,3 +1,4 @@
1
+ import { WritableDraft } from 'immer';
1
2
  import { Logger, LoggerOptions } from 'pino';
2
- export declare function logger(name: string): Logger;
3
+ export declare function logger(name: string, optionsRecipe?: (draft: WritableDraft<LoggerOptions>) => WritableDraft<LoggerOptions>): Logger;
3
4
  export declare function loggerOptions(name: string): LoggerOptions;
@@ -1,7 +1,11 @@
1
+ import { produce } from 'immer';
1
2
  import { pino } from 'pino';
2
3
  import { PRODUCTION } from './config';
3
- export function logger(name) {
4
- return pino(loggerOptions(name));
4
+ export function logger(name, optionsRecipe) {
5
+ const options = optionsRecipe === undefined
6
+ ? loggerOptions(name)
7
+ : produce(loggerOptions(name), optionsRecipe);
8
+ return pino(options);
5
9
  }
6
10
  export function loggerOptions(name) {
7
11
  if (PRODUCTION) {
@@ -19,7 +23,8 @@ export function loggerOptions(name) {
19
23
  // target: 'pino-'
20
24
  // }
21
25
  ]
22
- }
26
+ },
27
+ level: 'info'
23
28
  };
24
29
  }
25
30
  return {
@@ -31,6 +36,7 @@ export function loggerOptions(name) {
31
36
  target: 'pino-pretty'
32
37
  }
33
38
  ]
34
- }
39
+ },
40
+ level: 'trace'
35
41
  };
36
42
  }
@@ -20,18 +20,22 @@ export class MongoStorage {
20
20
  const knownIndexes = await this.listIndexes(collection);
21
21
  this.logger.info({ indexes: Array.from(knownIndexes), collection: collection.collectionName }, 'Known indexes');
22
22
  knownIndexes.delete('_id_');
23
+ const indexesToCreate = [];
23
24
  for (const index of indexes) {
24
25
  if (knownIndexes.has(index.name)) {
25
26
  knownIndexes.delete(index.name);
26
27
  continue;
27
28
  }
28
- this.logger.info({ index, collection: collection.collectionName }, 'Create index');
29
- await collection.createIndexes([index]);
29
+ indexesToCreate.push(index);
30
30
  }
31
31
  for (const name of knownIndexes) {
32
32
  this.logger.info({ index: name, collection: collection.collectionName }, 'Drop index');
33
33
  await collection.dropIndex(name);
34
34
  }
35
+ for (const index of indexesToCreate) {
36
+ this.logger.info({ index, collection: collection.collectionName }, 'Create index');
37
+ await collection.createIndexes([index]);
38
+ }
35
39
  }
36
40
  async listIndexes(collection) {
37
41
  const indexes = await collection.listIndexes().toArray();
@@ -5,13 +5,13 @@ export declare const API_AUTH_RESPONSE_SCHEMA_V0: z.ZodObject<{
5
5
  email: z.ZodString;
6
6
  tempPassword: z.ZodString;
7
7
  }, "strip", z.ZodTypeAny, {
8
- id: string;
9
8
  name: string;
9
+ id: string;
10
10
  email: string;
11
11
  tempPassword: string;
12
12
  }, {
13
- id: string;
14
13
  name: string;
14
+ id: string;
15
15
  email: string;
16
16
  tempPassword: string;
17
17
  }>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "rlz-engine",
3
- "version": "1.0.26",
3
+ "version": "1.0.28",
4
4
  "description": "Deps and tools for my style of development",
5
5
  "scripts": {
6
6
  "build": "tsc",
@@ -53,6 +53,7 @@
53
53
  "fastify": "^5.1.0",
54
54
  "fastify-acme": "^1.0.5",
55
55
  "fastify-plugin": "^5.0.1",
56
+ "immer": "^10.1.1",
56
57
  "iterator-helpers-polyfill": "^3.0.1",
57
58
  "luxon": "^3.5.0",
58
59
  "mongodb": "^6.12.0",