@lenne.tech/nest-server 8.6.28 → 8.6.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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lenne.tech/nest-server",
3
- "version": "8.6.28",
3
+ "version": "8.6.29",
4
4
  "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).",
5
5
  "keywords": [
6
6
  "node",
@@ -18,7 +18,7 @@
18
18
  "build:pack": "npm pack && echo 'use file:/ROOT_PATH_TO_TGZ_FILE to integrate the package'",
19
19
  "docs": "npm run docs:ci && open ./public/index.html",
20
20
  "docs:bootstrap": "node extras/update-spectaql-version.mjs && npx -y spectaql ./spectaql.yml",
21
- "docs:ci": "ts-node ./scripts/init-server.ts && npm run docs:boostrap",
21
+ "docs:ci": "ts-node ./scripts/init-server.ts && npm run docs:bootstrap",
22
22
  "format": "prettier --write 'src/**/*.ts'",
23
23
  "format:staged": "pretty-quick --staged",
24
24
  "lint": "eslint \"{src,tests}/**/*.ts\" --fix",
package/src/config.env.ts CHANGED
@@ -1,5 +1,6 @@
1
1
  import { CronExpression } from '@nestjs/schedule';
2
2
  import { join } from 'path';
3
+ import { merge } from './core/common/helpers/config.helper';
3
4
  import { IServerOptions } from './core/common/interfaces/server-options.interface';
4
5
 
5
6
  /**
@@ -22,8 +23,8 @@ const config: { [env: string]: IServerOptions } = {
22
23
  email: {
23
24
  smtp: {
24
25
  auth: {
25
- user: 'rebeca68@ethereal.email',
26
- pass: 'v5WUScAN98AzGbRjpc',
26
+ user: 'sandra98@ethereal.email',
27
+ pass: 'JCQQdz8xJEfBSewahK',
27
28
  },
28
29
  host: 'smtp.ethereal.email',
29
30
  port: 587,
@@ -34,8 +35,8 @@ const config: { [env: string]: IServerOptions } = {
34
35
  api_key_private: 'MAILJET_API_KEY_PRIVATE',
35
36
  },
36
37
  defaultSender: {
37
- email: 'rebeca68@ethereal.email',
38
- name: 'Rebeca Sixtyeight',
38
+ email: 'sandra98@ethereal.email',
39
+ name: 'Sandra Klein',
39
40
  },
40
41
  verificationLink: 'http://localhost:4200/user/verification',
41
42
  passwordResetLink: 'http://localhost:4200/user/password-reset',
@@ -51,6 +52,7 @@ const config: { [env: string]: IServerOptions } = {
51
52
  jwt: {
52
53
  secret: 'SECRET_OR_PRIVATE_KEY_DEV',
53
54
  },
55
+ loadLocalConfig: false,
54
56
  mongoose: {
55
57
  uri: 'mongodb://localhost/nest-server-dev',
56
58
  },
@@ -73,8 +75,8 @@ const config: { [env: string]: IServerOptions } = {
73
75
  email: {
74
76
  smtp: {
75
77
  auth: {
76
- user: 'rebeca68@ethereal.email',
77
- pass: 'v5WUScAN98AzGbRjpc',
78
+ user: 'sandra98@ethereal.email',
79
+ pass: 'JCQQdz8xJEfBSewahK',
78
80
  },
79
81
  host: 'smtp.ethereal.email',
80
82
  port: 587,
@@ -85,8 +87,8 @@ const config: { [env: string]: IServerOptions } = {
85
87
  api_key_private: 'MAILJET_API_KEY_PRIVATE',
86
88
  },
87
89
  defaultSender: {
88
- email: 'rebeca68@ethereal.email',
89
- name: 'Rebeca Sixtyeight',
90
+ email: 'sandra98@ethereal.email',
91
+ name: 'Sandra Klein',
90
92
  },
91
93
  verificationLink: 'http://localhost:4200/user/verification',
92
94
  passwordResetLink: 'http://localhost:4200/user/password-reset',
@@ -102,6 +104,7 @@ const config: { [env: string]: IServerOptions } = {
102
104
  jwt: {
103
105
  secret: 'SECRET_OR_PRIVATE_KEY_DEV',
104
106
  },
107
+ loadLocalConfig: false,
105
108
  mongoose: {
106
109
  uri: 'mongodb://localhost/nest-server-dev',
107
110
  },
@@ -124,8 +127,8 @@ const config: { [env: string]: IServerOptions } = {
124
127
  email: {
125
128
  smtp: {
126
129
  auth: {
127
- user: 'rebeca68@ethereal.email',
128
- pass: 'v5WUScAN98AzGbRjpc',
130
+ user: 'sandra98@ethereal.email',
131
+ pass: 'JCQQdz8xJEfBSewahK',
129
132
  },
130
133
  host: 'smtp.ethereal.email',
131
134
  port: 587,
@@ -136,8 +139,8 @@ const config: { [env: string]: IServerOptions } = {
136
139
  api_key_private: 'MAILJET_API_KEY_PRIVATE',
137
140
  },
138
141
  defaultSender: {
139
- email: 'rebeca68@ethereal.email',
140
- name: 'Rebeca Sixtyeight',
142
+ email: 'sandra98@ethereal.email',
143
+ name: 'Sandra Klein',
141
144
  },
142
145
  verificationLink: 'http://localhost:4200/user/verification',
143
146
  passwordResetLink: 'http://localhost:4200/user/password-reset',
@@ -153,6 +156,7 @@ const config: { [env: string]: IServerOptions } = {
153
156
  jwt: {
154
157
  secret: 'SECRET_OR_PRIVATE_KEY_PROD',
155
158
  },
159
+ loadLocalConfig: false,
156
160
  mongoose: {
157
161
  uri: 'mongodb://localhost/nest-server-prod',
158
162
  },
@@ -178,6 +182,29 @@ const env = process.env['NODE' + '_ENV'] || 'development';
178
182
  const envConfig = config[env] || config.development;
179
183
  console.info('Configured for: ' + envConfig.env + (env !== envConfig.env ? ' (requested: ' + env + ')' : ''));
180
184
 
185
+ // Merge with localConfig (e.g. config.json)
186
+ if (envConfig.loadLocalConfig) {
187
+ let localConfig;
188
+ if (typeof envConfig.loadLocalConfig === 'string') {
189
+ localConfig = require(envConfig.loadLocalConfig);
190
+ merge(envConfig, localConfig);
191
+ } else {
192
+ try {
193
+ // get config from src directory
194
+ localConfig = require(__dirname + '/config.json');
195
+ merge(envConfig, localConfig);
196
+ } catch {
197
+ try {
198
+ // if not found try to find in project directory
199
+ localConfig = require(__dirname + '/../config.json');
200
+ merge(envConfig, localConfig);
201
+ } catch (e) {
202
+ // No config.json found => nothing to do
203
+ }
204
+ }
205
+ }
206
+ }
207
+
181
208
  /**
182
209
  * Export envConfig as default
183
210
  */
@@ -322,12 +322,12 @@ export function clone(object: any, options?: { proto?: boolean; circles?: boolea
322
322
  try {
323
323
  return rfdc(config)(object);
324
324
  } catch (e) {
325
- console.info(e);
326
- if (object.circle) {
325
+ console.debug(e);
326
+ if (!config.circles) {
327
327
  try {
328
328
  return rfdc({ ...config, ...{ circles: true } })(object);
329
329
  } catch (e) {
330
- console.info(e);
330
+ console.debug(e);
331
331
  return _.clone(object);
332
332
  }
333
333
  } else {
@@ -202,18 +202,18 @@ export function mapClasses<T = Record<string, any>>(
202
202
  if (Array.isArray(value)) {
203
203
  const arr = [];
204
204
  for (const item of value) {
205
- if (value instanceof targetClass) {
206
- arr.push(value);
207
- } else if (value instanceof Types.ObjectId) {
208
- config.objectIdsToString ? arr.push(value.toHexString()) : arr.push(value);
209
- } else if (typeof value === 'object') {
205
+ if (item instanceof targetClass) {
206
+ arr.push(item);
207
+ } else if (item instanceof Types.ObjectId) {
208
+ config.objectIdsToString ? arr.push(item.toHexString()) : arr.push(item);
209
+ } else if (typeof item === 'object') {
210
210
  if (targetClass.map) {
211
211
  arr.push(targetClass.map(item));
212
212
  } else {
213
213
  arr.push(plainToInstance(targetClass, item));
214
214
  }
215
215
  } else {
216
- arr.push(value);
216
+ arr.push(item);
217
217
  }
218
218
  }
219
219
  target[prop] = arr as any;
@@ -285,18 +285,18 @@ export async function mapClassesAsync<T = Record<string, any>>(
285
285
  if (Array.isArray(value)) {
286
286
  const arr = [];
287
287
  for (const item of value) {
288
- if (value instanceof targetClass) {
289
- arr.push(value);
290
- } else if (value instanceof Types.ObjectId) {
291
- config.objectIdsToString ? arr.push(value.toHexString()) : arr.push(value);
292
- } else if (typeof value === 'object') {
288
+ if (item instanceof targetClass) {
289
+ arr.push(item);
290
+ } else if (item instanceof Types.ObjectId) {
291
+ config.objectIdsToString ? arr.push(item.toHexString()) : arr.push(item);
292
+ } else if (typeof item === 'object') {
293
293
  if (targetClass.map) {
294
294
  arr.push(await targetClass.map(item));
295
295
  } else {
296
296
  arr.push(plainToInstance(targetClass, item));
297
297
  }
298
298
  } else {
299
- arr.push(value);
299
+ arr.push(item);
300
300
  }
301
301
  }
302
302
  target[prop] = arr as any;
@@ -128,6 +128,14 @@ export interface IServerOptions {
128
128
  secretOrPrivateKey?: string;
129
129
  } & JwtModuleOptions;
130
130
 
131
+ /**
132
+ * Load local configuration
133
+ * false: no local configuration is loaded,
134
+ * true: it tries to load ./config.json or ../config.json,
135
+ * string: path to configuration
136
+ */
137
+ loadLocalConfig?: boolean | string;
138
+
131
139
  /**
132
140
  * Configuration for Mongoose
133
141
  */