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 program = new Command();
|
||||
|
||||
const createInviteCommand = require('./commands/createInvite');
|
||||
const createAppInviteCommand = require('./commands/createAppInvite');
|
||||
|
||||
program
|
||||
.version('1.0.0')
|
||||
.description('CLI for managing web app tasks');
|
||||
|
||||
program
|
||||
.command('createInvite <inviterNpub>')
|
||||
.command('createAppInvite <inviterNpub>')
|
||||
.description('Create an invite')
|
||||
.action(createInviteCommand);
|
||||
.action(createAppInviteCommand);
|
||||
|
||||
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 sequelize = require('../database');
|
||||
|
||||
const Session = sequelize.define('Session', {
|
||||
const SessionCreated = sequelize.define('SessionCreated', {
|
||||
uuid: {
|
||||
type: DataTypes.UUID,
|
||||
allowNull: false,
|
||||
|
|
@ -17,7 +17,7 @@ const Session = sequelize.define('Session', {
|
|||
allowNull: false
|
||||
}
|
||||
}, {
|
||||
tableName: 'session'
|
||||
tableName: 'session_created'
|
||||
});
|
||||
|
||||
module.exports = Session;
|
||||
module.exports = SessionCreated;
|
||||
|
|
@ -1,10 +1,10 @@
|
|||
const uuid = require('uuid');
|
||||
|
||||
const AppInvite = require('../models/AppInvite');
|
||||
const AppInviteCreated = require('../models/AppInviteCreated');
|
||||
const InvitedNpub = require('../models/InvitedNpub');
|
||||
|
||||
async function appInviteExists(inviteUuid) {
|
||||
const invite = await AppInvite.findOne({ where: { uuid: inviteUuid } });
|
||||
const invite = await AppInviteCreated.findOne({ where: { uuid: inviteUuid } });
|
||||
if (invite) {
|
||||
return true;
|
||||
}
|
||||
|
|
@ -12,7 +12,7 @@ async function appInviteExists(inviteUuid) {
|
|||
}
|
||||
|
||||
async function getAppInvite(inviteUuid) {
|
||||
const invite = await AppInvite.findOne({ where: { uuid: inviteUuid } });
|
||||
const invite = await AppInviteCreated.findOne({ where: { uuid: inviteUuid } });
|
||||
return invite;
|
||||
}
|
||||
|
||||
|
|
@ -29,8 +29,8 @@ async function isAppInviteSpent(inviteUuid) {
|
|||
return false;
|
||||
}
|
||||
|
||||
async function createInvite(inviterNpub) {
|
||||
await AppInvite.create({
|
||||
async function createAppInvite(inviterNpub) {
|
||||
await AppInviteCreated.create({
|
||||
uuid: uuid.v7(),
|
||||
inviter_npub: inviterNpub,
|
||||
created_at: new Date().toISOString()
|
||||
|
|
@ -42,4 +42,4 @@ async function createInvite(inviterNpub) {
|
|||
exports.appInviteExists = appInviteExists;
|
||||
exports.getAppInvite = getAppInvite;
|
||||
exports.isAppInviteSpent = isAppInviteSpent;
|
||||
exports.createInvite = createInvite;
|
||||
exports.createAppInvite = createAppInvite;
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
const uuid = require("uuid");
|
||||
|
||||
const Session = require('../models/Session');
|
||||
const SessionCreated = require('../models/SessionCreated');
|
||||
const SessionNpubbed = require('../models/SessionNpubbed');
|
||||
|
||||
const invitedNpubService = require('./invitedNpubService');
|
||||
|
|
@ -12,7 +12,7 @@ async function createSession(sessionUuid) {
|
|||
const expiryTimestamp = new Date(currentTimestamp.getTime());
|
||||
expiryTimestamp.setSeconds(expiryTimestamp.getSeconds() + constants.DEFAULT_SESSION_DURATION_SECONDS);
|
||||
|
||||
await Session.create({
|
||||
await SessionCreated.create({
|
||||
uuid: sessionUuid,
|
||||
created_at: currentTimestamp.toISOString(),
|
||||
expires_at: expiryTimestamp.toISOString()
|
||||
|
|
@ -20,7 +20,7 @@ async function createSession(sessionUuid) {
|
|||
}
|
||||
|
||||
async function isSessionExpired(sessionUuid) {
|
||||
const currentSession = await Session.findOne({
|
||||
const currentSession = await SessionCreated.findOne({
|
||||
where: {
|
||||
'uuid': sessionUuid
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue