From 332c791788fc41d224050b9fb633e6be0e4923ee Mon Sep 17 00:00:00 2001 From: Alexis Tyler Date: Wed, 3 Mar 2021 14:27:13 +1030 Subject: [PATCH] feat: get flash info --- app/core/modules/info/get-flash.ts | 43 ++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 app/core/modules/info/get-flash.ts diff --git a/app/core/modules/info/get-flash.ts b/app/core/modules/info/get-flash.ts new file mode 100644 index 000000000..46b2ae751 --- /dev/null +++ b/app/core/modules/info/get-flash.ts @@ -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 { + 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 + }; + } + }; +};