fix: resolve Prettier markdown code block parsing errors

- Fix syntax errors in skills markdown files (.github/skills, .opencode/skills)
- Change typescript to tsx for code blocks with JSX
- Replace ellipsis (...) in array examples with valid syntax
- Separate CSS from TypeScript into distinct code blocks
- Convert JavaScript object examples to valid JSON in docs
- Fix enum definitions with proper comma separation
This commit is contained in:
2026-01-20 21:09:29 +01:00
parent 7932fe7386
commit cd05fc8648
177 changed files with 5042 additions and 5541 deletions

View File

@@ -1,17 +1,17 @@
import type { CompanyStatus } from "@prisma/client";
import { type NextRequest, NextResponse } from "next/server";
import { getServerSession } from "next-auth";
import { platformAuthOptions } from "../../../../lib/platform-auth";
import { prisma } from "../../../../lib/prisma";
export const dynamic = "force-dynamic";
import {
getAuthenticatedPlatformUser,
hasPlatformAccess,
} from "@/lib/auth/server";
import { prisma } from "@/lib/prisma";
// GET /api/platform/companies - List all companies
export async function GET(request: NextRequest) {
try {
const session = await getServerSession(platformAuthOptions);
const { user } = await getAuthenticatedPlatformUser();
if (!session?.user?.isPlatformUser) {
if (!user) {
return NextResponse.json(
{ error: "Platform access required" },
{ status: 401 }
@@ -86,12 +86,9 @@ export async function GET(request: NextRequest) {
// POST /api/platform/companies - Create new company
export async function POST(request: NextRequest) {
try {
const session = await getServerSession(platformAuthOptions);
const { user } = await getAuthenticatedPlatformUser();
if (
!session?.user?.isPlatformUser ||
session.user.platformRole === "SUPPORT"
) {
if (!user || !hasPlatformAccess(user.role, "PLATFORM_ADMIN")) {
return NextResponse.json(
{ error: "Admin access required" },
{ status: 403 }
@@ -106,7 +103,6 @@ export async function POST(request: NextRequest) {
csvPassword,
adminEmail,
adminName,
adminPassword,
maxUsers = 10,
status = "TRIAL",
} = body;
@@ -125,15 +121,7 @@ export async function POST(request: NextRequest) {
);
}
// Generate password if not provided
const finalAdminPassword =
adminPassword || `Temp${Math.random().toString(36).slice(2, 8)}!`;
// Hash the admin password
const bcrypt = await import("bcryptjs");
const hashedPassword = await bcrypt.hash(finalAdminPassword, 12);
// Create company and admin user in a transaction
// Create company and admin user placeholder in a transaction
const result = await prisma.$transaction(async (tx) => {
// Create the company
const company = await tx.company.create({
@@ -147,24 +135,19 @@ export async function POST(request: NextRequest) {
},
});
// Create the admin user
// Create the admin user placeholder (they'll complete signup via Neon Auth)
const adminUser = await tx.user.create({
data: {
email: adminEmail,
password: hashedPassword,
name: adminName,
role: "ADMIN",
companyId: company.id,
invitedBy: session.user.email || "platform",
invitedBy: user.email,
invitedAt: new Date(),
},
});
return {
company,
adminUser,
generatedPassword: adminPassword ? null : finalAdminPassword,
};
return { company, adminUser };
});
return NextResponse.json(
@@ -175,7 +158,8 @@ export async function POST(request: NextRequest) {
name: result.adminUser.name,
role: result.adminUser.role,
},
generatedPassword: result.generatedPassword,
// User should sign up via /auth/sign-up with this email
signupUrl: "/auth/sign-up",
},
{ status: 201 }
);