blixify-server 0.1.14 → 0.1.16

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
1
- {"version":3,"file":"fbWrapper.d.ts","sourceRoot":"","sources":["../../src/apis/fbWrapper.ts"],"names":[],"mappings":"AAOA,OAAO,cAAc,MAAM,yBAAyB,CAAC;AACrD,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAE5C;;;GAGG;AACH,qBAAa,eAAe;IAC1B,OAAO,EAAE,GAAG,CAAM;IAClB,UAAU,SAAM;IAChB,MAAM,UAAS;IACf,MAAM,EAAE,cAAc,CAQpB;IACF,GAAG,EAAE,UAAU,CAAC;IAEhB,YAAY,QAAS,GAAG,aAEtB;gBAGA,OAAO,EAAE,GAAG,EACZ,UAAU,EAAE,MAAM,EAClB,MAAM,EAAE,OAAO,EACf,MAAM,EAAE,cAAc,EACtB,YAAY,EAAE,CAAC,GAAG,EAAE,GAAG,EAAE,MAAM,CAAC,EAAE,OAAO,KAAK,OAAO,EACrD,GAAG,EAAE,UAAU;IAUjB,UAAU,SAAU,GAAG,SAIrB;IAEF,eAAe,QAAe,GAAG,OAAO,GAAG,mBA8CzC;IAEF,UAAU,QAAe,GAAG,OAAO,GAAG,mBA8BpC;IAEF,OAAO,QAAe,GAAG,OAAO,GAAG,mBA6BjC;IAEF,eAAe,QAAe,GAAG,OAAO,GAAG,mBAoEzC;IAEF,UAAU,QAAe,GAAG,OAAO,GAAG,mBA0DpC;IAEF,eAAe,QAAe,GAAG,OAAO,GAAG,mBA8CzC;IAEF,UAAU,QAAe,GAAG,OAAO,GAAG,mBAyCpC;IAEF,QAAQ,QAAe,GAAG,OAAO,GAAG,mBAsHlC;IAEF,IAAI,YA0DF;CACH"}
1
+ {"version":3,"file":"fbWrapper.d.ts","sourceRoot":"","sources":["../../src/apis/fbWrapper.ts"],"names":[],"mappings":"AAOA,OAAO,cAAc,MAAM,yBAAyB,CAAC;AACrD,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAE5C;;;GAGG;AACH,qBAAa,eAAe;IAC1B,OAAO,EAAE,GAAG,CAAM;IAClB,UAAU,SAAM;IAChB,MAAM,UAAS;IACf,MAAM,EAAE,cAAc,CAQpB;IACF,GAAG,EAAE,UAAU,CAAC;IAEhB,YAAY,QAAS,GAAG,aAEtB;gBAGA,OAAO,EAAE,GAAG,EACZ,UAAU,EAAE,MAAM,EAClB,MAAM,EAAE,OAAO,EACf,MAAM,EAAE,cAAc,EACtB,YAAY,EAAE,CAAC,GAAG,EAAE,GAAG,EAAE,MAAM,CAAC,EAAE,OAAO,KAAK,OAAO,EACrD,GAAG,EAAE,UAAU;IAUjB,UAAU,SAAU,GAAG,SAIrB;IAEF,eAAe,QAAe,GAAG,OAAO,GAAG,mBA8CzC;IAEF,UAAU,QAAe,GAAG,OAAO,GAAG,mBA8BpC;IAEF,OAAO,QAAe,GAAG,OAAO,GAAG,mBA6BjC;IAEF,eAAe,QAAe,GAAG,OAAO,GAAG,mBAoEzC;IAEF,UAAU,QAAe,GAAG,OAAO,GAAG,mBA0DpC;IAEF,eAAe,QAAe,GAAG,OAAO,GAAG,mBA6GzC;IAEF,UAAU,QAAe,GAAG,OAAO,GAAG,mBAyCpC;IAEF,QAAQ,QAAe,GAAG,OAAO,GAAG,mBAsHlC;IAEF,IAAI,YA0DF;CACH"}
@@ -1 +1 @@
1
- "use strict";var __awaiter=this&&this.__awaiter||function(t,r,d,n){return new(d=d||Promise)(function(i,e){function s(t){try{a(n.next(t))}catch(t){e(t)}}function o(t){try{a(n.throw(t))}catch(t){e(t)}}function a(t){var e;t.done?i(t.value):((e=t.value)instanceof d?e:new d(function(t){t(e)})).then(s,o)}a((n=n.apply(t,r||[])).next())})},__importDefault=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(exports,"__esModule",{value:!0}),exports.FirebaseWrapper=void 0;const moment_1=__importDefault(require("moment")),QueryModel_1=require("../model/QueryModel");class FirebaseWrapper{constructor(t,e,i,s,o,a){this.fbAdmin="",this.collection="",this.isProd=!1,this.config={baseConfig:[],opsConfig:{read:[],create:[],update:[],delete:[]}},this.modelChecker=t=>!1,this.parseModel=t=>(delete t.id,t.baseUpdatedAt=(0,moment_1.default)().toDate(),t),this.initBatchCreate=(s,o)=>__awaiter(this,void 0,void 0,function*(){try{const i=this.fbAdmin.firestore().batch();if(Array.isArray(s.body.data)){let e=!0;if(s.body.data.map(t=>{this.modelChecker(t)||(e=!1)}),e){var t=(0,QueryModel_1.checkBaseConfig)(this.config,s);let e=!0;s.body.data.map(t=>{(0,QueryModel_1.checkOpsConfig)(this.config,"update",s,t)||(e=!1)}),t&&e?(yield Promise.all(s.body.data.map(e=>__awaiter(this,void 0,void 0,function*(){e.baseUpdatedAt=(0,moment_1.default)().toDate();var t=this.fbAdmin.firestore().collection(this.collection).doc(e.id);i.set(t,Object.assign({},e))}))),yield i.commit(),o.send({success:!0})):o.status(400).json({err:"Invalid Security Configuration"})}else o.status(400).json({err:"Invalid Model Structure"})}else o.status(400).json({err:"Invalid Fields"})}catch(t){o.status(400).json({err:t})}}),this.initCreate=(i,s)=>__awaiter(this,void 0,void 0,function*(){try{var t,e;this.modelChecker(i.body.data)?(t=(0,QueryModel_1.checkBaseConfig)(this.config,i),e=(0,QueryModel_1.checkOpsConfig)(this.config,"create",i,i.body.data),t&&e?(i.body.data.baseUpdatedAt=(0,moment_1.default)().toDate(),yield this.fbAdmin.firestore().collection(this.collection).doc(i.body.data.id).set(i.body.data),s.send({success:!0})):s.status(400).json({err:"Invalid Security Configuration"})):s.status(400).json({err:"Invalid Model Structure"})}catch(t){s.status(400).json({err:t})}}),this.initGet=(a,r)=>__awaiter(this,void 0,void 0,function*(){try{var t,e,i,s,o=a.body.id;o?(t=yield this.fbAdmin.firestore().collection(this.collection).doc(o).get()).exists&&(e=t.data(),i=(0,QueryModel_1.checkBaseConfig)(this.config,a),s=(0,QueryModel_1.checkOpsConfig)(this.config,"read",a,e),i)&&s?r.send({data:e}):r.status(400).json({err:"Invalid Security Configuration"}):r.status(400).json({err:"Invalid Fields"})}catch(t){r.status(400).json({err:t})}}),this.initBatchUpdate=(a,r)=>__awaiter(this,void 0,void 0,function*(){const o=this.fbAdmin.firestore().batch();try{if(this.modelChecker(a.body.data)&&a.body.id&&Array.isArray(a.body.id)){var t=(0,QueryModel_1.checkBaseConfig)(this.config,a);let e=!0;if(a.body.data.map(t=>{(0,QueryModel_1.checkOpsConfig)(this.config,"update",a,t)||(e=!1)}),t&&e)if(a.body.sensitive){let s=!0;yield Promise.all(a.body.id.map(i=>__awaiter(this,void 0,void 0,function*(){var t,e=yield this.fbAdmin.firestore().collection(this.collection).doc(i).get();e.exists?(e=e.data(),(0,moment_1.default)(a.body.data.baseUpdatedAt).isAfter((0,moment_1.default)(1e3*e.baseUpdatedAt.seconds))?(e=this.parseModel(a.body.data),t=this.fbAdmin.firestore().collection(this.collection).doc(i),o.update(t,Object.assign({},e))):s=!1):r.status(400).json({err:"Invalid Security Configuration"})}))),s&&(yield o.commit()),r.send({success:!0})}else{const i=this.parseModel(a.body.data);a.body.id.map(e=>__awaiter(this,void 0,void 0,function*(){var t=this.fbAdmin.firestore().collection(this.collection).doc(e);o.update(t,Object.assign({},i)),yield o.commit()}))}else r.status(400).json({err:"Invalid Security Configuration"})}}catch(t){}}),this.initUpdate=(d,n)=>__awaiter(this,void 0,void 0,function*(){try{var t,e,i,s,o,a,r=this.modelChecker(d.body.data)&&d.body.id;r?(t=(0,QueryModel_1.checkBaseConfig)(this.config,d),e=(0,QueryModel_1.checkOpsConfig)(this.config,"update",d,d.body.data),t&&e?d.body.sensitive?(i=yield this.fbAdmin.firestore().collection(this.collection).doc(r).get()).exists?(s=i.data(),(0,moment_1.default)(d.body.data.baseUpdatedAt).isAfter((0,moment_1.default)(1e3*s.baseUpdatedAt.seconds))?(o=this.parseModel(d.body.data),yield this.fbAdmin.firestore().collection(this.collection).doc(r).update(Object.assign({},o)),n.send({success:!0})):n.status(400).json({err:"Refresh Sensitive Model"})):n.status(400).json({err:"Invalid Security Configuration"}):(a=this.parseModel(d.body.data),yield this.fbAdmin.firestore().collection(this.collection).doc(r).update(Object.assign({},a)),n.send({success:!0})):n.status(400).json({err:"Invalid Security Configuration"})):n.status(400).json({err:"Invalid Model Structure"})}catch(t){n.status(400).json({err:t})}}),this.initBatchDelete=(o,a)=>__awaiter(this,void 0,void 0,function*(){try{if(Array.isArray(o.body.id)){const s=this.fbAdmin.firestore().batch();var t=yield this.fbAdmin.firestore().collection(this.collection).where("id","in",o.body.id).get(),i=(0,QueryModel_1.checkBaseConfig)(this.config,o);let e=!0;t&&t.forEach(t=>{t=t.data();(0,QueryModel_1.checkOpsConfig)(this.config,"delete",o,t)||(e=!1)}),i&&e?(yield Promise.all(o.body.id.map(e=>__awaiter(this,void 0,void 0,function*(){var t=yield this.fbAdmin.firestore().collection(this.collection).doc(e);s.delete(t)}))),yield s.commit(),a.send({success:!0})):a.status(400).json({err:"Invalid Security Configuration"})}else a.status(400).json({err:"Invalid Fields"})}catch(t){a.status(400).json({err:t})}}),this.initDelete=(a,r)=>__awaiter(this,void 0,void 0,function*(){try{var t,e,i,s,o=a.body.id;o?(t=yield this.fbAdmin.firestore().collection(this.collection).doc(o).get()).exists&&(e=t.data(),i=(0,QueryModel_1.checkBaseConfig)(this.config,a),s=(0,QueryModel_1.checkOpsConfig)(this.config,"delete",a,e),i)&&s?(yield this.fbAdmin.firestore().collection(this.collection).doc(o).delete(),r.send({success:!0})):r.status(400).json({err:"Invalid Security Configuration"}):r.status(400).json({err:"Invalid Fields"})}catch(t){r.status(400).json({err:t})}}),this.initList=(n,c)=>__awaiter(this,void 0,void 0,function*(){try{var t=(0,QueryModel_1.checkBaseConfig)(this.config,n);if(t){let o=this.fbAdmin.firestore().collection(this.collection),a="";var e=n.body.query;if(e&&0<e.length&&e.map(t=>{var e,i=null!=(e=t.queryId)?e:"",s=t.value;switch(t.type){case"search":t.searchIds&&0<t.searchIds.length&&(a=t.searchIds[0],o=o.orderBy(t.searchIds[0]).startAt(s).endAt(s+""));break;case"=":o=o.where(i,"==",s);break;case"!=":o=o.where(i,"!=",s);break;case">":o=o.where(i,">",s);break;case"<":o=o.where(i,"<",s);break;case"><":Array.isArray(s)&&2<=s.length&&(o=o.where(i,">=",s[0]).where(i,"<=",s[1]));break;case"in":o=o.where(i,"in",s)}}),n.body.limit){if(o=o.limit(n.body.limit),n.body.sort){var i=n.body.sort;if(a&&i.sortId!==a)return void c.status(400).json({err:"Invalid Search Sort Configuration"});a||(o=o.orderBy(i.sortId,"asc"===i.type?"asc":"desc"))}var s,r=yield(o=n.body.cursor?o.startAfter(n.body.cursor):o).get();let e=!0;const d=[];if(r&&r.forEach(t=>{t=t.data();d.push(t),(0,QueryModel_1.checkOpsConfig)(this.config,"read",n,t)||(e=!1)}),t&&e){let e="";if(d.length===n.body.limit){let t="id";n.body.sort&&(s=n.body.sort,t=s.sortId),e=d[n.body.limit-1][t]}c.send({data:d,count:e})}else c.status(400).json({err:"Invalid Security Configuration"})}else c.status(400).json({err:"Invalid Limit Configuration"})}else c.status(400).json({err:"Invalid Security Configuration"})}catch(t){c.status(400).json({err:t})}}),this.init=()=>{var t=this.lib.express.Router();return t.post("/create",this.initCreate),t.post("/batchCreate",this.initBatchCreate),t.post("/get",this.initGet),t.post("/update",this.initUpdate),t.post("/batchUpdate",this.initBatchUpdate),t.post("/delete",this.initDelete),t.post("/batchDelete",this.initBatchDelete),t.post("/list",this.initList),t},this.fbAdmin=t,this.collection=e,this.isProd=i,this.config=s,this.modelChecker=o,this.lib=a}}exports.FirebaseWrapper=FirebaseWrapper;
1
+ "use strict";var __awaiter=this&&this.__awaiter||function(e,a,d,n){return new(d=d||Promise)(function(i,t){function s(e){try{r(n.next(e))}catch(e){t(e)}}function o(e){try{r(n.throw(e))}catch(e){t(e)}}function r(e){var t;e.done?i(e.value):((t=e.value)instanceof d?t:new d(function(e){e(t)})).then(s,o)}r((n=n.apply(e,a||[])).next())})},__importDefault=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(exports,"__esModule",{value:!0}),exports.FirebaseWrapper=void 0;const moment_1=__importDefault(require("moment")),QueryModel_1=require("../model/QueryModel");class FirebaseWrapper{constructor(e,t,i,s,o,r){this.fbAdmin="",this.collection="",this.isProd=!1,this.config={baseConfig:[],opsConfig:{read:[],create:[],update:[],delete:[]}},this.modelChecker=e=>!1,this.parseModel=e=>(delete e.id,e.baseUpdatedAt=(0,moment_1.default)().toDate(),e),this.initBatchCreate=(s,o)=>__awaiter(this,void 0,void 0,function*(){try{const i=this.fbAdmin.firestore().batch();if(Array.isArray(s.body.data)){let t=!0;if(s.body.data.map(e=>{this.modelChecker(e)||(t=!1)}),t){var e=(0,QueryModel_1.checkBaseConfig)(this.config,s);let t=!0;s.body.data.map(e=>{(0,QueryModel_1.checkOpsConfig)(this.config,"update",s,e)||(t=!1)}),e&&t?(yield Promise.all(s.body.data.map(t=>__awaiter(this,void 0,void 0,function*(){t.baseUpdatedAt=(0,moment_1.default)().toDate();var e=this.fbAdmin.firestore().collection(this.collection).doc(t.id);i.set(e,Object.assign({},t))}))),yield i.commit(),o.send({success:!0})):o.status(400).json({err:"Invalid Security Configuration"})}else o.status(400).json({err:"Invalid Model Structure"})}else o.status(400).json({err:"Invalid Fields"})}catch(e){o.status(400).json({err:e})}}),this.initCreate=(i,s)=>__awaiter(this,void 0,void 0,function*(){try{var e,t;this.modelChecker(i.body.data)?(e=(0,QueryModel_1.checkBaseConfig)(this.config,i),t=(0,QueryModel_1.checkOpsConfig)(this.config,"create",i,i.body.data),e&&t?(i.body.data.baseUpdatedAt=(0,moment_1.default)().toDate(),yield this.fbAdmin.firestore().collection(this.collection).doc(i.body.data.id).set(i.body.data),s.send({success:!0})):s.status(400).json({err:"Invalid Security Configuration"})):s.status(400).json({err:"Invalid Model Structure"})}catch(e){s.status(400).json({err:e})}}),this.initGet=(r,a)=>__awaiter(this,void 0,void 0,function*(){try{var e,t,i,s,o=r.body.id;o?(e=yield this.fbAdmin.firestore().collection(this.collection).doc(o).get()).exists&&(t=e.data(),i=(0,QueryModel_1.checkBaseConfig)(this.config,r),s=(0,QueryModel_1.checkOpsConfig)(this.config,"read",r,t),i)&&s?a.send({data:t}):a.status(400).json({err:"Invalid Security Configuration"}):a.status(400).json({err:"Invalid Fields"})}catch(e){a.status(400).json({err:e})}}),this.initBatchUpdate=(r,a)=>__awaiter(this,void 0,void 0,function*(){const o=this.fbAdmin.firestore().batch();try{if(this.modelChecker(r.body.data)&&r.body.id&&Array.isArray(r.body.id)){var e=(0,QueryModel_1.checkBaseConfig)(this.config,r);let t=!0;if(r.body.data.map(e=>{(0,QueryModel_1.checkOpsConfig)(this.config,"update",r,e)||(t=!1)}),e&&t)if(r.body.sensitive){let s=!0;yield Promise.all(r.body.id.map(i=>__awaiter(this,void 0,void 0,function*(){var e,t=yield this.fbAdmin.firestore().collection(this.collection).doc(i).get();t.exists?(t=t.data(),(0,moment_1.default)(r.body.data.baseUpdatedAt).isAfter((0,moment_1.default)(1e3*t.baseUpdatedAt.seconds))?(t=this.parseModel(r.body.data),e=this.fbAdmin.firestore().collection(this.collection).doc(i),o.update(e,Object.assign({},t))):s=!1):a.status(400).json({err:"Invalid Security Configuration"})}))),s&&(yield o.commit()),a.send({success:!0})}else{const i=this.parseModel(r.body.data);r.body.id.map(t=>__awaiter(this,void 0,void 0,function*(){var e=this.fbAdmin.firestore().collection(this.collection).doc(t);o.update(e,Object.assign({},i)),yield o.commit()}))}else a.status(400).json({err:"Invalid Security Configuration"})}}catch(e){}}),this.initUpdate=(d,n)=>__awaiter(this,void 0,void 0,function*(){try{var e,t,i,s,o,r,a=this.modelChecker(d.body.data)&&d.body.id;a?(e=(0,QueryModel_1.checkBaseConfig)(this.config,d),t=(0,QueryModel_1.checkOpsConfig)(this.config,"update",d,d.body.data),e&&t?d.body.sensitive?(i=yield this.fbAdmin.firestore().collection(this.collection).doc(a).get()).exists?(s=i.data(),(0,moment_1.default)(d.body.data.baseUpdatedAt).isAfter((0,moment_1.default)(1e3*s.baseUpdatedAt.seconds))?(o=this.parseModel(d.body.data),yield this.fbAdmin.firestore().collection(this.collection).doc(a).update(Object.assign({},o)),n.send({success:!0})):n.status(400).json({err:"Refresh Sensitive Model"})):n.status(400).json({err:"Invalid Security Configuration"}):(r=this.parseModel(d.body.data),yield this.fbAdmin.firestore().collection(this.collection).doc(a).update(Object.assign({},r)),n.send({success:!0})):n.status(400).json({err:"Invalid Security Configuration"})):n.status(400).json({err:"Invalid Model Structure"})}catch(e){n.status(400).json({err:e})}}),this.initBatchDelete=(n,c)=>__awaiter(this,void 0,void 0,function*(){try{const d=this.fbAdmin.firestore().batch();if(Array.isArray(n.body.id)){var e=yield this.fbAdmin.firestore().collection(this.collection).where("id","in",n.body.id).get(),i=(0,QueryModel_1.checkBaseConfig)(this.config,n);let t=!0;if(e&&e.forEach(e=>{e=e.data();(0,QueryModel_1.checkOpsConfig)(this.config,"delete",n,e)||(t=!1)}),!i||!t)return void c.status(400).json({err:"Invalid Security Configuration"});yield Promise.all(n.body.id.map(t=>__awaiter(this,void 0,void 0,function*(){var e=yield this.fbAdmin.firestore().collection(this.collection).doc(t);d.delete(e)}))),yield d.commit(),c.send({success:!0})}else{let o=this.fbAdmin.firestore().collection(this.collection);var s=n.body.query,r=(s&&0<s.length&&s.map(e=>{var t,i=null!=(t=e.queryId)?t:"",s=e.value;switch(e.type){case"search":e.searchIds&&0<e.searchIds.length&&(o=o.orderBy(e.searchIds[0]).startAt(s).endAt(s+""));break;case"=":o=o.where(i,"==",s);break;case"!=":o=o.where(i,"!=",s);break;case">":o=o.where(i,">",s);break;case"<":o=o.where(i,"<",s);break;case"><":Array.isArray(s)&&2<=s.length&&(o=o.where(i,">=",s[0]).where(i,"<=",s[1]));break;case"in":o=o.where(i,"in",s)}}),yield o.get()),a=(0,QueryModel_1.checkBaseConfig)(this.config,n);let t=!0;if(r&&r.forEach(e=>{e=e.data();(0,QueryModel_1.checkOpsConfig)(this.config,"delete",n,e)||(t=!1)}),!a||!t)return void c.status(400).json({err:"Invalid Security Configuration"});r.forEach(e=>{d.delete(e.ref)}),yield d.commit()}c.send({success:!0})}catch(e){c.status(400).json({err:e})}}),this.initDelete=(r,a)=>__awaiter(this,void 0,void 0,function*(){try{var e,t,i,s,o=r.body.id;o?(e=yield this.fbAdmin.firestore().collection(this.collection).doc(o).get()).exists&&(t=e.data(),i=(0,QueryModel_1.checkBaseConfig)(this.config,r),s=(0,QueryModel_1.checkOpsConfig)(this.config,"delete",r,t),i)&&s?(yield this.fbAdmin.firestore().collection(this.collection).doc(o).delete(),a.send({success:!0})):a.status(400).json({err:"Invalid Security Configuration"}):a.status(400).json({err:"Invalid Fields"})}catch(e){a.status(400).json({err:e})}}),this.initList=(n,c)=>__awaiter(this,void 0,void 0,function*(){try{var e=(0,QueryModel_1.checkBaseConfig)(this.config,n);if(e){let o=this.fbAdmin.firestore().collection(this.collection),r="";var t=n.body.query;if(t&&0<t.length&&t.map(e=>{var t,i=null!=(t=e.queryId)?t:"",s=e.value;switch(e.type){case"search":e.searchIds&&0<e.searchIds.length&&(r=e.searchIds[0],o=o.orderBy(e.searchIds[0]).startAt(s).endAt(s+""));break;case"=":o=o.where(i,"==",s);break;case"!=":o=o.where(i,"!=",s);break;case">":o=o.where(i,">",s);break;case"<":o=o.where(i,"<",s);break;case"><":Array.isArray(s)&&2<=s.length&&(o=o.where(i,">=",s[0]).where(i,"<=",s[1]));break;case"in":o=o.where(i,"in",s)}}),n.body.limit){if(o=o.limit(n.body.limit),n.body.sort){var i=n.body.sort;if(r&&i.sortId!==r)return void c.status(400).json({err:"Invalid Search Sort Configuration"});r||(o=o.orderBy(i.sortId,"asc"===i.type?"asc":"desc"))}var s,a=yield(o=n.body.cursor?o.startAfter(n.body.cursor):o).get();let t=!0;const d=[];if(a&&a.forEach(e=>{e=e.data();d.push(e),(0,QueryModel_1.checkOpsConfig)(this.config,"read",n,e)||(t=!1)}),e&&t){let t="";if(d.length===n.body.limit){let e="id";n.body.sort&&(s=n.body.sort,e=s.sortId),t=d[n.body.limit-1][e]}c.send({data:d,count:t})}else c.status(400).json({err:"Invalid Security Configuration"})}else c.status(400).json({err:"Invalid Limit Configuration"})}else c.status(400).json({err:"Invalid Security Configuration"})}catch(e){c.status(400).json({err:e})}}),this.init=()=>{var e=this.lib.express.Router();return e.post("/create",this.initCreate),e.post("/batchCreate",this.initBatchCreate),e.post("/get",this.initGet),e.post("/update",this.initUpdate),e.post("/batchUpdate",this.initBatchUpdate),e.post("/delete",this.initDelete),e.post("/batchDelete",this.initBatchDelete),e.post("/list",this.initList),e},this.fbAdmin=e,this.collection=t,this.isProd=i,this.config=s,this.modelChecker=o,this.lib=r}}exports.FirebaseWrapper=FirebaseWrapper;
@@ -1 +1 @@
1
- {"version":3,"file":"mongoWrapper.d.ts","sourceRoot":"","sources":["../../src/apis/mongoWrapper.ts"],"names":[],"mappings":"AAOA,OAAO,cAAc,MAAM,yBAAyB,CAAC;AAErD,MAAM,WAAW,UAAU;IACzB,OAAO,CAAC,EAAE,GAAG,CAAC;CACf;AAED;;;;GAIG;AACH,qBAAa,YAAY;IACvB,OAAO,EAAE,GAAG,CAAM;IAClB,UAAU,SAAM;IAChB,MAAM,UAAS;IACf,MAAM,EAAE,cAAc,CAQpB;IACF,GAAG,EAAE,UAAU,CAAC;IAEhB,YAAY,QAAS,GAAG,aAEtB;IACF,OAAO,SAAM;gBAGX,OAAO,EAAE,GAAG,EACZ,UAAU,EAAE,MAAM,EAClB,MAAM,EAAE,OAAO,EACf,MAAM,EAAE,cAAc,EACtB,YAAY,EAAE,CAAC,GAAG,EAAE,GAAG,EAAE,MAAM,CAAC,EAAE,OAAO,KAAK,OAAO,EACrD,GAAG,EAAE,UAAU,EACf,OAAO,CAAC,EAAE,MAAM;IAYlB,UAAU,SAAU,GAAG,SAIrB;IAEF,eAAe,QAAe,GAAG,OAAO,GAAG,mBA+CzC;IAEF,UAAU,QAAe,GAAG,OAAO,GAAG,mBA6BpC;IAEF,OAAO,QAAe,GAAG,OAAO,GAAG,mBA8BjC;IAEF,eAAe,QAAe,GAAG,OAAO,GAAG,mBAuEzC;IAEF,UAAU,QAAe,GAAG,OAAO,GAAG,mBA4DpC;IAEF,eAAe,QAAe,GAAG,OAAO,GAAG,mBAyCzC;IAEF,UAAU,QAAe,GAAG,OAAO,GAAG,mBAkCpC;IAEF,QAAQ,QAAe,GAAG,OAAO,GAAG,mBA8GlC;IAEF,IAAI,YA0DF;CACH"}
1
+ {"version":3,"file":"mongoWrapper.d.ts","sourceRoot":"","sources":["../../src/apis/mongoWrapper.ts"],"names":[],"mappings":"AAOA,OAAO,cAAc,MAAM,yBAAyB,CAAC;AAErD,MAAM,WAAW,UAAU;IACzB,OAAO,CAAC,EAAE,GAAG,CAAC;CACf;AAED;;;;GAIG;AACH,qBAAa,YAAY;IACvB,OAAO,EAAE,GAAG,CAAM;IAClB,UAAU,SAAM;IAChB,MAAM,UAAS;IACf,MAAM,EAAE,cAAc,CAQpB;IACF,GAAG,EAAE,UAAU,CAAC;IAEhB,YAAY,QAAS,GAAG,aAEtB;IACF,OAAO,SAAM;gBAGX,OAAO,EAAE,GAAG,EACZ,UAAU,EAAE,MAAM,EAClB,MAAM,EAAE,OAAO,EACf,MAAM,EAAE,cAAc,EACtB,YAAY,EAAE,CAAC,GAAG,EAAE,GAAG,EAAE,MAAM,CAAC,EAAE,OAAO,KAAK,OAAO,EACrD,GAAG,EAAE,UAAU,EACf,OAAO,CAAC,EAAE,MAAM;IAYlB,UAAU,SAAU,GAAG,SAIrB;IAEF,eAAe,QAAe,GAAG,OAAO,GAAG,mBA+CzC;IAEF,UAAU,QAAe,GAAG,OAAO,GAAG,mBA6BpC;IAEF,OAAO,QAAe,GAAG,OAAO,GAAG,mBA8BjC;IAEF,eAAe,QAAe,GAAG,OAAO,GAAG,mBAuEzC;IAEF,UAAU,QAAe,GAAG,OAAO,GAAG,mBA4DpC;IAEF,eAAe,QAAe,GAAG,OAAO,GAAG,mBAoHzC;IAEF,UAAU,QAAe,GAAG,OAAO,GAAG,mBAkCpC;IAEF,QAAQ,QAAe,GAAG,OAAO,GAAG,mBA8GlC;IAEF,IAAI,YA0DF;CACH"}
@@ -1 +1 @@
1
- "use strict";var __awaiter=this&&this.__awaiter||function(t,d,n,r){return new(n=n||Promise)(function(i,e){function s(t){try{a(r.next(t))}catch(t){e(t)}}function o(t){try{a(r.throw(t))}catch(t){e(t)}}function a(t){var e;t.done?i(t.value):((e=t.value)instanceof n?e:new n(function(t){t(e)})).then(s,o)}a((r=r.apply(t,d||[])).next())})},__importDefault=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(exports,"__esModule",{value:!0}),exports.MongoWrapper=void 0;const moment_1=__importDefault(require("moment")),QueryModel_1=require("../model/QueryModel");class MongoWrapper{constructor(t,e,i,s,o,a,d){this.mongoDB="",this.collection="",this.isProd=!1,this.config={baseConfig:[],opsConfig:{read:[],create:[],update:[],delete:[]}},this.modelChecker=t=>!1,this.tableId="",this.parseModel=t=>(delete t._id,t.baseUpdatedAt=(0,moment_1.default)().toDate(),t),this.initBatchCreate=(o,a)=>__awaiter(this,void 0,void 0,function*(){try{if(Array.isArray(o.body.data)){let e=!0;o.body.data.map(t=>{this.modelChecker(t)||(e=!1)}),e||a.status(400).json({err:"Invalid Model Structure"});var t,s=(0,QueryModel_1.checkBaseConfig)(this.config,o);let i=!0;yield Promise.all(o.body.data.map(t=>{(0,QueryModel_1.checkOpsConfig)(this.config,"update",o,t)||(i=!1)})),s&&i?(t=o.body.data.map(t=>Object.assign(Object.assign({},t),{baseUpdatedAt:(0,moment_1.default)().toDate()})),yield this.mongoDB.db(this.tableId).collection(this.collection).insertMany(t),a.send({success:!0})):a.status(400).json({err:"Invalid Security Configuration"})}else a.status(400).json({err:"Invalid Fields"})}catch(t){a.status(400).json({err:t})}}),this.initCreate=(i,s)=>__awaiter(this,void 0,void 0,function*(){try{var t,e;this.modelChecker(i.body.data)?(t=(0,QueryModel_1.checkBaseConfig)(this.config,i),e=(0,QueryModel_1.checkOpsConfig)(this.config,"create",i,i.body.data),t&&e?(i.body.data.baseUpdatedAt=(0,moment_1.default)().toDate(),yield this.mongoDB.db(this.tableId).collection(this.collection).insertOne(i.body.data),s.send({success:!0})):s.status(400).json({err:"Invalid Security Configuration"})):s.status(400).json({err:"Invalid Model Structure"})}catch(t){s.status(400).json({err:t})}}),this.initGet=(o,a)=>__awaiter(this,void 0,void 0,function*(){try{var t,e,i,s=o.body.id;s?(t=yield this.mongoDB.db(this.tableId).collection(this.collection).findOne({_id:s}),e=(0,QueryModel_1.checkBaseConfig)(this.config,o),i=(0,QueryModel_1.checkOpsConfig)(this.config,"read",o,t),e&&i?a.send({data:t}):a.status(400).json({err:"Invalid Security Configuration"})):a.status(400).json({err:"Invalid Fields"})}catch(t){a.status(400).json({err:t})}}),this.initBatchUpdate=(a,d)=>__awaiter(this,void 0,void 0,function*(){try{var t=this.modelChecker(a.body.data)&&a.body.id;if(Array.isArray(a.body.id)){var s=a.body.data.map(t=>Object.assign(Object.assign({},t),{baseUpdatedAt:(0,moment_1.default)().toDate()})),i=(0,QueryModel_1.checkBaseConfig)(this.config,a);let e=!0;if(yield Promise.all(a.body.data.map(t=>{(0,QueryModel_1.checkOpsConfig)(this.config,"update",a,t)||(e=!1)})),i&&e){const o=this.mongoDB.db(this.tableId).collection(this.collection);if(a.body.sensitive){let i=!0;yield Promise.all(a.body.id.map(e=>__awaiter(this,void 0,void 0,function*(){var t=yield o.findOne({_id:e});(0,moment_1.default)(a.body.data.baseUpdatedAt).isAfter((0,moment_1.default)(t.baseUpdatedAt))?d.status(400).json({err:"Refresh Sensitive Model"}):i=!1}))),i&&(yield o.updateMany({_id:{$in:t}},{$set:Object.assign({},s)}),d.send({success:!0}))}else yield o.updateMany({_id:{$in:t}},{$set:Object.assign({},s)}),d.send({success:!0})}else d.status(400).json({err:"Invalid Security Configuration"})}}catch(t){}}),this.initUpdate=(n,r)=>__awaiter(this,void 0,void 0,function*(){try{var t,e,i,s,o,a,d=this.modelChecker(n.body.data)&&n.body.id;d?(t=(0,QueryModel_1.checkBaseConfig)(this.config,n),e=(0,QueryModel_1.checkOpsConfig)(this.config,"update",n,n.body.data),t&&e?(i=this.mongoDB.db(this.tableId).collection(this.collection),n.body.sensitive?(s=yield i.findOne({_id:d}),(0,moment_1.default)(n.body.data.baseUpdatedAt).isAfter((0,moment_1.default)(s.baseUpdatedAt))?(o=this.parseModel(n.body.data),yield i.updateOne({_id:d},{$set:Object.assign({},o)}),r.send({success:!0})):r.status(400).json({err:"Refresh Sensitive Model"})):(a=this.parseModel(n.body.data),yield i.updateOne({_id:d},{$set:Object.assign({},a)}),r.send({success:!0}))):r.status(400).json({err:"Invalid Security Configuration"})):r.status(400).json({err:"Invalid Model Structure"})}catch(t){r.status(400).json({err:t})}}),this.initBatchDelete=(a,d)=>__awaiter(this,void 0,void 0,function*(){try{if(Array.isArray(a.body.id)){var t=this.mongoDB.db(this.tableId).collection(this.collection),i=yield t.find({_id:{$in:a.body.id}}),s=(0,QueryModel_1.checkBaseConfig)(this.config,a),o=yield i.toArray();let e=!0;0<o.length&&(yield Promise.all(o.map(t=>{(0,QueryModel_1.checkOpsConfig)(this.config,"delete",a,t)||(e=!1)}))),s&&e?(yield t.deleteMany({_id:{$in:a.body.id}}),d.send({success:!0})):d.status(400).json({err:"Invalid Security Configuration"})}else d.status(400).json({err:"Invalid Fields"})}catch(t){d.status(400).json({err:t})}}),this.initDelete=(a,d)=>__awaiter(this,void 0,void 0,function*(){try{var t,e,i,s,o=a.body.id;o?(e=yield(t=this.mongoDB.db(this.tableId).collection(this.collection)).findOne({_id:o}),i=(0,QueryModel_1.checkBaseConfig)(this.config,a),s=(0,QueryModel_1.checkOpsConfig)(this.config,"delete",a,e),i&&s?(yield t.findOneAndDelete({_id:o}),d.send({success:!0})):d.status(400).json({err:"Invalid Security Configuration"})):d.status(400).json({err:"Invalid Fields"})}catch(t){d.status(400).json({err:t})}}),this.initList=(c,l)=>__awaiter(this,void 0,void 0,function*(){try{var i=(0,QueryModel_1.checkBaseConfig)(this.config,c);if(i){var s=c.body.query;const r={};s&&0<s.length&&s.map(t=>{var e,i=null!=(e=t.queryId)?e:"";const s=t.value;switch(t.type){case"search":t.searchIds&&0<t.searchIds.length&&(r.$or=[],t.searchIds.map(t=>{r.$or.push({[t]:{$regex:s,$options:"i"}})}));break;case"=":r[i]=s;break;case"!=":r[i]={$ne:s};break;case">":r[i]={$gt:s};break;case"<":r[i]={$lt:s};break;case"><":Array.isArray(s)&&2<=s.length&&(r[i]={$gte:s[0],$lte:s[1]});break;case"in":r[i]={$in:s}}});let t=this.mongoDB.db(this.tableId).collection(this.collection).find(r);var o,a,d=yield t.count({}),n=(c.body.cursor&&(t=t.skip(c.body.cursor)),c.body.limit&&(t=t.limit(c.body.limit)),c.body.sort&&(a={[(o=c.body.sort).sortId]:"asc"===o.type?1:-1},t=t.sort(a)),yield t.toArray());let e=!0;0<n.length&&n.map(t=>{(0,QueryModel_1.checkOpsConfig)(this.config,"read",c,t)||(e=!1)}),i&&e?l.send({data:n,count:d}):l.status(400).json({err:"Invalid Security Configuration"})}else l.status(400).json({err:"Invalid Security Configuration"})}catch(t){l.status(400).json({err:t})}}),this.init=()=>{var t=this.lib.express.Router();return t.post("/create",this.initCreate),t.post("/batchCreate",this.initBatchCreate),t.post("/get",this.initGet),t.post("/update",this.initUpdate),t.post("/batchUpdate",this.initBatchUpdate),t.post("/delete",this.initDelete),t.post("/batchDelete",this.initBatchDelete),t.post("/list",this.initList),t},this.mongoDB=t,this.collection=e,this.isProd=i,this.config=s,this.modelChecker=o,this.lib=a;t=this.isProd?"prod":"dev";this.tableId=d?d+"-"+t:t}}exports.MongoWrapper=MongoWrapper;
1
+ "use strict";var __awaiter=this&&this.__awaiter||function(e,n,d,r){return new(d=d||Promise)(function(i,t){function s(e){try{a(r.next(e))}catch(e){t(e)}}function o(e){try{a(r.throw(e))}catch(e){t(e)}}function a(e){var t;e.done?i(e.value):((t=e.value)instanceof d?t:new d(function(e){e(t)})).then(s,o)}a((r=r.apply(e,n||[])).next())})},__importDefault=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(exports,"__esModule",{value:!0}),exports.MongoWrapper=void 0;const moment_1=__importDefault(require("moment")),QueryModel_1=require("../model/QueryModel");class MongoWrapper{constructor(e,t,i,s,o,a,n){this.mongoDB="",this.collection="",this.isProd=!1,this.config={baseConfig:[],opsConfig:{read:[],create:[],update:[],delete:[]}},this.modelChecker=e=>!1,this.tableId="",this.parseModel=e=>(delete e._id,e.baseUpdatedAt=(0,moment_1.default)().toDate(),e),this.initBatchCreate=(o,a)=>__awaiter(this,void 0,void 0,function*(){try{if(Array.isArray(o.body.data)){let t=!0;o.body.data.map(e=>{this.modelChecker(e)||(t=!1)}),t||a.status(400).json({err:"Invalid Model Structure"});var e,s=(0,QueryModel_1.checkBaseConfig)(this.config,o);let i=!0;yield Promise.all(o.body.data.map(e=>{(0,QueryModel_1.checkOpsConfig)(this.config,"update",o,e)||(i=!1)})),s&&i?(e=o.body.data.map(e=>Object.assign(Object.assign({},e),{baseUpdatedAt:(0,moment_1.default)().toDate()})),yield this.mongoDB.db(this.tableId).collection(this.collection).insertMany(e),a.send({success:!0})):a.status(400).json({err:"Invalid Security Configuration"})}else a.status(400).json({err:"Invalid Fields"})}catch(e){a.status(400).json({err:e})}}),this.initCreate=(i,s)=>__awaiter(this,void 0,void 0,function*(){try{var e,t;this.modelChecker(i.body.data)?(e=(0,QueryModel_1.checkBaseConfig)(this.config,i),t=(0,QueryModel_1.checkOpsConfig)(this.config,"create",i,i.body.data),e&&t?(i.body.data.baseUpdatedAt=(0,moment_1.default)().toDate(),yield this.mongoDB.db(this.tableId).collection(this.collection).insertOne(i.body.data),s.send({success:!0})):s.status(400).json({err:"Invalid Security Configuration"})):s.status(400).json({err:"Invalid Model Structure"})}catch(e){s.status(400).json({err:e})}}),this.initGet=(o,a)=>__awaiter(this,void 0,void 0,function*(){try{var e,t,i,s=o.body.id;s?(e=yield this.mongoDB.db(this.tableId).collection(this.collection).findOne({_id:s}),t=(0,QueryModel_1.checkBaseConfig)(this.config,o),i=(0,QueryModel_1.checkOpsConfig)(this.config,"read",o,e),t&&i?a.send({data:e}):a.status(400).json({err:"Invalid Security Configuration"})):a.status(400).json({err:"Invalid Fields"})}catch(e){a.status(400).json({err:e})}}),this.initBatchUpdate=(a,n)=>__awaiter(this,void 0,void 0,function*(){try{var e=this.modelChecker(a.body.data)&&a.body.id;if(Array.isArray(a.body.id)){var s=a.body.data.map(e=>Object.assign(Object.assign({},e),{baseUpdatedAt:(0,moment_1.default)().toDate()})),i=(0,QueryModel_1.checkBaseConfig)(this.config,a);let t=!0;if(yield Promise.all(a.body.data.map(e=>{(0,QueryModel_1.checkOpsConfig)(this.config,"update",a,e)||(t=!1)})),i&&t){const o=this.mongoDB.db(this.tableId).collection(this.collection);if(a.body.sensitive){let i=!0;yield Promise.all(a.body.id.map(t=>__awaiter(this,void 0,void 0,function*(){var e=yield o.findOne({_id:t});(0,moment_1.default)(a.body.data.baseUpdatedAt).isAfter((0,moment_1.default)(e.baseUpdatedAt))?n.status(400).json({err:"Refresh Sensitive Model"}):i=!1}))),i&&(yield o.updateMany({_id:{$in:e}},{$set:Object.assign({},s)}),n.send({success:!0}))}else yield o.updateMany({_id:{$in:e}},{$set:Object.assign({},s)}),n.send({success:!0})}else n.status(400).json({err:"Invalid Security Configuration"})}}catch(e){}}),this.initUpdate=(d,r)=>__awaiter(this,void 0,void 0,function*(){try{var e,t,i,s,o,a,n=this.modelChecker(d.body.data)&&d.body.id;n?(e=(0,QueryModel_1.checkBaseConfig)(this.config,d),t=(0,QueryModel_1.checkOpsConfig)(this.config,"update",d,d.body.data),e&&t?(i=this.mongoDB.db(this.tableId).collection(this.collection),d.body.sensitive?(s=yield i.findOne({_id:n}),(0,moment_1.default)(d.body.data.baseUpdatedAt).isAfter((0,moment_1.default)(s.baseUpdatedAt))?(o=this.parseModel(d.body.data),yield i.updateOne({_id:n},{$set:Object.assign({},o)}),r.send({success:!0})):r.status(400).json({err:"Refresh Sensitive Model"})):(a=this.parseModel(d.body.data),yield i.updateOne({_id:n},{$set:Object.assign({},a)}),r.send({success:!0}))):r.status(400).json({err:"Invalid Security Configuration"})):r.status(400).json({err:"Invalid Model Structure"})}catch(e){r.status(400).json({err:e})}}),this.initBatchDelete=(l,h)=>__awaiter(this,void 0,void 0,function*(){try{if(Array.isArray(l.body.id)){var e=this.mongoDB.db(this.tableId).collection(this.collection),i=yield e.find({_id:{$in:l.body.id}}),s=(0,QueryModel_1.checkBaseConfig)(this.config,l),o=yield i.toArray();let t=!0;0<o.length&&(yield Promise.all(o.map(e=>{(0,QueryModel_1.checkOpsConfig)(this.config,"delete",l,e)||(t=!1)}))),s&&t?(yield e.deleteMany({_id:{$in:l.body.id}}),h.send({success:!0})):h.status(400).json({err:"Invalid Security Configuration"})}else{var a=l.body.query;const c={};a&&0<a.length&&a.map(e=>{var t,i=null!=(t=e.queryId)?t:"";const s=e.value;switch(e.type){case"search":e.searchIds&&0<e.searchIds.length&&(c.$or=[],e.searchIds.map(e=>{c.$or.push({[e]:{$regex:s,$options:"i"}})}));break;case"=":c[i]=s;break;case"!=":c[i]={$ne:s};break;case">":c[i]={$gt:s};break;case"<":c[i]={$lt:s};break;case"><":Array.isArray(s)&&2<=s.length&&(c[i]={$gte:s[0],$lte:s[1]});break;case"in":c[i]={$in:s}}});var n=this.mongoDB.db(this.tableId).collection(this.collection),d=yield n.find(c).toArray(),r=(0,QueryModel_1.checkBaseConfig)(this.config,l);let t=!0;0<d.length&&d.map(e=>{(0,QueryModel_1.checkOpsConfig)(this.config,"delete",l,e)||(t=!1)}),r&&t?(yield n.deleteMany(c),h.send({success:!0})):h.status(400).json({err:"Invalid Security Configuration"})}}catch(e){h.status(400).json({err:e})}}),this.initDelete=(a,n)=>__awaiter(this,void 0,void 0,function*(){try{var e,t,i,s,o=a.body.id;o?(t=yield(e=this.mongoDB.db(this.tableId).collection(this.collection)).findOne({_id:o}),i=(0,QueryModel_1.checkBaseConfig)(this.config,a),s=(0,QueryModel_1.checkOpsConfig)(this.config,"delete",a,t),i&&s?(yield e.findOneAndDelete({_id:o}),n.send({success:!0})):n.status(400).json({err:"Invalid Security Configuration"})):n.status(400).json({err:"Invalid Fields"})}catch(e){n.status(400).json({err:e})}}),this.initList=(c,l)=>__awaiter(this,void 0,void 0,function*(){try{var i=(0,QueryModel_1.checkBaseConfig)(this.config,c);if(i){var s=c.body.query;const r={};s&&0<s.length&&s.map(e=>{var t,i=null!=(t=e.queryId)?t:"";const s=e.value;switch(e.type){case"search":e.searchIds&&0<e.searchIds.length&&(r.$or=[],e.searchIds.map(e=>{r.$or.push({[e]:{$regex:s,$options:"i"}})}));break;case"=":r[i]=s;break;case"!=":r[i]={$ne:s};break;case">":r[i]={$gt:s};break;case"<":r[i]={$lt:s};break;case"><":Array.isArray(s)&&2<=s.length&&(r[i]={$gte:s[0],$lte:s[1]});break;case"in":r[i]={$in:s}}});let e=this.mongoDB.db(this.tableId).collection(this.collection).find(r);var o,a,n=yield e.count({}),d=(c.body.cursor&&(e=e.skip(c.body.cursor)),c.body.limit&&(e=e.limit(c.body.limit)),c.body.sort&&(a={[(o=c.body.sort).sortId]:"asc"===o.type?1:-1},e=e.sort(a)),yield e.toArray());let t=!0;0<d.length&&d.map(e=>{(0,QueryModel_1.checkOpsConfig)(this.config,"read",c,e)||(t=!1)}),i&&t?l.send({data:d,count:n}):l.status(400).json({err:"Invalid Security Configuration"})}else l.status(400).json({err:"Invalid Security Configuration"})}catch(e){l.status(400).json({err:e})}}),this.init=()=>{var e=this.lib.express.Router();return e.post("/create",this.initCreate),e.post("/batchCreate",this.initBatchCreate),e.post("/get",this.initGet),e.post("/update",this.initUpdate),e.post("/batchUpdate",this.initBatchUpdate),e.post("/delete",this.initDelete),e.post("/batchDelete",this.initBatchDelete),e.post("/list",this.initList),e},this.mongoDB=e,this.collection=t,this.isProd=i,this.config=s,this.modelChecker=o,this.lib=a;e=this.isProd?"prod":"dev";this.tableId=n?n+"-"+e:e}}exports.MongoWrapper=MongoWrapper;
@@ -6,10 +6,10 @@
6
6
  * 4. Prevent DDOS from rate limiting
7
7
  */
8
8
  export declare class SecurityMiddleware {
9
- checkAuthentication: (token: string) => string;
10
- checkRole: (userId: string) => string;
11
- checkAPIToken: (apiToken: string) => boolean;
12
- constructor(checkAuthentication: (token: string) => string, checkRole: (userId: string) => string, checkAPIToken: (apiToken: string) => boolean);
9
+ checkAuthentication: (token: string) => Promise<string>;
10
+ checkRole: (userId: string) => Promise<string>;
11
+ checkAPIToken: (apiToken: string) => Promise<boolean>;
12
+ constructor(checkAuthentication: (token: string) => Promise<string>, checkRole: (userId: string) => Promise<string>, checkAPIToken: (apiToken: string) => Promise<boolean>);
13
13
  /**
14
14
  * 1. Check User Authentication
15
15
  * 2. Check User Role
@@ -1 +1 @@
1
- {"version":3,"file":"security.d.ts","sourceRoot":"","sources":["../../src/apis/security.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,qBAAa,kBAAkB;IAE7B,mBAAmB,UAAW,MAAM,YAElC;IACF,SAAS,WAAY,MAAM,YAEzB;IACF,aAAa,aAAc,MAAM,aAE/B;gBAIA,mBAAmB,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,MAAM,EAC9C,SAAS,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK,MAAM,EACrC,aAAa,EAAE,CAAC,QAAQ,EAAE,MAAM,KAAK,OAAO;IAO9C;;;;OAIG;IACH,IAAI,UAG8C,GAAG,OAAO,GAAG,SAAS,GAAG;CA6B5E"}
1
+ {"version":3,"file":"security.d.ts","sourceRoot":"","sources":["../../src/apis/security.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,qBAAa,kBAAkB;IAE7B,mBAAmB,UAAiB,MAAM,qBAExC;IACF,SAAS,WAAkB,MAAM,qBAE/B;IACF,aAAa,aAAoB,MAAM,sBAErC;gBAIA,mBAAmB,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,OAAO,CAAC,MAAM,CAAC,EACvD,SAAS,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK,OAAO,CAAC,MAAM,CAAC,EAC9C,aAAa,EAAE,CAAC,QAAQ,EAAE,MAAM,KAAK,OAAO,CAAC,OAAO,CAAC;IAOvD;;;;OAIG;IACH,IAAI,UAG8C,GAAG,OAAO,GAAG,SAAS,GAAG;CA6B5E"}
@@ -1 +1 @@
1
- "use strict";var __awaiter=this&&this.__awaiter||function(e,r,u,d){return new(u=u||Promise)(function(o,t){function i(e){try{c(d.next(e))}catch(e){t(e)}}function n(e){try{c(d.throw(e))}catch(e){t(e)}}function c(e){var t;e.done?o(e.value):((t=e.value)instanceof u?t:new u(function(e){e(t)})).then(i,n)}c((d=d.apply(e,r||[])).next())})};Object.defineProperty(exports,"__esModule",{value:!0}),exports.SecurityMiddleware=void 0;class SecurityMiddleware{constructor(e,t,o){this.checkAuthentication=e=>"",this.checkRole=e=>"",this.checkAPIToken=e=>!1,this.checkAuthentication=e,this.checkRole=t,this.checkAPIToken=o}init(){const i=this;return function(t,e,o){return __awaiter(this,void 0,void 0,function*(){var e;delete t.body.bm_userId,delete t.body.bm_userRole,delete t.body.bm_apiToken,t.body.userToken&&(e=i.checkAuthentication(t.body.userToken))&&(t.body.bm_userId=e,e=i.checkRole(e))&&(t.body.bm_userRole=e),t.body.apiToken&&(e=t.body.apiToken,e=i.checkAPIToken(e),t.body.bm_apiToken=e),o&&o()})}}}exports.SecurityMiddleware=SecurityMiddleware;
1
+ "use strict";var __awaiter=this&&this.__awaiter||function(e,r,d,u){return new(d=d||Promise)(function(i,t){function o(e){try{c(u.next(e))}catch(e){t(e)}}function n(e){try{c(u.throw(e))}catch(e){t(e)}}function c(e){var t;e.done?i(e.value):((t=e.value)instanceof d?t:new d(function(e){e(t)})).then(o,n)}c((u=u.apply(e,r||[])).next())})};Object.defineProperty(exports,"__esModule",{value:!0}),exports.SecurityMiddleware=void 0;class SecurityMiddleware{constructor(e,t,i){this.checkAuthentication=e=>__awaiter(this,void 0,void 0,function*(){return""}),this.checkRole=e=>__awaiter(this,void 0,void 0,function*(){return""}),this.checkAPIToken=e=>__awaiter(this,void 0,void 0,function*(){return!1}),this.checkAuthentication=e,this.checkRole=t,this.checkAPIToken=i}init(){const o=this;return function(t,e,i){return __awaiter(this,void 0,void 0,function*(){var e;delete t.body.bm_userId,delete t.body.bm_userRole,delete t.body.bm_apiToken,t.body.userToken&&(e=yield o.checkAuthentication(t.body.userToken))&&(t.body.bm_userId=e,e=yield o.checkRole(e))&&(t.body.bm_userRole=e),t.body.apiToken&&(e=t.body.apiToken,e=yield o.checkAPIToken(e),t.body.bm_apiToken=e),i&&i()})}}}exports.SecurityMiddleware=SecurityMiddleware;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "blixify-server",
3
- "version": "0.1.14",
3
+ "version": "0.1.16",
4
4
  "license": "MIT",
5
5
  "main": "dist/apis/index.js",
6
6
  "private": false,