mirror of
https://github.com/Lifeforge-app/lifeforge.git
synced 2026-06-27 22:36:06 +00:00
feat(server): add checkModuleAvailability endpoint and contracts
This commit is contained in:
@@ -2419,6 +2419,36 @@ export const contract = {
|
||||
}
|
||||
},
|
||||
"modules": {
|
||||
"checkModuleAvailability": {
|
||||
"method": "get",
|
||||
"description": "Check if a module is available (installed)",
|
||||
"noAuth": false,
|
||||
"encrypted": true,
|
||||
"isDownloadable": false,
|
||||
"media": null,
|
||||
"input": {
|
||||
"query": {
|
||||
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"moduleId": {
|
||||
"type": "string",
|
||||
"minLength": 1
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"moduleId"
|
||||
],
|
||||
"additionalProperties": false
|
||||
}
|
||||
},
|
||||
"output": {
|
||||
"OK": {
|
||||
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
||||
"type": "boolean"
|
||||
}
|
||||
}
|
||||
},
|
||||
"list": {
|
||||
"method": "get",
|
||||
"description": "List installed modules with metadata",
|
||||
|
||||
@@ -2419,6 +2419,36 @@ export const contract = {
|
||||
}
|
||||
},
|
||||
"modules": {
|
||||
"checkModuleAvailability": {
|
||||
"method": "get",
|
||||
"description": "Check if a module is available (installed)",
|
||||
"noAuth": false,
|
||||
"encrypted": true,
|
||||
"isDownloadable": false,
|
||||
"media": null,
|
||||
"input": {
|
||||
"query": {
|
||||
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"moduleId": {
|
||||
"type": "string",
|
||||
"minLength": 1
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"moduleId"
|
||||
],
|
||||
"additionalProperties": false
|
||||
}
|
||||
},
|
||||
"output": {
|
||||
"OK": {
|
||||
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
||||
"type": "boolean"
|
||||
}
|
||||
}
|
||||
},
|
||||
"list": {
|
||||
"method": "get",
|
||||
"description": "List installed modules with metadata",
|
||||
|
||||
@@ -8,6 +8,7 @@ import forge from '../forge'
|
||||
import scanFederatedModules, {
|
||||
type ModuleManifestEntry
|
||||
} from '../utils/scanFederatedModules'
|
||||
import { checkModulesAvailability } from '@functions/utils/checkModulesAvailability'
|
||||
|
||||
const APPS_DIR = path.join(ROOT_DIR, 'apps')
|
||||
|
||||
@@ -194,3 +195,21 @@ export const uninstall = forge
|
||||
return response.ok({ success: false, error: message })
|
||||
}
|
||||
})
|
||||
|
||||
export const checkModuleAvailability = forge
|
||||
.query({
|
||||
description: 'Check if a module is available (installed)',
|
||||
input: {
|
||||
query: z.object({
|
||||
moduleId: z.string().min(1)
|
||||
})
|
||||
},
|
||||
output: {
|
||||
OK: z.boolean()
|
||||
}
|
||||
})
|
||||
.callback(async ({ query: { moduleId }, response }) => {
|
||||
const available = await checkModulesAvailability(moduleId)
|
||||
|
||||
return response.ok(available)
|
||||
})
|
||||
Reference in New Issue
Block a user