-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added support for TS, specifying controller dir on instantiation etc.…
… TS support is currently experimental!
- Loading branch information
1 parent
436b758
commit cdeb933
Showing
60 changed files
with
1,609 additions
and
53 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 |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import Core from '../System/Core'; | ||
|
||
/** | ||
* @module cerberus-mvc/Base/Controller | ||
* @class Controller | ||
* @extends Core | ||
* @description System class to give a base for creating controllers, exposing services and base methods | ||
* @author Paul Smith (ulsmith) <[email protected]> <pa.ulsmith.net> | ||
* @copyright 2020 Paul Smith (ulsmith) all rights reserved | ||
* @license MIT | ||
*/ | ||
export default abstract class Controller<T> extends Core<T> {}; |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import Core from '../System/Core'; | ||
|
||
/** | ||
* @modle cerberus-mvc/Base/Middleware | ||
* @class Middleware | ||
* @extends Core | ||
* @description System class to give a base for creating middleware, exposing services and base methods | ||
* @author Paul Smith (ulsmith) <[email protected]> <pa.ulsmith.net> | ||
* @copyright 2020 Paul Smith (ulsmith) all rights reserved | ||
* @license MIT | ||
*/ | ||
export default abstract class Middleware<T> extends Core<T> {} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
import Core from '../System/Core'; | ||
|
||
/** | ||
* @module cerberus-mvc/Base/Model | ||
* @class Model | ||
* @extends Core | ||
* @description System class to give a base for creating models, exposing the knex DB service and giving base methods | ||
* @author Paul Smith (ulsmith) <[email protected]> <pa.ulsmith.net> | ||
* @copyright 2020 Paul Smith (ulsmith) all rights reserved | ||
* @license MIT | ||
* @deprecated [Model.js] removal estimated in V1.1, switch to ModelKnex or use Model[DB Engine] for raw model access | ||
*/ | ||
export default abstract class Model<T> extends Core<T> { | ||
/** | ||
* @public @method constructor | ||
* @description Base method when instantiating class | ||
*/ | ||
constructor(dbname: string, table: string); | ||
|
||
get db(): any; | ||
|
||
get model(): any; | ||
|
||
get(id: any): any; | ||
|
||
find(where: any): any; | ||
|
||
all(): any; | ||
|
||
transaction(func: any): any; | ||
|
||
insert(data: any, returning: any): any; | ||
|
||
transactInsert(trx: any, data: any, returning: any): any; | ||
|
||
update(where: any, data: any, returning: any): any; | ||
|
||
transactUpdate(trx: any, where: any, data: any, returning: any): any; | ||
|
||
delete(id: any): any; | ||
|
||
transactDelete(trx: any, id: any): any; | ||
|
||
softDelete(id: any): any; | ||
|
||
softRestore(id: any): any; | ||
|
||
mapDataToColumn(data: any, partial: any): any; | ||
|
||
mapDataArrayToColumn(data: any, partial: any): any; | ||
|
||
parseError(error: any): any; | ||
|
||
checkColumnsStrict(data: any): any; | ||
|
||
private cleanIncommingData(data: any): any; | ||
} |
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 |
---|---|---|
@@ -0,0 +1,118 @@ | ||
import Core from '../System/Core'; | ||
import Dynamo from '../Service/Dynamo'; | ||
|
||
/** | ||
* @module cerberus-mvc/Base/ModelDynamo | ||
* @class ModelDynamo | ||
* @extends Core | ||
* @description System class to give a base for creating dynamo models | ||
* @author Paul Smith (ulsmith) <[email protected]> <pa.ulsmith.net> | ||
* @copyright 2020 Paul Smith (ulsmith) all rights reserved | ||
* @license MIT | ||
*/ | ||
export default abstract class ModelDynamo<T = object> extends Core<T> { | ||
|
||
public dbname: string; | ||
public params: object; | ||
|
||
/** | ||
* @public @method constructor | ||
* @description Base method when instantiating class | ||
*/ | ||
constructor(dbname: ModelDynamo['dbname'], table: string, params: ModelDynamo['params']) | ||
|
||
/** | ||
* @public @get dynamo | ||
* @desciption Get the services available to the system | ||
* @return {Knex} Knex service abstracted to dynamo | ||
*/ | ||
get dynamo(): Dynamo['dynamo']; | ||
|
||
/** | ||
* @public @get db | ||
* @desciption Get the services available to the system | ||
* @return {Knex} Knex service abstracted to db | ||
*/ | ||
get db(): Dynamo['client']; | ||
|
||
/** | ||
* @public @method create | ||
* @description Create a new table resource | ||
* @return {Promise} a resulting promise of data or error on failure | ||
* @example | ||
* let dynamoSource = new DynamoSourceModel(); | ||
* return dynamoSource.createTable(); | ||
*/ | ||
createTable(): Promise<any>; | ||
|
||
/** | ||
* @public @method get | ||
* @description Get a single resource in a single table by table id | ||
* @param {Mixed} key The key to the resource as a literal string/number (mapping to one key schema) or an object as Keys matching key schema ({ id: 123456, something: 'else' }) | ||
* @return {Promise} a resulting promise of data or error on failure | ||
* @example | ||
* let dynamoSource = new DynamoSourceModel(); | ||
* return dynamoSource.get('6ff98823-3c0b-4b09-a433-63fc55cfa6d0'); | ||
*/ | ||
get<T>(key: string | number | T): Promise<T>; | ||
|
||
/** | ||
* @public @method put | ||
* @description Put a single resource into dynamo table | ||
* @param {Object} item The data to put into the resource | ||
* @return {Promise} a resulting promise of data or error on failure | ||
* @example | ||
* let dynamoSource = new DynamoSourceModel(); | ||
* return dynamoSource.put({ | ||
* id: '6ff98823-3c0b-4b09-a433-63fc55cfa6d0', | ||
* product: [ | ||
* { | ||
* title: 'Title Two', | ||
* description: 'Description two... more stuff' | ||
* } | ||
* ], | ||
* filter: { | ||
* z: 'zzz' | ||
* } | ||
* }); | ||
*/ | ||
put<T>(item: T): Promise<T>; | ||
|
||
/** | ||
* @public @method update | ||
* @description Update a single resource in dynamo table | ||
* @param {Mixed} key The key to the resource as a literal string/number (mapping to one key schema) or an object as Keys matching key schema ({ id: 123456, something: 'else' }) | ||
* @param {Object} item The data to update in the resource { "some.path.to.property": "new value" } | ||
* @return {Promise} a resulting promise of data or error on failure | ||
* @example | ||
* let dynamoSource = new DynamoSourceModel(); | ||
* return dynamoSource.update('9ff98823-3c0b-4b09-a433-63fc55cfa6d0', { | ||
* product: [ | ||
* { | ||
* title: 'Title Two', | ||
* description: 'Description two... more stuff' | ||
* } | ||
* ] | ||
* }); | ||
*/ | ||
update<T>(key: string | number | T, item: T): Promise<T>; | ||
|
||
/** | ||
* @public @method listAppend | ||
* @description Append item to a property list in dynamo table | ||
* @param {Mixed} key The key to the resource as a literal string/number (mapping to one key schema) or an object as Keys matching key schema ({ id: 123456, something: 'else' }) | ||
* @param {Mixed} item The data to append in the resource { "some.path.to.property": "new value" } | ||
* @return {Promise} a resulting promise of data or error on failure | ||
* @example | ||
* let dynamoSource = new DynamoSourceModel(); | ||
* return dynamoSource.listAppend('9ff98823-3c0b-4b09-a433-63fc55cfa6d0', { | ||
* product: [ | ||
* { | ||
* title: 'Title Two', | ||
* description: 'Description two... more stuff' | ||
* } | ||
* ] | ||
* }); | ||
*/ | ||
listAppend<T>(key: string | number | T, item: T): Promise<T>; | ||
} |
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 |
---|---|---|
|
@@ -4,8 +4,8 @@ const Core = require('cerberus-mvc/System/Core.js'); | |
const ModelError = require('cerberus-mvc/Error/Model.js'); | ||
|
||
/** | ||
* @namespace MVC/Base | ||
* @class Model | ||
* @module cerberus-mvc/Base/ModelDynamo | ||
* @class ModelDynamo | ||
* @extends Core | ||
* @description System class to give a base for creating dynamo models | ||
* @author Paul Smith (ulsmith) <[email protected]> <pa.ulsmith.net> | ||
|
Oops, something went wrong.