@boxyhq/saml-jackson 0.1.5-beta.96 → 0.1.5-beta.97

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": "@boxyhq/saml-jackson",
3
- "version": "0.1.5-beta.96",
3
+ "version": "0.1.5-beta.97",
4
4
  "license": "Apache 2.0",
5
5
  "description": "SAML 2.0 service",
6
6
  "main": "src/index.js",
@@ -13,9 +13,11 @@ module.exports = new EntitySchema({
13
13
  },
14
14
  key: {
15
15
  type: 'varchar',
16
+ length: 1500,
16
17
  },
17
18
  storeKey: {
18
19
  type: 'varchar',
20
+ length: 1500,
19
21
  }
20
22
  },
21
23
  relations: {
@@ -1,20 +1,36 @@
1
1
  const EntitySchema = require('typeorm').EntitySchema;
2
2
  const JacksonStore = require('../model/JacksonStore.js');
3
3
 
4
- module.exports = new EntitySchema({
5
- name: 'JacksonStore',
6
- target: JacksonStore,
7
- columns: {
8
- key: {
9
- primary: true,
10
- type: 'varchar',
11
- },
12
- value: {
13
- type: 'varchar',
4
+ const valueType = (type) => {
5
+ switch (type) {
6
+ case 'postgres':
7
+ case 'cockroachdb':
8
+ return 'text';
9
+ case 'mysql':
10
+ case 'mariadb':
11
+ return 'mediumtext';
12
+ default:
13
+ return 'varchar';
14
+ }
15
+ };
16
+
17
+ module.exports = (type) => {
18
+ return new EntitySchema({
19
+ name: 'JacksonStore',
20
+ target: JacksonStore,
21
+ columns: {
22
+ key: {
23
+ primary: true,
24
+ type: 'varchar',
25
+ length: 1500,
26
+ },
27
+ value: {
28
+ type: valueType(type),
29
+ },
30
+ expiresAt: {
31
+ type: 'bigint',
32
+ nullable: true,
33
+ },
14
34
  },
15
- expiresAt: {
16
- type: 'bigint',
17
- nullable: true,
18
- }
19
- },
20
- });
35
+ });
36
+ };
package/src/db/sql/sql.js CHANGED
@@ -8,17 +8,28 @@ const dbutils = require('../utils.js');
8
8
  class Sql {
9
9
  constructor(options) {
10
10
  return (async () => {
11
- this.connection = await typeorm.createConnection({
12
- name: options.type,
13
- type: options.type,
14
- url: options.url,
15
- synchronize: true,
16
- logging: false,
17
- entities: [
18
- require('./entity/JacksonStore.js'),
19
- require('./entity/JacksonIndex.js'),
20
- ],
21
- });
11
+ while (true) {
12
+ try {
13
+ this.connection = await typeorm.createConnection({
14
+ name: options.type,
15
+ type: options.type,
16
+ url: options.url,
17
+ synchronize: true,
18
+ migrationsTableName: '_jackson_migrations',
19
+ logging: false,
20
+ entities: [
21
+ require('./entity/JacksonStore.js')(options.type),
22
+ require('./entity/JacksonIndex.js'),
23
+ ],
24
+ });
25
+
26
+ break;
27
+ } catch (err) {
28
+ console.error(`error connecting to ${options.type} db: ${err}`);
29
+ await dbutils.sleep(1000);
30
+ continue;
31
+ }
32
+ }
22
33
 
23
34
  this.storeRepository = this.connection.getRepository(JacksonStore);
24
35
  this.indexRepository = this.connection.getRepository(JacksonIndex);
@@ -45,7 +56,9 @@ class Sql {
45
56
 
46
57
  this.timerId = setTimeout(this.ttlCleanup, options.ttl * 1000);
47
58
  } else {
48
- console.log('Warning: ttl cleanup not enabled, set both "ttl" and "limit" options to enable it!')
59
+ console.log(
60
+ 'Warning: ttl cleanup not enabled, set both "ttl" and "limit" options to enable it!'
61
+ );
49
62
  }
50
63
 
51
64
  return this;
package/src/db/utils.js CHANGED
@@ -16,14 +16,15 @@ const keyFromParts = (...parts) => {
16
16
  return parts.join(':'); // TODO: pick a better strategy, keys can collide now
17
17
  };
18
18
 
19
+ const sleep = (ms) => {
20
+ return new Promise((resolve) => setTimeout(resolve, ms));
21
+ };
22
+
19
23
  module.exports = {
20
24
  key,
21
-
22
25
  keyForIndex,
23
-
24
26
  keyDigest,
25
-
26
27
  keyFromParts,
27
-
28
+ sleep,
28
29
  indexPrefix: '_index',
29
30
  };
package/src/index.js CHANGED
@@ -56,7 +56,8 @@ module.exports = async function (opts) {
56
56
  }
57
57
  }
58
58
 
59
- console.log(`Using engine: ${opts.db.engine}`);
59
+ const type = opts.db.type ? ' Type: ' + opts.db.type : '';
60
+ console.log(`Using engine: ${opts.db.engine}.${type}`);
60
61
 
61
62
  return {
62
63
  apiController,