cli to create invites
This commit is contained in:
parent
01f4b3743c
commit
7e4adf052c
5 changed files with 46 additions and 1 deletions
15
src/cli.js
Normal file
15
src/cli.js
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
const { Command } = require('commander');
|
||||
const program = new Command();
|
||||
|
||||
const createInviteCommand = require('./commands/createInvite');
|
||||
|
||||
program
|
||||
.version('1.0.0')
|
||||
.description('CLI for managing web app tasks');
|
||||
|
||||
program
|
||||
.command('createInvite <inviterNpub>')
|
||||
.description('Create an invite')
|
||||
.action(createInviteCommand);
|
||||
|
||||
program.parse(process.argv);
|
||||
7
src/commands/createInvite.js
Normal file
7
src/commands/createInvite.js
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
const { exec } = require('child_process');
|
||||
|
||||
const appInviteService = require('../services/appInviteService');
|
||||
|
||||
module.exports = async function createInvite(inviterNpub) {
|
||||
await appInviteService.createInvite(inviterNpub);
|
||||
};
|
||||
|
|
@ -1,3 +1,5 @@
|
|||
const uuid = require('uuid');
|
||||
|
||||
const AppInvite = require('../models/AppInvite');
|
||||
const InvitedNpub = require('../models/InvitedNpub');
|
||||
|
||||
|
|
@ -27,7 +29,17 @@ async function isAppInviteSpent(inviteUuid) {
|
|||
return false;
|
||||
}
|
||||
|
||||
async function createInvite(inviterNpub) {
|
||||
await AppInvite.create({
|
||||
uuid: uuid.v7(),
|
||||
inviter_npub: inviterNpub,
|
||||
created_at: new Date().toISOString()
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
exports.appInviteExists = appInviteExists;
|
||||
exports.getAppInvite = getAppInvite;
|
||||
exports.isAppInviteSpent = isAppInviteSpent;
|
||||
exports.createInvite = createInvite;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue