Setting up the model resolution design.
This commit is contained in:
@@ -7,7 +7,7 @@ export interface Distribution {
|
||||
/**
|
||||
* Global settings for Discord Rich Presence.
|
||||
*/
|
||||
discord: {
|
||||
discord?: {
|
||||
/**
|
||||
* Client ID for the Application registered with Discord.
|
||||
*/
|
||||
@@ -41,7 +41,7 @@ export interface Server {
|
||||
/**
|
||||
* Server specific settings used for Discord Rich Presence.
|
||||
*/
|
||||
discord: {
|
||||
discord?: {
|
||||
/**
|
||||
* Short ID for the server. Displayed on the second status line as Server: shortId.
|
||||
*/
|
||||
25
src/model/struct/distribution.struct.ts
Normal file
25
src/model/struct/distribution.struct.ts
Normal file
@@ -0,0 +1,25 @@
|
||||
import { Distribution } from '../spec/distribution'
|
||||
import { ModelStructure } from './model.struct'
|
||||
import { ServerStructure } from './server.struct'
|
||||
|
||||
export class DistributionStructure implements ModelStructure<Distribution> {
|
||||
|
||||
private servers: ServerStructure[] | undefined
|
||||
|
||||
constructor(
|
||||
private root: string
|
||||
) {}
|
||||
|
||||
public getServers() {
|
||||
return new ServerStructure(this.root).getSpecModel()
|
||||
}
|
||||
|
||||
public getSpecModel(): Distribution {
|
||||
return {
|
||||
version: '1.0.0',
|
||||
rss: 'TODO',
|
||||
servers: this.getServers()
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
5
src/model/struct/model.struct.ts
Normal file
5
src/model/struct/model.struct.ts
Normal file
@@ -0,0 +1,5 @@
|
||||
export interface ModelStructure<T> {
|
||||
|
||||
getSpecModel(): T
|
||||
|
||||
}
|
||||
25
src/model/struct/server.struct.ts
Normal file
25
src/model/struct/server.struct.ts
Normal file
@@ -0,0 +1,25 @@
|
||||
import { resolve } from 'path'
|
||||
import { Server } from '../spec/server'
|
||||
import { ModelStructure } from './model.struct'
|
||||
|
||||
export class ServerStructure implements ModelStructure<Server[]> {
|
||||
|
||||
private servers: Server[] | undefined
|
||||
|
||||
constructor(
|
||||
private root: string
|
||||
) {}
|
||||
|
||||
public getSpecModel(): Server[] {
|
||||
if (this.servers == null) {
|
||||
this.servers = this._doSeverRetrieval()
|
||||
}
|
||||
return this.servers
|
||||
}
|
||||
|
||||
private _doSeverRetrieval(): Server[] {
|
||||
const base = resolve(this.root, 'servers')
|
||||
return [] // TODO
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user