rlz-engine 1.0.27 → 1.0.29

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.
@@ -11,7 +11,9 @@ import { installIntoGlobal } from 'iterator-helpers-polyfill';
11
11
  import path from 'path';
12
12
  import { logger } from './logger';
13
13
  installIntoGlobal();
14
+ const L = logger('init');
14
15
  export async function runServer({ production, domain, certDir, staticDir, init }) {
16
+ L.info({ production }, 'runServer');
15
17
  const httpServer = fastify({
16
18
  loggerInstance: logger('http'),
17
19
  ajv: { plugins: [formatsPlugin] }
@@ -35,7 +37,9 @@ export async function runServer({ production, domain, certDir, staticDir, init }
35
37
  }
36
38
  httpServer.register(fastifyAcmeUnsecurePlugin, { redirectDomain: domain });
37
39
  await httpServer.listen({ port: 80, host: '::' });
40
+ L.info('Get certificates');
38
41
  const certAndKey = await getCertAndKey(certDir, domain);
42
+ L.info('Init secure server');
39
43
  const httpsServer = fastify({
40
44
  http2: true,
41
45
  https: {
@@ -62,6 +66,7 @@ export async function runServer({ production, domain, certDir, staticDir, init }
62
66
  });
63
67
  addStaticEndpoints(httpsServer, staticDir);
64
68
  await httpsServer.listen({ port: 443, host: '::' });
69
+ L.info('runServer done');
65
70
  }
66
71
  function addStaticEndpoints(server, staticPath) {
67
72
  const absStaticPath = path.resolve(staticPath);
@@ -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();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "rlz-engine",
3
- "version": "1.0.27",
3
+ "version": "1.0.29",
4
4
  "description": "Deps and tools for my style of development",
5
5
  "scripts": {
6
6
  "build": "tsc",