feat: Extend apps with further data

This commit is contained in:
Ali BARIN
2021-10-10 21:51:16 +02:00
parent 2a01407495
commit 1d65a7c0dd
14 changed files with 93 additions and 26 deletions

View File

@@ -7,7 +7,7 @@ const queryType = new GraphQLObjectType({
name: 'Query',
fields: {
getApps: {
type: GraphQLList(GraphQLString),
type: GraphQLList(appType),
args: {
name: { type: GraphQLString }
},

View File

@@ -7,6 +7,7 @@ const appType = new GraphQLObjectType({
name: { type: GraphQLString },
iconUrl: { type: GraphQLString },
docUrl: { type: GraphQLString },
primaryColor: { type: GraphQLString },
fields: { type: GraphQLList(fieldType) }
}
});

View File

@@ -1,12 +1,15 @@
import fs from 'fs';
class App {
static folderPath = __dirname + '/../apps'
static folderPath = __dirname + '/../apps';
static list = fs.readdirSync(this.folderPath);
static findAll(name?: string): string[] {
if(!name) return this.list;
return this.list.filter((app) => app.includes(name.toLowerCase()));
static findAll(name?: string): object[] {
if(!name) return this.list.map((name) => this.findOneByName(name));
return this.list
.filter((app) => app.includes(name.toLowerCase()))
.map((name) => this.findOneByName(name));
}
static findOneByName(name: string): object {