feat: get flash info

This commit is contained in:
Alexis Tyler
2021-03-03 14:27:13 +10:30
parent 371e184204
commit 332c791788
+43
View File
@@ -0,0 +1,43 @@
/*!
* Copyright 2019-2021 Lime Technology Inc. All rights reserved.
* Written by: Alexis Tyler
*/
import { varState } from '../../states';
import { CoreContext, CoreResult } from '../../types';
import { ensurePermission } from '../../utils';
/**
* Get server's flash info
*
* @memberof Core
* @module info/get-flash
*/
export const getFlash = async function (context: CoreContext): Promise<CoreResult> {
const { user } = context;
// Check permissions
ensurePermission(user, {
resource: 'flash',
action: 'read',
possession: 'any'
});
// Get flash data
const guid = varState.data.flashGuid;
const product = varState.data.flashProduct;
const vendor = varState.data.flashVendor;
return {
get text() {
return `GUID: ${guid}\nProduct: ${product}\nVendor: ${vendor}`;
},
get json() {
return {
guid,
product,
vendor
};
}
};
};