miolo 3.0.0-beta.136 → 3.0.0-beta.138

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": "miolo",
3
- "version": "3.0.0-beta.136",
3
+ "version": "3.0.0-beta.138",
4
4
  "description": "all-in-one koa-based server",
5
5
  "author": "Donato Lorenzo <donato@afialapis.com>",
6
6
  "contributors": [
@@ -3,7 +3,13 @@ export function sys_email_queue_config() {
3
3
  name: 'Emailer',
4
4
  cronTime: '* * * * *',
5
5
  onTick: async (miolo, _onCompleted) => {
6
- await miolo.emailer.queue_send_emails(miolo.logger)
6
+
7
+ const n = await miolo.emailer.queue_send_emails(miolo.logger)
8
+ if (n == -1) {
9
+ miolo.logger.error(`[emailer] Error sending emails`)
10
+ } else {
11
+ miolo.logger.info(`[emailer] Sent ${n} emails`)
12
+ }
7
13
  },
8
14
  start: true
9
15
  }
@@ -20,7 +20,6 @@ export async function email_queue_an_email(email, logger= undefined) {
20
20
 
21
21
  /* eslint-disable no-unused-vars */
22
22
  export function email_queue_pop_pendings(logger= undefined) {
23
-
24
23
  let grouped = {}
25
24
 
26
25
  Object.values(EMAIL_QUEUE)
@@ -103,30 +103,36 @@ export function _init_emailer_transporter({options, defaults, silent}) {
103
103
  async function queue_send_emails(logger= undefined) {
104
104
  const pending = email_queue_pop_pendings(logger)
105
105
  if (pending.length <= 0) {
106
- return
106
+ return 0
107
107
  }
108
- _logi(logger, `[emailer] Sending emails queue (${pending.length} emails)`)
109
-
110
- // const emailString = await client.lPop('email_queue')
111
- // if (!emailString) break
112
- // const email = JSON.parse(emailString)
113
-
114
- for (const email of pending) {
115
- if (email.count > 1) {
116
- _logs(logger, `[emailer] Sending queued and stacked email [${email.subject}](x${email.count})...`)
117
- email.subject = `${email.subject} (x${email.count})`
118
- } else {
119
- _logs(logger, `[emailer] Sending queued email [${email.subject}]...`)
120
- }
121
-
122
- send_email(email).then((res) => {
123
- _logs(logger, `[emailer] Queued email [${email.subject}]sent ${res.ok ? 'OK' : 'NOT OK'}`)
124
- if (res.ok) {
125
- delete email_queue_remove_ids(email.ids, logger)
108
+ try {
109
+ _logi(logger, `[emailer] Sending emails queue (${pending.length} emails)`)
110
+
111
+ // const emailString = await client.lPop('email_queue')
112
+ // if (!emailString) break
113
+ // const email = JSON.parse(emailString)
114
+
115
+ for (const email of pending) {
116
+ if (email.count > 1) {
117
+ _logs(logger, `[emailer] Sending queued and stacked email [${email.subject}](x${email.count})...`)
118
+ email.subject = `${email.subject} (x${email.count})`
119
+ } else {
120
+ _logs(logger, `[emailer] Sending queued email [${email.subject}]...`)
126
121
  }
127
- })
122
+
123
+ send_email(email).then((res) => {
124
+ _logs(logger, `[emailer] Queued email [${email.subject}]sent ${res.ok ? 'OK' : 'NOT OK'}`)
125
+ if (res.ok) {
126
+ delete email_queue_remove_ids(email.ids, logger)
127
+ }
128
+ })
129
+ }
130
+ _logs(logger, `[emailer] Sent emails ${pending.length} from queue`)
131
+ return pending.length
132
+ } catch(error) {
133
+ _loge(logger, `[emailer] Error sending emails queue: ${error}`)
134
+ return -1
128
135
  }
129
- _logs(logger, `[emailer] Sent emails ${pending.length} from queue`)
130
136
  }
131
137
 
132
138
  const emailer= {
@@ -14,7 +14,7 @@ const injectStackTrace = format((info) => {
14
14
  // 2. Buscamos en qué línea del stack aparece tu wrapper
15
15
  const wrapperIndex = stackLines.findIndex(line => line.includes(wrapperAnchor));
16
16
 
17
- let cleanStackLines = [];
17
+ let cleanStackLines = stackLines;
18
18
 
19
19
  if (wrapperIndex !== -1) {
20
20
  // CASO ÉXITO: Encontramos tu wrapper.
package/src/index.mjs CHANGED
@@ -7,7 +7,7 @@ import { with_miolo_schema } from './engines/schema/index.mjs'
7
7
 
8
8
  import { cacheiro as miolo_cacher} from 'cacheiro'
9
9
  import { getConnection as miolo_db_connection_pg} from 'calustra/conn-postgres'
10
- import { getConnection as miolo_db_connection_sqlite} from 'calustra/conn-sqlite'
10
+ // import { getConnection as miolo_db_connection_sqlite} from 'calustra/conn-sqlite'
11
11
 
12
12
  export {
13
13
  miolo,
@@ -17,6 +17,6 @@ export {
17
17
  miolo_parser,
18
18
  miolo_cacher,
19
19
  miolo_db_connection_pg,
20
- miolo_db_connection_sqlite,
20
+ // miolo_db_connection_sqlite,
21
21
  with_miolo_schema
22
22
  }
@@ -1,5 +1,5 @@
1
1
  import { getConnection as miolo_db_connection_pg, dropConnections as miolo_db_drop_connections_pg } from 'calustra/conn-postgres'
2
- import { getConnection as miolo_db_connection_sqlite, dropConnections as miolo_db_drop_connections_sqlite } from 'calustra/conn-sqlite'
2
+ // import { getConnection as miolo_db_connection_sqlite, dropConnections as miolo_db_drop_connections_sqlite } from 'calustra/conn-sqlite'
3
3
  import { miolo_cacher_options_for_calustra } from './cache/options.mjs'
4
4
 
5
5
  export function init_context_db (config, logger) {
@@ -14,12 +14,17 @@ export function init_context_db (config, logger) {
14
14
  cache: miolo_cacher_options_for_calustra(config, logger)
15
15
  }
16
16
 
17
- let conn = undefined
17
+ // let conn = undefined
18
+ // if (config.db.config.dialect === 'sqlite') {
19
+ // conn = await miolo_db_connection_sqlite(config.db.config, dbOptions)
20
+ // } else {
21
+ // conn = await miolo_db_connection_pg(config.db.config, dbOptions)
22
+ // }
23
+
24
+ let conn = await miolo_db_connection_pg(config.db.config, dbOptions)
18
25
  if (config.db.config.dialect === 'sqlite') {
19
- conn = await miolo_db_connection_sqlite(config.db.config, dbOptions)
20
- } else {
21
- conn = await miolo_db_connection_pg(config.db.config, dbOptions)
22
- }
26
+ logger.error(`[miolo] SQLite is not supported yet`)
27
+ }
23
28
 
24
29
  conn.get_model = conn.getModel
25
30
 
@@ -42,12 +47,17 @@ export function init_context_db (config, logger) {
42
47
  log: logger
43
48
  }
44
49
 
45
- let conn = undefined
50
+ // let conn = undefined
51
+ // if (config.db.config.dialect === 'sqlite') {
52
+ // conn = await miolo_db_connection_sqlite(config.db.config, dbOptions)
53
+ // } else {
54
+ // conn = await miolo_db_connection_pg(config.db.config, dbOptions)
55
+ // }
56
+
57
+ let conn = await miolo_db_connection_pg(config.db.config, dbOptions)
46
58
  if (config.db.config.dialect === 'sqlite') {
47
- conn = await miolo_db_connection_sqlite(config.db.config, dbOptions)
48
- } else {
49
- conn = await miolo_db_connection_pg(config.db.config, dbOptions)
50
- }
59
+ logger.error(`[miolo] SQLite is not supported yet`)
60
+ }
51
61
 
52
62
  return conn.get_model(name)
53
63
  }
@@ -63,9 +73,10 @@ export function init_context_db (config, logger) {
63
73
  },
64
74
  get_connection: get_connection_wrap,
65
75
  get_model: get_model_wrap,
66
- drop_connections: (config.db.config.dialect === 'sqlite')
67
- ? miolo_db_drop_connections_sqlite
68
- : miolo_db_drop_connections_pg
76
+ drop_connections:miolo_db_drop_connections_pg
77
+ // drop_connections: (config.db.config.dialect === 'sqlite')
78
+ // ? miolo_db_drop_connections_sqlite
79
+ // : miolo_db_drop_connections_pg
69
80
  }
70
81
 
71
82
  return db