Fleshed out API, added simple email support.
This commit is contained in:
@@ -21,6 +21,8 @@
|
||||
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
||||
const Forms = require('./../../common/Forms');
|
||||
|
||||
class APIRequest {
|
||||
constructor(handler, req, res) {
|
||||
this.handler = handler;
|
||||
@@ -32,12 +34,14 @@ class APIRequest {
|
||||
getRequest() {return this.req;}
|
||||
getResponse() {return this.res;}
|
||||
getHandleFunction() {return this.getHandler().handle;}
|
||||
getFormData(name) {return Forms[name];}
|
||||
|
||||
//Some nice shorthands
|
||||
getAPI() {return this.getHandler().getAPI();}
|
||||
getConfig() {return this.getAPI().getConfig();}
|
||||
getServer() {return this.getAPI().getServer();}
|
||||
getExpress() {return this.getAPI().getExpress();}
|
||||
getEmail() {return this.getAPI().getEmail();}
|
||||
getApp() {return this.getAPI().getApp();}
|
||||
|
||||
//Our process method
|
||||
@@ -54,7 +58,8 @@ class APIRequest {
|
||||
try {
|
||||
response = await this.getHandleFunction()(this);
|
||||
} catch(e) {
|
||||
response = { ok: false, data: ( e.message || "Unknown Error Occured" ) };
|
||||
console.error(e);
|
||||
response = { ok: false, data: "An unknown error occured" };
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user