Skip to content

Commit

Permalink
fix: prevent null reference error
Browse files Browse the repository at this point in the history
  • Loading branch information
albanm committed May 15, 2024
1 parent 122d5fa commit e3cd90f
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
6 changes: 5 additions & 1 deletion api/src/routers/plugins.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,9 @@ tmp.setGracefulCleanup()
* @property {object} access
*/

/** @typedef {import('../types.js').Access} Access */
/** @typedef {import('../types.js').PrivateAccess} PrivateAccess */

/**
* For compatibility with old plugins
* @param {PluginData} plugin
Expand Down Expand Up @@ -139,7 +142,8 @@ router.get('/', asyncHandler(async (req, res) => {
for (const dir of dirs) {
/** @type {PluginDataWithConfig} */
const pluginInfo = await fs.readJson(path.join(pluginsDir, dir, 'plugin.json'))
let access
/** @type {Access} */
let access = { public: false, privateAccess: [] }
const accessFilePath = path.join(pluginsDir, dir + '-access.json')
if (await fs.pathExists(accessFilePath)) {
access = await fs.readJson(path.join(pluginsDir, dir + '-access.json'))
Expand Down
12 changes: 12 additions & 0 deletions api/src/types.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
/* eslint-disable */

export type PrivateAccess {
type: 'user' | 'organization'
id: string
name: string
}

export type Access {
public: boolean;
privateAccess: PrivateAccess[]
}

0 comments on commit e3cd90f

Please sign in to comment.