@prosopo/database 0.3.1 → 0.3.3
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/dist/cjs/eventsDatabase/eventsDatabase.cjs +7 -33
- package/dist/eventsDatabase/eventsDatabase.d.ts +1 -1
- package/dist/eventsDatabase/eventsDatabase.d.ts.map +1 -1
- package/dist/eventsDatabase/eventsDatabase.js +8 -37
- package/dist/eventsDatabase/eventsDatabase.js.map +1 -1
- package/package.json +6 -6
- package/typedoc.config.js +13 -0
- package/vite.cjs.config.ts +13 -0
|
@@ -35,39 +35,13 @@ try {
|
|
|
35
35
|
} catch (error) {
|
|
36
36
|
CaptchaEvent = mongoose.model("CaptchaEvent", captchaEventSchema);
|
|
37
37
|
}
|
|
38
|
-
const addCaptchaEventRecord = async (record) => {
|
|
39
|
-
try {
|
|
40
|
-
const newRecord = new CaptchaEvent(record);
|
|
41
|
-
await newRecord.save();
|
|
42
|
-
logger.info("Record added successfully");
|
|
43
|
-
} catch (error) {
|
|
44
|
-
logger.error("Error adding record to the database:", error);
|
|
45
|
-
}
|
|
46
|
-
};
|
|
47
38
|
const saveCaptchaEvent = async (events, accountId, atlasUri) => {
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
reject(
|
|
56
|
-
new common.ProsopoDBError("DATABASE.CONNECT_ERROR", {
|
|
57
|
-
context: { failedFuncName: saveCaptchaEvent.name, db: "events database" },
|
|
58
|
-
logger
|
|
59
|
-
})
|
|
60
|
-
);
|
|
61
|
-
} else {
|
|
62
|
-
connection?.removeAllListeners("error");
|
|
63
|
-
}
|
|
64
|
-
});
|
|
65
|
-
}
|
|
66
|
-
const captchaEventData = {
|
|
67
|
-
...events,
|
|
68
|
-
accountId
|
|
69
|
-
};
|
|
70
|
-
addCaptchaEventRecord(captchaEventData).then(() => logger.info("Captcha event data saved")).catch((error) => logger.error("Error saving captcha event data:", error)).finally(() => connection.close());
|
|
71
|
-
});
|
|
39
|
+
await mongoose.connect(atlasUri).then(() => console.log("Connected to MongoDB Atlas"));
|
|
40
|
+
const captchaEventData = {
|
|
41
|
+
...events,
|
|
42
|
+
accountId
|
|
43
|
+
};
|
|
44
|
+
await CaptchaEvent.create(captchaEventData);
|
|
45
|
+
logger.info("Mongo Saved Events");
|
|
72
46
|
};
|
|
73
47
|
exports.saveCaptchaEvent = saveCaptchaEvent;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { StoredEvents } from '@prosopo/types';
|
|
2
|
-
export declare const saveCaptchaEvent: (events: StoredEvents, accountId: string, atlasUri: string) => Promise<
|
|
2
|
+
export declare const saveCaptchaEvent: (events: StoredEvents, accountId: string, atlasUri: string) => Promise<void>;
|
|
3
3
|
//# sourceMappingURL=eventsDatabase.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"eventsDatabase.d.ts","sourceRoot":"","sources":["../../src/eventsDatabase/eventsDatabase.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"eventsDatabase.d.ts","sourceRoot":"","sources":["../../src/eventsDatabase/eventsDatabase.ts"],"names":[],"mappings":"AAaA,OAAO,EAAqB,YAAY,EAAE,MAAM,gBAAgB,CAAA;AAsChE,eAAO,MAAM,gBAAgB,WAAkB,YAAY,aAAa,MAAM,YAAY,MAAM,kBAU/F,CAAA"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { getLoggerDefault } from '@prosopo/common';
|
|
2
2
|
import mongoose from 'mongoose';
|
|
3
3
|
const logger = getLoggerDefault();
|
|
4
4
|
const MAX_RETRIES = 3;
|
|
@@ -34,42 +34,13 @@ try {
|
|
|
34
34
|
catch (error) {
|
|
35
35
|
CaptchaEvent = mongoose.model('CaptchaEvent', captchaEventSchema);
|
|
36
36
|
}
|
|
37
|
-
const addCaptchaEventRecord = async (record) => {
|
|
38
|
-
try {
|
|
39
|
-
const newRecord = new CaptchaEvent(record);
|
|
40
|
-
await newRecord.save();
|
|
41
|
-
logger.info('Record added successfully');
|
|
42
|
-
}
|
|
43
|
-
catch (error) {
|
|
44
|
-
logger.error('Error adding record to the database:', error);
|
|
45
|
-
}
|
|
46
|
-
};
|
|
47
37
|
export const saveCaptchaEvent = async (events, accountId, atlasUri) => {
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
reject(new ProsopoDBError('DATABASE.CONNECT_ERROR', {
|
|
56
|
-
context: { failedFuncName: saveCaptchaEvent.name, db: 'events database' },
|
|
57
|
-
logger: logger,
|
|
58
|
-
}));
|
|
59
|
-
}
|
|
60
|
-
else {
|
|
61
|
-
connection?.removeAllListeners('error');
|
|
62
|
-
}
|
|
63
|
-
});
|
|
64
|
-
}
|
|
65
|
-
const captchaEventData = {
|
|
66
|
-
...events,
|
|
67
|
-
accountId,
|
|
68
|
-
};
|
|
69
|
-
addCaptchaEventRecord(captchaEventData)
|
|
70
|
-
.then(() => logger.info('Captcha event data saved'))
|
|
71
|
-
.catch((error) => logger.error('Error saving captcha event data:', error))
|
|
72
|
-
.finally(() => connection.close());
|
|
73
|
-
});
|
|
38
|
+
await mongoose.connect(atlasUri).then(() => console.log('Connected to MongoDB Atlas'));
|
|
39
|
+
const captchaEventData = {
|
|
40
|
+
...events,
|
|
41
|
+
accountId,
|
|
42
|
+
};
|
|
43
|
+
await CaptchaEvent.create(captchaEventData);
|
|
44
|
+
logger.info('Mongo Saved Events');
|
|
74
45
|
};
|
|
75
46
|
//# sourceMappingURL=eventsDatabase.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"eventsDatabase.js","sourceRoot":"","sources":["../../src/eventsDatabase/eventsDatabase.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"eventsDatabase.js","sourceRoot":"","sources":["../../src/eventsDatabase/eventsDatabase.ts"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ED,MAAM,YAAY,CAAC,MAAM,CAAC,gBAAgB,CAAC,CAAA;IAC3C,MAAM,CAAC,IAAI,CAAC,oBAAoB,CAAC,CAAA;AACrC,CAAC,CAAA"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@prosopo/database",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.3",
|
|
4
4
|
"description": "Prosopo database plugins for provider",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"type": "module",
|
|
@@ -37,11 +37,11 @@
|
|
|
37
37
|
"homepage": "https://github.com/prosopo/captcha#readme",
|
|
38
38
|
"dependencies": {
|
|
39
39
|
"@polkadot/util": "12.6.1",
|
|
40
|
-
"@prosopo/captcha-contract": "0.3.
|
|
41
|
-
"@prosopo/common": "0.3.
|
|
42
|
-
"@prosopo/config": "0.3.
|
|
43
|
-
"@prosopo/types": "0.3.
|
|
44
|
-
"@prosopo/types-database": "0.3.
|
|
40
|
+
"@prosopo/captcha-contract": "0.3.3",
|
|
41
|
+
"@prosopo/common": "0.3.3",
|
|
42
|
+
"@prosopo/config": "0.3.3",
|
|
43
|
+
"@prosopo/types": "0.3.3",
|
|
44
|
+
"@prosopo/types-database": "0.3.3",
|
|
45
45
|
"mongodb": "5.8.0",
|
|
46
46
|
"mongodb-memory-server": "^8.7.2",
|
|
47
47
|
"mongoose": "^7.3.3"
|
package/typedoc.config.js
CHANGED
|
@@ -1,3 +1,16 @@
|
|
|
1
|
+
// Copyright 2021-2024 Prosopo (UK) Ltd.
|
|
2
|
+
//
|
|
3
|
+
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
// you may not use this file except in compliance with the License.
|
|
5
|
+
// You may obtain a copy of the License at
|
|
6
|
+
//
|
|
7
|
+
// http://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
+
//
|
|
9
|
+
// Unless required by applicable law or agreed to in writing, software
|
|
10
|
+
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
11
|
+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
|
+
// See the License for the specific language governing permissions and
|
|
13
|
+
// limitations under the License.
|
|
1
14
|
export default {
|
|
2
15
|
entryPoints: ['src/**/*.ts', 'src/**/*.tsx', 'src/**/*.js', 'src/**/*.jsx', 'src/**/*.json'],
|
|
3
16
|
includes: 'src',
|
package/vite.cjs.config.ts
CHANGED
|
@@ -1,3 +1,16 @@
|
|
|
1
|
+
// Copyright 2021-2024 Prosopo (UK) Ltd.
|
|
2
|
+
//
|
|
3
|
+
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
// you may not use this file except in compliance with the License.
|
|
5
|
+
// You may obtain a copy of the License at
|
|
6
|
+
//
|
|
7
|
+
// http://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
+
//
|
|
9
|
+
// Unless required by applicable law or agreed to in writing, software
|
|
10
|
+
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
11
|
+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
|
+
// See the License for the specific language governing permissions and
|
|
13
|
+
// limitations under the License.
|
|
1
14
|
import { ViteCommonJSConfig } from '@prosopo/config'
|
|
2
15
|
import path from 'path'
|
|
3
16
|
|