more renaming
This commit is contained in:
parent
a958842bf6
commit
f42ae5fc1d
6 changed files with 22 additions and 22 deletions
|
|
@ -1,15 +1,15 @@
|
||||||
const { Command } = require('commander');
|
const { Command } = require('commander');
|
||||||
const program = new Command();
|
const program = new Command();
|
||||||
|
|
||||||
const createInviteCommand = require('./commands/createInvite');
|
const createAppInviteCommand = require('./commands/createAppInvite');
|
||||||
|
|
||||||
program
|
program
|
||||||
.version('1.0.0')
|
.version('1.0.0')
|
||||||
.description('CLI for managing web app tasks');
|
.description('CLI for managing web app tasks');
|
||||||
|
|
||||||
program
|
program
|
||||||
.command('createInvite <inviterNpub>')
|
.command('createAppInvite <inviterNpub>')
|
||||||
.description('Create an invite')
|
.description('Create an invite')
|
||||||
.action(createInviteCommand);
|
.action(createAppInviteCommand);
|
||||||
|
|
||||||
program.parse(process.argv);
|
program.parse(process.argv);
|
||||||
7
src/commands/createAppInvite.js
Normal file
7
src/commands/createAppInvite.js
Normal file
|
|
@ -0,0 +1,7 @@
|
||||||
|
const { exec } = require('child_process');
|
||||||
|
|
||||||
|
const appInviteService = require('../services/appInviteService');
|
||||||
|
|
||||||
|
module.exports = async function createAppInvite(inviterNpub) {
|
||||||
|
await appInviteService.createAppInvite(inviterNpub);
|
||||||
|
};
|
||||||
|
|
@ -1,7 +0,0 @@
|
||||||
const { exec } = require('child_process');
|
|
||||||
|
|
||||||
const appInviteService = require('../services/appInviteService');
|
|
||||||
|
|
||||||
module.exports = async function createInvite(inviterNpub) {
|
|
||||||
await appInviteService.createInvite(inviterNpub);
|
|
||||||
};
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
const { DataTypes } = require('sequelize');
|
const { DataTypes } = require('sequelize');
|
||||||
const sequelize = require('../database');
|
const sequelize = require('../database');
|
||||||
|
|
||||||
const Session = sequelize.define('Session', {
|
const SessionCreated = sequelize.define('SessionCreated', {
|
||||||
uuid: {
|
uuid: {
|
||||||
type: DataTypes.UUID,
|
type: DataTypes.UUID,
|
||||||
allowNull: false,
|
allowNull: false,
|
||||||
|
|
@ -17,7 +17,7 @@ const Session = sequelize.define('Session', {
|
||||||
allowNull: false
|
allowNull: false
|
||||||
}
|
}
|
||||||
}, {
|
}, {
|
||||||
tableName: 'session'
|
tableName: 'session_created'
|
||||||
});
|
});
|
||||||
|
|
||||||
module.exports = Session;
|
module.exports = SessionCreated;
|
||||||
|
|
@ -1,10 +1,10 @@
|
||||||
const uuid = require('uuid');
|
const uuid = require('uuid');
|
||||||
|
|
||||||
const AppInvite = require('../models/AppInvite');
|
const AppInviteCreated = require('../models/AppInviteCreated');
|
||||||
const InvitedNpub = require('../models/InvitedNpub');
|
const InvitedNpub = require('../models/InvitedNpub');
|
||||||
|
|
||||||
async function appInviteExists(inviteUuid) {
|
async function appInviteExists(inviteUuid) {
|
||||||
const invite = await AppInvite.findOne({ where: { uuid: inviteUuid } });
|
const invite = await AppInviteCreated.findOne({ where: { uuid: inviteUuid } });
|
||||||
if (invite) {
|
if (invite) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
@ -12,7 +12,7 @@ async function appInviteExists(inviteUuid) {
|
||||||
}
|
}
|
||||||
|
|
||||||
async function getAppInvite(inviteUuid) {
|
async function getAppInvite(inviteUuid) {
|
||||||
const invite = await AppInvite.findOne({ where: { uuid: inviteUuid } });
|
const invite = await AppInviteCreated.findOne({ where: { uuid: inviteUuid } });
|
||||||
return invite;
|
return invite;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -29,8 +29,8 @@ async function isAppInviteSpent(inviteUuid) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
async function createInvite(inviterNpub) {
|
async function createAppInvite(inviterNpub) {
|
||||||
await AppInvite.create({
|
await AppInviteCreated.create({
|
||||||
uuid: uuid.v7(),
|
uuid: uuid.v7(),
|
||||||
inviter_npub: inviterNpub,
|
inviter_npub: inviterNpub,
|
||||||
created_at: new Date().toISOString()
|
created_at: new Date().toISOString()
|
||||||
|
|
@ -42,4 +42,4 @@ async function createInvite(inviterNpub) {
|
||||||
exports.appInviteExists = appInviteExists;
|
exports.appInviteExists = appInviteExists;
|
||||||
exports.getAppInvite = getAppInvite;
|
exports.getAppInvite = getAppInvite;
|
||||||
exports.isAppInviteSpent = isAppInviteSpent;
|
exports.isAppInviteSpent = isAppInviteSpent;
|
||||||
exports.createInvite = createInvite;
|
exports.createAppInvite = createAppInvite;
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
const uuid = require("uuid");
|
const uuid = require("uuid");
|
||||||
|
|
||||||
const Session = require('../models/Session');
|
const SessionCreated = require('../models/SessionCreated');
|
||||||
const SessionNpubbed = require('../models/SessionNpubbed');
|
const SessionNpubbed = require('../models/SessionNpubbed');
|
||||||
|
|
||||||
const invitedNpubService = require('./invitedNpubService');
|
const invitedNpubService = require('./invitedNpubService');
|
||||||
|
|
@ -12,7 +12,7 @@ async function createSession(sessionUuid) {
|
||||||
const expiryTimestamp = new Date(currentTimestamp.getTime());
|
const expiryTimestamp = new Date(currentTimestamp.getTime());
|
||||||
expiryTimestamp.setSeconds(expiryTimestamp.getSeconds() + constants.DEFAULT_SESSION_DURATION_SECONDS);
|
expiryTimestamp.setSeconds(expiryTimestamp.getSeconds() + constants.DEFAULT_SESSION_DURATION_SECONDS);
|
||||||
|
|
||||||
await Session.create({
|
await SessionCreated.create({
|
||||||
uuid: sessionUuid,
|
uuid: sessionUuid,
|
||||||
created_at: currentTimestamp.toISOString(),
|
created_at: currentTimestamp.toISOString(),
|
||||||
expires_at: expiryTimestamp.toISOString()
|
expires_at: expiryTimestamp.toISOString()
|
||||||
|
|
@ -20,7 +20,7 @@ async function createSession(sessionUuid) {
|
||||||
}
|
}
|
||||||
|
|
||||||
async function isSessionExpired(sessionUuid) {
|
async function isSessionExpired(sessionUuid) {
|
||||||
const currentSession = await Session.findOne({
|
const currentSession = await SessionCreated.findOne({
|
||||||
where: {
|
where: {
|
||||||
'uuid': sessionUuid
|
'uuid': sessionUuid
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue