diff --git a/cli/caddy_migrate.js b/cli/caddy_migrate.js index b982c60..c3982eb 100644 --- a/cli/caddy_migrate.js +++ b/cli/caddy_migrate.js @@ -24,7 +24,7 @@ routes.forEach(route => { } }); async function main() { - await prisma.domain.create({ + await prisma.domain.createMany({ data: set }) } diff --git a/cli/commands/caddy.js b/cli/commands/caddy.js index d4afc80..e89429e 100644 --- a/cli/commands/caddy.js +++ b/cli/commands/caddy.js @@ -10,7 +10,7 @@ module.exports = function ({ program, run }) { caddy .command('list') .description('lists all domains you have configured in caddy') - .option('--user', 'allows you to add a domain on behalf of a user (requires sudo)') + .option('--user [user]', 'allows you to add a domain on behalf of a user (requires sudo)') .action(async (options) => { if (options?.user && !isAdmin) { console.error("To change/see another user's domains, you'll need to use sudo or be root.") @@ -25,8 +25,8 @@ module.exports = function ({ program, run }) { caddy .command('add ') .description('adds a domain to caddy') - .option('--proxy', 'changes where the domain should be proxied to (advanced)') - .option('--user', "allows you to list a different user's domains (requires sudo)") + .option('--proxy [proxy]', 'changes where the domain should be proxied to (advanced)') + .option('--user [user]', "allows you to list a different user's domains (requires sudo)") .action(async (domain, options) => { if (options?.user && !isAdmin) { console.error("To change/see another user's domains, you'll need to use sudo or be root.") @@ -68,7 +68,7 @@ module.exports = function ({ program, run }) { caddy .command('rm ') .description('removes a domain from caddy') - .option('--user', 'allows you to add a domain on behalf of a user (requires sudo)') + .option('--user [user]', 'allows you to add a domain on behalf of a user (requires sudo)') .action(async (domain, options) => { if (options?.user && !isAdmin) { console.error("To change/see another user's domains, you'll need to use sudo or be root.") diff --git a/cli/commands/resources.js b/cli/commands/resources.js index 6a39ea6..e9063b5 100644 --- a/cli/commands/resources.js +++ b/cli/commands/resources.js @@ -5,6 +5,10 @@ module.exports = function ({ program, run }) { .command('resources') .description('See your Nest resource usage and limits') .action(() => { + if (!process.getuid()){ + console.log("Root doesn't have any limits.") + process.exit(0) + } const output = run(`quota`).toString(); const numbers = output.split("\n").find(line => line.includes("/dev/sda")).match(/\d+/g); const array = numbers.map(Number) diff --git a/cli/index.js b/cli/index.js index 4b84519..c4af0ae 100755 --- a/cli/index.js +++ b/cli/index.js @@ -1,4 +1,4 @@ -#!/usr/bin/env node +#!/usr/bin/env bun const { Command } = require('commander'); const program = new Command(); const { execSync } = require('child_process'); diff --git a/cli/prisma/schema.prisma b/cli/prisma/schema.prisma index 2f81120..90e8d7c 100644 --- a/cli/prisma/schema.prisma +++ b/cli/prisma/schema.prisma @@ -4,8 +4,8 @@ generator client { } datasource db { - provider = "sqlite" - url = "file:./database.sqlite" + provider = "postgresql" + url = env("DATABASE_URL") } model Domain { diff --git a/cli/utils.js b/cli/utils.js index c3c31c3..24741c7 100644 --- a/cli/utils.js +++ b/cli/utils.js @@ -8,10 +8,9 @@ const isAdmin = !process.getuid() || os.userInfo().username == "nest-internal" module.exports = { checkWhitelist: function (domain, username) { - if (!fs.existsSync(".whitelist")) return - const whitelist = fs.readFileSync(".whitelist", "utf8").split("\n") + if (!fs.existsSync(__dirname + "/.whitelist")) return + const whitelist = fs.readFileSync(__dirname + "/.whitelist", "utf8").split("\n") - whitelist var i = 0 while (i < whitelist.length) { if (minimatch(domain, whitelist[i].replace("$USERNAME", username))) return true