add membership features endpoint and use it in mobile
This commit is contained in:
1 parent
091cb5ba85
commit
50ece15089
4 files changed
+90
-6
No files matched your search
@@ -0,0 +1,32 @@
|
||||
import { NextResponse } from "next/server";
|
||||
import { auth } from "@clerk/nextjs/server";
|
||||
import { MEMBERSHIP_FEATURES } from "@/lib/membership/features";
|
||||
import { getUserMembershipContext } from "@/lib/membership/access";
|
||||
|
||||
export async function GET() {
|
||||
try {
|
||||
const { userId } = await auth();
|
||||
if (!userId) {
|
||||
return NextResponse.json({ error: "Unauthorized" }, { status: 401 });
|
||||
}
|
||||
|
||||
const { membershipType, features } = await getUserMembershipContext(userId);
|
||||
|
||||
return NextResponse.json({
|
||||
success: true,
|
||||
data: {
|
||||
membershipType,
|
||||
currentFeatures: features,
|
||||
plans: MEMBERSHIP_FEATURES,
|
||||
},
|
||||
meta: {
|
||||
timestamp: new Date().toISOString(),
|
||||
},
|
||||
});
|
||||
} catch {
|
||||
return NextResponse.json(
|
||||
{ error: "Failed to load membership features" },
|
||||
{ status: 500 },
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user