pass constants to nostr service
This commit is contained in:
parent
9f4bc729e2
commit
73a71d3ccb
2 changed files with 11 additions and 6 deletions
|
|
@ -1,3 +1,5 @@
|
|||
const constants = require('../constants');
|
||||
|
||||
class ServicesProvider {
|
||||
constructor() {}
|
||||
|
||||
|
|
@ -9,7 +11,9 @@ class ServicesProvider {
|
|||
*/
|
||||
|
||||
const NostrServiceProvider = require('../services/nostrService');
|
||||
const nostrService = new NostrServiceProvider().provide();
|
||||
const nostrService = new NostrServiceProvider({
|
||||
constants: constants,
|
||||
}).provide();
|
||||
const InvitesServiceProvider = require('../services/invitesService');
|
||||
const invitesService = new InvitesServiceProvider({
|
||||
nostrService,
|
||||
|
|
|
|||
|
|
@ -5,19 +5,20 @@ const { verifyEvent } = require('nostr-tools');
|
|||
|
||||
const models = require('../models');
|
||||
|
||||
const constants = require('../constants');
|
||||
const errors = require('../errors');
|
||||
|
||||
class NostrServiceProvider {
|
||||
constructor() {}
|
||||
constructor({ constants }) {
|
||||
this.constants = constants;
|
||||
}
|
||||
|
||||
provide() {
|
||||
async function createNostrChallenge() {
|
||||
const createNostrChallenge = async () => {
|
||||
const currentTimestamp = new Date();
|
||||
const expiryTimestamp = new Date(currentTimestamp.getTime());
|
||||
expiryTimestamp.setSeconds(
|
||||
expiryTimestamp.getSeconds() +
|
||||
constants.DEFAULT_NOSTR_CHALLENGE_DURATION_SECONDS
|
||||
this.constants.DEFAULT_NOSTR_CHALLENGE_DURATION_SECONDS
|
||||
);
|
||||
|
||||
const nostrChallenge = await models.NostrChallengeCreated.create({
|
||||
|
|
@ -28,7 +29,7 @@ class NostrServiceProvider {
|
|||
});
|
||||
|
||||
return nostrChallenge;
|
||||
}
|
||||
};
|
||||
|
||||
async function getNostrChallenge(
|
||||
nostrChallengeUuid = null,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue