feat: add owner query endpoint

This commit is contained in:
Alexis Tyler
2021-04-14 21:28:47 +09:30
parent 6d71ae6d03
commit f3db1b022c
3 changed files with 24 additions and 1 deletions
+2
View File
@@ -5,6 +5,7 @@
import display from './display';
import info from './info';
import online from './online';
import owner from './owner';
import server from './server';
import servers from './servers';
import vms from './vms';
@@ -13,6 +14,7 @@ export const Query = {
display,
info,
online,
owner,
vms,
server,
servers
+21
View File
@@ -0,0 +1,21 @@
/*!
* Copyright 2021 Lime Technology Inc. All rights reserved.
* Written by: Alexis Tyler
*/
import { ensurePermission } from '../../../core/utils';
import { Context, getServers } from '../../schema/utils';
export default async (_: unknown, __: unknown, context: Context) => {
ensurePermission(context.user, {
resource: 'owner',
action: 'read',
possession: 'any'
});
// Get all servers
const servers = await getServers();
// Return the owner of the first
return servers[0].owner;
};
+1 -1
View File
@@ -84,7 +84,7 @@ export const getServers = async (): Promise<Server[]> => {
const name = varState?.data?.name;
const wanip = null;
const lanip: string = networkState.data[0].ipaddr[0];
const port: string = varState?.data?.port;
const port = varState?.data?.port;
const localurl = `http://${lanip}:${port}`;
const remoteurl = null;