feat(Proposals): Adding simple event handler
This commit is contained in:
1
.gitignore
vendored
1
.gitignore
vendored
@@ -2,3 +2,4 @@ node_modules/
|
||||
.env
|
||||
package-lock.json
|
||||
.env
|
||||
migrate.js
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
"use strict";
|
||||
|
||||
const { ROOT_PATH, LIB_PATH, MODELS_PATH, HANDLERS_PATH } = process.env;
|
||||
const { getModel } = require( `${ROOT_PATH}/${MODELS_PATH}` );
|
||||
const { getPagination } = require( `${ROOT_PATH}/${LIB_PATH}/Misc.js` );
|
||||
const { GenericHandler } = require( `${ROOT_PATH}/${HANDLERS_PATH}/Generic.handler.js` );
|
||||
const { getModel } = require( '../../../lib/Models' );
|
||||
const { getPagination } = require( '../../../lib/Misc' );
|
||||
const { GenericHandler } = require( '../../../lib/Handlers/Generic.handler' );
|
||||
const { onPatchEvent } = require('../../../lib/Handlers/Proposals.handler');
|
||||
const Model = getModel('proposals');
|
||||
|
||||
const populate_list = [{ path:'load' , populate : { path : 'categories' } }, 'shipper','carrier','vehicle','bidder','accepted_by'];
|
||||
@@ -93,6 +93,7 @@ const patchProposal = async(req, res) => {
|
||||
throw "proposal data not sent";
|
||||
}
|
||||
await Model.findByIdAndUpdate( elementId , data );
|
||||
await onPatchEvent( elementId , data );
|
||||
return res.send( await Model.findById( elementId ) );
|
||||
}catch(error){
|
||||
console.error( error );
|
||||
|
||||
13
src/lib/Handlers/Proposals.handler.js
Normal file
13
src/lib/Handlers/Proposals.handler.js
Normal file
@@ -0,0 +1,13 @@
|
||||
'user strict';
|
||||
const { getModel } = require( '../Models' );
|
||||
|
||||
const proposalsModel = getModel('proposals');
|
||||
const loadsModel = getModel('loads');
|
||||
const usersModel = getModel('users');
|
||||
const companiesModel = getModel('companies');
|
||||
|
||||
async function onPatchEvent( id , newProposalData ){
|
||||
console.log( newProposalData );
|
||||
}
|
||||
|
||||
module.exports = { onPatchEvent };
|
||||
Reference in New Issue
Block a user