cli to create invites
This commit is contained in:
parent
01f4b3743c
commit
7e4adf052c
5 changed files with 46 additions and 1 deletions
9
package-lock.json
generated
9
package-lock.json
generated
|
|
@ -9,6 +9,7 @@
|
|||
"version": "1.0.0",
|
||||
"license": "ISC",
|
||||
"dependencies": {
|
||||
"commander": "^13.1.0",
|
||||
"cookie-parser": "^1.4.7",
|
||||
"dotenv": "^16.4.7",
|
||||
"ejs": "^3.1.10",
|
||||
|
|
@ -433,6 +434,14 @@
|
|||
"color-support": "bin.js"
|
||||
}
|
||||
},
|
||||
"node_modules/commander": {
|
||||
"version": "13.1.0",
|
||||
"resolved": "https://registry.npmjs.org/commander/-/commander-13.1.0.tgz",
|
||||
"integrity": "sha512-/rFeCpNJQbhSZjGVwO9RFV3xPqbnERS8MmIQzCtD/zl6gpJuV/bMLuN92oG3F7d8oDEHHRrujSXNUr8fpjntKw==",
|
||||
"engines": {
|
||||
"node": ">=18"
|
||||
}
|
||||
},
|
||||
"node_modules/concat-map": {
|
||||
"version": "0.0.1",
|
||||
"resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz",
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@
|
|||
"name": "express-hello-world",
|
||||
"version": "1.0.0",
|
||||
"dependencies": {
|
||||
"commander": "^13.1.0",
|
||||
"cookie-parser": "^1.4.7",
|
||||
"dotenv": "^16.4.7",
|
||||
"ejs": "^3.1.10",
|
||||
|
|
@ -17,9 +18,10 @@
|
|||
"start": "node src/app.js",
|
||||
"start:containers": "docker compose up -d --build",
|
||||
"stop:containers": "docker compose down",
|
||||
"cli": "node src/cli.js",
|
||||
"test": "echo \"Error: no test specified\" && exit 1"
|
||||
},
|
||||
"keywords": [],
|
||||
"author": "",
|
||||
"license": "ISC"
|
||||
}
|
||||
}
|
||||
|
|
|
|||
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