11import { NextRequest , NextResponse } from "next/server" ;
22import { getSupabaseAdmin } from "@/lib/supabase" ;
33import { getAuthenticatedRequestUser } from "@/lib/api-auth" ;
4- import { normalizeConfigSchema } from "@profullstack/pluginstore" ;
4+ import { createPluginInstallPayload } from "@profullstack/pluginstore" ;
55
66type RouteContext = { params : Promise < { slug : string } > } ;
77
88const MODULE_INSTALL_COLUMNS =
99 "id, name, slug, version, downloads, git_url, npm_package, tarball_url, min_threatcrush_version, os_support, license, config_schema, config_notes" ;
1010
11- function installPayload ( mod : {
12- id ?: string ;
13- name : string ;
14- slug : string ;
15- version : string ;
16- downloads ?: number | null ;
17- git_url ?: string | null ;
18- npm_package ?: string | null ;
19- tarball_url ?: string | null ;
20- min_threatcrush_version ?: string | null ;
21- os_support ?: string [ ] | null ;
22- license ?: string | null ;
23- config_schema ?: unknown ;
24- config_notes ?: string | null ;
25- } ) {
26- return {
27- name : mod . name ,
28- slug : mod . slug ,
29- version : mod . version ,
30- downloads : mod . downloads || 0 ,
31- license : mod . license ,
32- min_threatcrush_version : mod . min_threatcrush_version ,
33- min_version : mod . min_threatcrush_version ,
34- os_support : mod . os_support ,
35- config_schema : normalizeConfigSchema ( mod . config_schema ) ,
36- config_notes : mod . config_notes || null ,
37- install : {
38- npm_package : mod . npm_package || null ,
39- git_url : mod . git_url || null ,
40- tarball_url : mod . tarball_url || null ,
41- } ,
42- } ;
43- }
44-
4511/**
4612 * GET /api/modules/[slug]/install
4713 * Query module install info without incrementing download count.
@@ -65,7 +31,7 @@ export async function GET(
6531 }
6632
6733 return NextResponse . json ( {
68- module : installPayload ( mod ) ,
34+ module : createPluginInstallPayload ( mod ) ,
6935 } ) ;
7036}
7137
@@ -133,6 +99,6 @@ export async function POST(
13399 success : true ,
134100 downloads : newCount ,
135101 installed : ! ! user ,
136- module : installPayload ( { ...mod , downloads : newCount } ) ,
102+ module : createPluginInstallPayload ( { ...mod , downloads : newCount } ) ,
137103 } ) ;
138104}
0 commit comments