Implement CLI commands and admin API endpoints

- Add bootstrap command with direct DB access for initial setup
- Implement auth login/logout/status CLI commands
- Implement user create/confirm-email CLI commands
- Implement org create/list/add-site CLI commands
- Add admin.orgs.* and admin.users.* API endpoints
- Add password hashing utility with scrypt
- Add token hashing and authentication utility
- Add superuser runtime checks for admin endpoints
- Wrap multi-step operations in transactions
- Fix config file permissions (0o600) for security
- Remove token display from status command
- Add return statements to void handlers
- Add reviq CLI command to devenv

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
RevIQ
2026-01-09 15:30:10 +08:00
parent 30ee35b25c
commit 410b937f9f
20 changed files with 1267 additions and 85 deletions

View File

@@ -1,15 +1,61 @@
import type { LocalContext } from "../../context.js";
import { buildCommand } from "@stricli/core";
import { createApiClient } from "../../utils/api-client.js";
function create(this: LocalContext): void {
console.log("Org create command - Not implemented");
console.log("This command will create a new organization");
interface CreateOrgFlags {
slug: string;
name: string;
owner: string;
}
async function create(
this: LocalContext,
flags: CreateOrgFlags,
): Promise<void> {
try {
const client = await createApiClient();
const result = await client.call<{ slug: string }>("admin.orgs.create", {
slug: flags.slug,
displayName: flags.name,
ownerEmail: flags.owner,
});
console.log(`Created org: ${result.slug}`);
console.log(`Owner: ${flags.owner}`);
} catch (error) {
console.error(
"Error:",
error instanceof Error ? error.message : String(error),
);
this.process.exit(1);
}
}
export const createCommand = buildCommand({
func: create,
parameters: {},
parameters: {
flags: {
slug: {
kind: "parsed",
parse: String,
brief: "URL-friendly slug for the org",
},
name: {
kind: "parsed",
parse: String,
brief: "Display name for the org",
},
owner: {
kind: "parsed",
parse: String,
brief: "Email of the org owner",
},
},
},
docs: {
brief: "Create an organization",
fullDescription:
"Creates a new organization with the specified owner via the admin API.",
},
});