This repository has been archived by the owner on Nov 29, 2020. It is now read-only.
generated from dirigeants/util-ts-template
-
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
misc: Finalized SchemaEntry's tests, documented more, moved resolve m…
…ethods Co-authored-by: Vlad Frangu <kingdgrizzle@gmail.com>
- Loading branch information
1 parent
7eb7def
commit 4668d66
Showing
7 changed files
with
199 additions
and
72 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -55,21 +55,7 @@ export class GatewayStorage { | |
if (provider === null) throw new Error(`The gateway ${this.name} could not find the provider ${this._provider}.`); | ||
this.ready = true; | ||
|
||
const errors = []; | ||
for (const entry of this.schema.values(true)) { | ||
// Assign Client to all Pieces for Serializers && Type Checking | ||
entry.client = this.client; | ||
|
||
Object.freeze(entry); | ||
|
||
// Check if the entry is valid | ||
try { | ||
entry.check(); | ||
} catch (error) { | ||
errors.push(error.message); | ||
} | ||
} | ||
|
||
const errors = [...this._checkSchemaFolder(this.schema)]; | ||
if (errors.length) throw new Error(`[SCHEMA] There is an error with your schema.\n${errors.join('\n')}`); | ||
|
||
// Initialize the defaults | ||
|
@@ -112,6 +98,22 @@ export class GatewayStorage { | |
}; | ||
} | ||
|
||
private *_checkSchemaFolder(schema: Schema): IterableIterator<string> { | ||
for (const value of schema.values()) { | ||
if (value instanceof Schema) { | ||
This comment was marked as resolved.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
kyranet
Author
Member
|
||
yield* this._checkSchemaFolder(value); | ||
} else { | ||
value.client = this.client; | ||
try { | ||
value.check(); | ||
} catch (error) { | ||
yield error.message; | ||
} | ||
} | ||
} | ||
schema.ready = true; | ||
} | ||
|
||
} | ||
|
||
export interface GatewayStorageOptions { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Couldn't this just pass
true
to the values method to get a recursive iterator instead of checking if it's a schema?