├── .DS_Store ├── .gitignore ├── .gitlab-ci.yml ├── .vscode └── launch.json ├── README.md ├── bba-client ├── assets │ ├── images │ │ ├── action_resend.svg │ │ ├── bike_logo.png │ │ ├── bike_logo.svg │ │ ├── bike_logo@2x.png │ │ ├── bike_logo_color.png │ │ ├── cycle.png │ │ ├── cycle@2x.png │ │ ├── dashboard_bike.svg │ │ ├── dashboard_lock.svg │ │ ├── dashboard_resend.svg │ │ ├── dashboard_search.svg │ │ ├── delivery_bike.svg │ │ ├── down_arrow.svg │ │ ├── download.svg │ │ ├── empty.jpg │ │ ├── home.svg │ │ ├── lock.svg │ │ ├── resend.svg │ │ ├── search.svg │ │ ├── timer_lunchbreak.svg │ │ ├── timer_pause.svg │ │ ├── timer_start.svg │ │ └── timer_stop.svg │ └── sass │ │ ├── abstracts │ │ ├── _functions.scss │ │ ├── _mixins.scss │ │ └── _variables.scss │ │ ├── base │ │ ├── _animations.scss │ │ ├── _base.scss │ │ ├── _typhography.scss │ │ └── _utilities.scss │ │ ├── components │ │ └── _user.scss │ │ ├── layout │ │ ├── _footer.scss │ │ ├── _header.scss │ │ └── _navigation.scss │ │ ├── main.scss │ │ ├── pages │ │ └── _users.scss │ │ ├── variables.scss │ │ └── vuetify.scss ├── components │ ├── BarScanner.vue │ ├── FormUserProfile.vue │ ├── OverlayLoading.vue │ ├── PageSetting.vue │ ├── PhotoCaptureComp.vue │ ├── ThemeSettings.vue │ ├── delivery-order │ │ ├── photo-capture │ │ │ ├── CameraModal.vue │ │ │ └── CapturePhoto.vue │ │ └── steppers │ │ │ ├── FourthStepper.vue │ │ │ ├── FourthSwapStepper.vue │ │ │ ├── ThirdStepper.vue │ │ │ └── ThirdSwapStepper.vue │ ├── location-management │ │ ├── Area.vue │ │ ├── StreetAddress.vue │ │ └── Villa.vue │ ├── logistics │ │ └── TruckBlock.vue │ └── paradym │ │ ├── AppBar.vue │ │ ├── AudioOscilloscope.vue │ │ ├── AudioRecorder.vue │ │ ├── AudioRecorderBackup.vue │ │ ├── DateInput.vue │ │ ├── Dialog.vue │ │ ├── Dropzone.vue │ │ ├── Editable.vue │ │ ├── Field.vue │ │ ├── FileUploadProgress.vue │ │ ├── FileUploader.vue │ │ ├── FloatingButton.vue │ │ ├── FormGenerator.vue │ │ ├── IconButton.vue │ │ ├── IconButtonMenu.vue │ │ ├── IconButtonMenuLeft.vue │ │ ├── ListInput.vue │ │ ├── ListTable.vue │ │ ├── Navigation.vue │ │ ├── NotificationButtonMenu.vue │ │ ├── Page.vue │ │ ├── PageForm.vue │ │ ├── PageResource.vue │ │ ├── PageSection.vue │ │ ├── ServerDataTable.vue │ │ ├── SettingsList.vue │ │ ├── Sidebar.vue │ │ ├── Snackbar.vue │ │ ├── TextUsersAndEmails.vue │ │ ├── TimeInput.vue │ │ ├── forms │ │ ├── Form.vue │ │ ├── FormChangePassword.vue │ │ ├── FormEmail.vue │ │ ├── FormLogin.vue │ │ └── FormRegister.vue │ │ └── modals │ │ └── ModalConfirm.vue ├── constants │ └── index.js ├── data.json ├── env.example ├── jsconfig.json ├── layouts │ ├── default.vue │ ├── error.vue │ └── loggedOut.vue ├── nuxt.config.js ├── package.json ├── pages │ ├── account │ │ ├── index.vue │ │ ├── name.vue │ │ └── password.vue │ ├── activity │ │ └── index.vue │ ├── after-hour-message │ │ └── index.vue │ ├── asset │ │ └── index.vue │ ├── backupDatabase.vue │ ├── backupPhotos.vue │ ├── callForHelp.vue │ ├── colorCombinationSetting.vue │ ├── communication-messages │ │ └── _deliveryOrderId │ │ │ └── index.vue │ ├── deal │ │ └── index.vue │ ├── deliveryOrder │ │ ├── _orderId │ │ │ └── index.vue │ │ └── index.vue │ ├── deliveryOrderManagement │ │ ├── _orderId │ │ │ └── index.vue │ │ └── index.vue │ ├── equipment-types │ │ └── index.vue │ ├── equipmentswap │ │ ├── _id │ │ │ ├── index.vue │ │ │ └── index_.vue │ │ ├── create.vue │ │ └── index.vue │ ├── forgotPassword.vue │ ├── index.vue │ ├── location-management │ │ └── index.vue │ ├── location-reconciliation │ │ └── index.vue │ ├── location-sort │ │ └── index.vue │ ├── locking │ │ ├── _deliveryId │ │ │ └── index.vue │ │ └── index.vue │ ├── login.vue │ ├── loginAndRegister.vue │ ├── logistics │ │ └── index.vue │ ├── logout.vue │ ├── pickup │ │ ├── _deliveryID │ │ │ └── index.vue │ │ └── index.vue │ ├── problem-types │ │ └── index.vue │ ├── problem │ │ └── index.vue │ ├── register.vue │ ├── report │ │ └── index.vue │ ├── resend │ │ └── index.vue │ ├── resendVerificationEmail.vue │ ├── resetPassword.vue │ ├── scheduler │ │ └── index.vue │ ├── searchHistory │ │ ├── _orderId │ │ │ └── index.vue │ │ └── index.vue │ ├── stock-tracking │ │ └── _id │ │ │ └── index.vue │ ├── test.vue │ ├── textMessageTemplate.vue │ ├── timeclock │ │ └── index.vue │ ├── truck │ │ └── index.vue │ ├── truckloading │ │ ├── _orderId │ │ │ └── index.vue │ │ └── index.vue │ ├── twilioManagement │ │ └── index.vue │ ├── upload.vue │ ├── users │ │ ├── allUsers.vue │ │ └── index.vue │ ├── verifyEmail.vue │ └── webHookSetting.vue ├── plugins │ ├── OfflineQueueProcessor.js │ ├── QReader.js │ ├── barCode.js │ ├── dateTimePicker.js │ ├── google-maps.js │ ├── queuedUploads.js │ └── theme.js ├── service │ └── touchScreen.js ├── static │ ├── favicon.png │ ├── paradym_icon.png │ ├── sw.js │ └── webHooks │ │ ├── LOCK_MOCK_DATA.json │ │ ├── ORDER_DELIVERY_MOCK_DATA.json │ │ ├── ORDER_MOCK_DATA.json │ │ ├── RESEND_MOCK_DATA.json │ │ └── SEARCH_MOCK_DATA.json ├── store │ ├── index.js │ ├── snackbar.js │ └── theme.js └── themes.json ├── bba-server ├── .DS_Store ├── api │ ├── extensions │ │ ├── email.js │ │ ├── fileFilter.js │ │ └── verifyAuthHeader.js │ ├── functions │ │ ├── notifications.js │ │ └── sendEmail.js │ ├── protected │ │ ├── index.js │ │ ├── upload.js │ │ ├── user │ │ │ ├── allUsers.js │ │ │ ├── changePassword.js │ │ │ ├── deleteUser.js │ │ │ ├── restoreUsers.js │ │ │ └── updateUsers.js │ │ └── webHook │ │ │ ├── allWebHooks.js │ │ │ ├── createWebHook.js │ │ │ └── updateWebHook.js │ └── unprotected │ │ ├── index.js │ │ └── user │ │ ├── activity.js │ │ ├── asset.js │ │ ├── communicationMessage.js │ │ ├── deal.js │ │ ├── deliveryItem.js │ │ ├── deliveryOrderManagement.js │ │ ├── deliveryorder.js │ │ ├── deliveryorderupdate.js │ │ ├── downloadBackUpPhotos.js │ │ ├── drivers.js │ │ ├── equipmentType.js │ │ ├── forgotPassword.js │ │ ├── getOrder.js │ │ ├── location.controller.js │ │ ├── location.service.js │ │ ├── locking.js │ │ ├── login.js │ │ ├── notification.js │ │ ├── problem.js │ │ ├── problemType.js │ │ ├── register.js │ │ ├── resend.js │ │ ├── resetPassword.js │ │ ├── searchhistory.js │ │ ├── sendDeliveryEmail.js │ │ ├── sendEmailVerification.js │ │ ├── sendSMS.js │ │ ├── stockTracker.js │ │ ├── template.js │ │ ├── timeclock.js │ │ ├── trip.controller.js │ │ ├── trip.service.js │ │ ├── truck.js │ │ ├── twilio.js │ │ ├── upload.js │ │ ├── uploadPickup.js │ │ ├── verifyEmail.js │ │ └── webhookmap.js ├── config │ └── config.js ├── constants │ ├── constant.js │ └── index.js ├── ecosystem.config.js ├── env.example ├── index.js ├── language │ └── en.json ├── libs │ ├── apiError.js │ ├── generateOTPPassword.js │ ├── iterate.js │ ├── randomCharacters.js │ ├── randomDate.js │ └── validateEmail.js ├── log.json ├── middleware │ └── auth.js ├── migrations │ ├── 01-create-Users.js │ ├── 02-create-VerificationTokens.js │ ├── 03-create-ResetTokens.js │ ├── 04-create-Uploads.js │ ├── 05-create-WebHook.js │ ├── 06-create-DeliveryOrder.js │ ├── 07-create-WebhookMap.js │ ├── 08-create-Template.js │ ├── 09-create-File.js │ ├── 09-create-Log.js │ ├── 10-create-Lock.js │ ├── 11-update-DeliveryOrder copy.js │ ├── 12-update-Lock.js │ ├── 20210519144448-ColorValues.js │ ├── 20210529215855-create-asset.js │ ├── 20210529220117-create-truck.js │ ├── 20210601095359-add_new_truck_id_column.js │ ├── 20230608124844-create-area.js │ └── 20230608125239-create-villa.js ├── mockData.js ├── models │ ├── Activity.js │ ├── Area.js │ ├── CommunicationMessage.js │ ├── Deal.js │ ├── EquipmentType.js │ ├── Notification.js │ ├── Problem.js │ ├── ProblemType.js │ ├── StreetAddress.js │ ├── Timeclock.js │ ├── Villa.js │ ├── asset.js │ ├── deliveryExtras.js │ ├── deliveryItem.js │ ├── deliveryOrder.js │ ├── file.js │ ├── index.js │ ├── lock.js │ ├── log.js │ ├── resetToken.js │ ├── template.js │ ├── trip.js │ ├── truck.js │ ├── uploads.js │ ├── user.js │ ├── verificationToken.js │ ├── webhook.js │ └── webhookMap.js ├── package.json ├── public │ ├── .DS_Store │ ├── Apr999-21-0.jpeg │ ├── Apr999-21-1.jpeg │ ├── Apr999-21-2.jpeg │ ├── Aug0005-23-0.jpeg │ ├── Aug0006-23-0.jpeg │ ├── Aug0006-23-pickup-1.jpeg │ ├── Jul0281-21-0.jpeg │ ├── Jun0140-21-0.jpeg │ ├── Jun0140-21-1.jpeg │ ├── Jun0156-21-0.jpeg │ ├── Jun999-21-0.jpeg │ ├── Sep0001-23-0.jpeg │ ├── Sep0001-23-pickup-1.jpeg │ └── pickup │ │ ├── Aug0005-23-0.jpeg │ │ ├── Jun0156-21-0.jpeg │ │ ├── Jun0156-21-1.jpeg │ │ ├── Jun0156-21-2.jpeg │ │ ├── May0070-23-0.jpeg │ │ ├── May0168-23-0.jpeg │ │ └── May0284-23-0.jpeg ├── seed.js ├── translation │ ├── DeliveryItemsQuery.js │ ├── DeliveryOrderQuery.js │ ├── colorLocksQuery.js │ ├── deliveryExtrasQuery.js │ └── generateWhereString.js └── webHook │ ├── index.js │ └── webHook.js ├── client.DockerFile ├── demo-3rdP ├── app.js ├── data.json ├── log.json ├── package-lock.json └── package.json ├── deploy.sh ├── node_modules ├── .yarn-integrity └── idb │ ├── CHANGELOG.md │ ├── LICENSE │ ├── README.md │ ├── build │ ├── async-iterators.d.ts │ ├── database-extras.d.ts │ ├── entry.d.ts │ ├── index.cjs │ ├── index.d.ts │ ├── index.js │ ├── umd.js │ ├── util.d.ts │ └── wrap-idb-value.d.ts │ └── package.json ├── package.json └── server.DockerFile /.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jairo-matos/BikeDeliveryApp/2f323905cfa6f5a9ebe280529bc094b85fc9ca3e/.DS_Store -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Logs 2 | bba-client/logs 3 | bba-client/*.log 4 | bba-client/npm-debug.log* 5 | bba-client/yarn-debug.log* 6 | bba-client/yarn-error.log* 7 | bba-server/yarn-error.log* 8 | 9 | # Runtime data 10 | bba-client/pids 11 | bba-client/*.pid 12 | bba-client/*.seed 13 | bba-client/*.pid.lock 14 | 15 | # Directory for instrumented libs generated by jscoverage/JSCover 16 | bba-client/lib-cov 17 | 18 | # Coverage directory used by tools like istanbul 19 | bba-client/coverage 20 | 21 | # nyc test coverage 22 | bba-client/.nyc_output 23 | 24 | # Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files) 25 | bba-client/.grunt 26 | 27 | # Bower dependency directory (https://bower.io/) 28 | bba-client/bower_components 29 | 30 | # node-waf configuration 31 | bba-client/.lock-wscript 32 | 33 | # Compiled binary addons (https://nodejs.org/api/addons.html) 34 | bba-client/build/Release 35 | 36 | # Dependency directories 37 | bba-client/node_modules/ 38 | bba-client/jspm_packages/ 39 | bba-server/node_modules/ 40 | demo-3rdP/node_modules/ 41 | 42 | # TypeScript v1 declaration files 43 | bba-client/typings/ 44 | 45 | # Optional npm cache directory 46 | bba-client/.npm 47 | 48 | # Optional eslint cache 49 | bba-client/.eslintcache 50 | 51 | # Optional REPL history 52 | bba-client/.node_repl_history 53 | 54 | # Output of 'npm pack' 55 | bba-client/*.tgz 56 | 57 | # Yarn Integrity file 58 | bba-client/.yarn-integrity 59 | 60 | # dotenv environment variables file 61 | bba-client/.env 62 | bba-server/.env 63 | 64 | # parcel-bundler cache (https://parceljs.org/) 65 | bba-client/.cache 66 | 67 | # next.js build output 68 | bba-client/.next 69 | 70 | # Ignore .nuxt 71 | bba-client/.nuxt 72 | 73 | # Nuxt generate 74 | bba-client/dist 75 | 76 | # vuepress build output 77 | bba-client/.vuepress/dist 78 | 79 | # Serverless directories 80 | bba-client/.serverless 81 | 82 | # IDE / Editor 83 | bba-client/.idea 84 | 85 | # Service worker 86 | bba-client/sw.* 87 | 88 | # macOS 89 | bba-client/.DS_Store 90 | 91 | # Vim swap files 92 | bba-client/*.swp 93 | 94 | # Lock files 95 | bba-client/package-lock.json 96 | bba-server/package-lock.json 97 | 98 | # Yarn lock file 99 | yarn.lock 100 | bba-client/yarn.lock 101 | bba-server/yarn.lock 102 | bba-server/public 103 | -------------------------------------------------------------------------------- /.gitlab-ci.yml: -------------------------------------------------------------------------------- 1 | image: node:lts 2 | 3 | before_script: 4 | - apt-get update -qq && apt-get install 5 | - apt install -y rsync 6 | - "which ssh-agent || ( apt-get update -y && apt-get install openssh-client -y )" 7 | - eval $(ssh-agent -s) 8 | - cat "$SSH_PRIVATE_KEY" | tr -d '\r' | ssh-add - 9 | 10 | stages: 11 | - build 12 | - deploy 13 | 14 | build dev: 15 | stage: build 16 | only: 17 | - dev 18 | script: 19 | - cd bba-client 20 | - yarn 21 | - yarn generate 22 | - ls -la 23 | 24 | build production: 25 | stage: build 26 | only: 27 | - main 28 | script: 29 | - cd bba-client 30 | - yarn 31 | - yarn generate 32 | - ls -la 33 | 34 | deploy development: 35 | stage: deploy 36 | only: 37 | - dev 38 | script: 39 | - cd bba-client 40 | - sed -i "s/{COMMIT}/$CI_COMMIT_REF_SLUG $CI_COMMIT_SHORT_SHA/g" components/paradym/Navigation.vue 41 | - rsync -azh --rsh="ssh -o StrictHostKeyChecking=no -l gitlab" ./../** gitlab@192.168.13.158:/var/storage/apps/bodhisys/apps-dev/bikeapp-copy 42 | - ssh -o StrictHostKeyChecking=no gitlab@192.168.13.158 "cd /var/storage/apps/bodhisys/apps-dev/bikeapp-copy/bba-client; yarn; yarn generate; pm2 restart bodhisys-mobile" 43 | 44 | 45 | deploy production: 46 | stage: deploy 47 | only: 48 | - main 49 | script: 50 | - cd bba-client 51 | - sed -i "s/{COMMIT}/$CI_COMMIT_REF_SLUG $CI_COMMIT_SHORT_SHA/g" components/paradym/Navigation.vue 52 | - rsync -azh --rsh="ssh -o StrictHostKeyChecking=no -l gitlab" ./../** gitlab@192.168.13.158:/var/storage/apps/bodhisys/apps/bikeapp-copy 53 | - ssh -o StrictHostKeyChecking=no gitlab@192.168.13.158 "cd /var/storage/apps/bodhisys/apps/bikeapp-copy/bba-client; yarn; yarn generate; pm2 restart bodhisys-mobile" 54 | -------------------------------------------------------------------------------- /.vscode/launch.json: -------------------------------------------------------------------------------- 1 | { 2 | // Use IntelliSense to learn about possible attributes. 3 | // Hover to view descriptions of existing attributes. 4 | // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 5 | "version": "0.2.0", 6 | "configurations": [ 7 | { 8 | "type": "pwa-chrome", 9 | "request": "launch", 10 | "name": "Launch Chrome against localhost", 11 | "url": "http://localhost:8080", 12 | "webRoot": "${workspaceFolder}" 13 | } 14 | ] 15 | } -------------------------------------------------------------------------------- /bba-client/assets/images/action_resend.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /bba-client/assets/images/bike_logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jairo-matos/BikeDeliveryApp/2f323905cfa6f5a9ebe280529bc094b85fc9ca3e/bba-client/assets/images/bike_logo.png -------------------------------------------------------------------------------- /bba-client/assets/images/bike_logo.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /bba-client/assets/images/bike_logo@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jairo-matos/BikeDeliveryApp/2f323905cfa6f5a9ebe280529bc094b85fc9ca3e/bba-client/assets/images/bike_logo@2x.png -------------------------------------------------------------------------------- /bba-client/assets/images/bike_logo_color.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jairo-matos/BikeDeliveryApp/2f323905cfa6f5a9ebe280529bc094b85fc9ca3e/bba-client/assets/images/bike_logo_color.png -------------------------------------------------------------------------------- /bba-client/assets/images/cycle.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jairo-matos/BikeDeliveryApp/2f323905cfa6f5a9ebe280529bc094b85fc9ca3e/bba-client/assets/images/cycle.png -------------------------------------------------------------------------------- /bba-client/assets/images/cycle@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jairo-matos/BikeDeliveryApp/2f323905cfa6f5a9ebe280529bc094b85fc9ca3e/bba-client/assets/images/cycle@2x.png -------------------------------------------------------------------------------- /bba-client/assets/images/dashboard_bike.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /bba-client/assets/images/dashboard_lock.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /bba-client/assets/images/dashboard_resend.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /bba-client/assets/images/dashboard_search.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /bba-client/assets/images/delivery_bike.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /bba-client/assets/images/down_arrow.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /bba-client/assets/images/download.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /bba-client/assets/images/empty.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jairo-matos/BikeDeliveryApp/2f323905cfa6f5a9ebe280529bc094b85fc9ca3e/bba-client/assets/images/empty.jpg -------------------------------------------------------------------------------- /bba-client/assets/images/home.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /bba-client/assets/images/lock.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /bba-client/assets/images/resend.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /bba-client/assets/images/search.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /bba-client/assets/images/timer_lunchbreak.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 5 | 6 | 7 | 12 | 18 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /bba-client/assets/images/timer_pause.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /bba-client/assets/images/timer_start.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /bba-client/assets/images/timer_stop.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /bba-client/assets/sass/abstracts/_functions.scss: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jairo-matos/BikeDeliveryApp/2f323905cfa6f5a9ebe280529bc094b85fc9ca3e/bba-client/assets/sass/abstracts/_functions.scss -------------------------------------------------------------------------------- /bba-client/assets/sass/abstracts/_mixins.scss: -------------------------------------------------------------------------------- 1 | @mixin clearfix { 2 | &::after { 3 | content: ""; 4 | display: table; 5 | clear: both; 6 | } 7 | } 8 | 9 | @mixin absCenter { 10 | position: absolute; 11 | top: 50%; 12 | left: 50%; 13 | transform: translate(-50%, -50%); 14 | } 15 | 16 | // All Media Query Manager 17 | @mixin responsive($breakpoint) { 18 | @if $breakpoint == phone { 19 | @media (max-width: 600px) { @content }; 20 | } 21 | @if $breakpoint == tab { 22 | @media (max-width: 960px) { @content }; 23 | } 24 | @if $breakpoint == laptop { 25 | @media (max-width: 1264px) { @content }; 26 | } 27 | @if $breakpoint == big-desktop { 28 | @media (min-width: 1904px) { @content }; 29 | } 30 | } -------------------------------------------------------------------------------- /bba-client/assets/sass/abstracts/_variables.scss: -------------------------------------------------------------------------------- 1 | //Fonts 2 | $body-font-family: 'Poppins', sans-serif; 3 | 4 | // COLORS 5 | $color-primary: #4c9a2a; 6 | $color-secondary: #8b91a0; 7 | $color-accent: #1f375b; 8 | $color-error: #ff426f; 9 | $color-info: #2196f3; 10 | $color-success: #4caf50; 11 | 12 | $color-white: #FFFFFF; 13 | $color-black: #000000; 14 | 15 | $color-grey-light-1: #faf9f9; 16 | $color-grey-light-2: #f4f2f2; 17 | $color-grey-light-3: #f0eeee; 18 | $color-grey-light-4: #ccc; 19 | $color-grey-light-5: #f6f9ff; 20 | $color-grey-light-6: #F5F5F5; 21 | 22 | $color-grey-dark-1: #333; 23 | $color-grey-dark-2: #777; 24 | $color-grey-dark-3: #999; 25 | 26 | $color-shadow-dark: 0 2rem 6rem rgba(0,0,0,.3); 27 | $color-shadow-light: 0 2rem 5rem rgba(0,0,0, .06); 28 | 29 | $color-background-1: #EAF1F8; 30 | $color-background-2: #F5F6FA; 31 | $color-line: 1px solid var($color-grey-light-2); 32 | 33 | $color-text-one: #343c4b; 34 | $color-text-two: #5e677b; 35 | 36 | $color-border-1: #8b91a0; 37 | $color-border-2: rgba(31, 55, 91, 0.1); 38 | $color-border-3: hsla(0,0%,100%,.12); 39 | 40 | // // Font 41 | // $default-font-size: 1.6rem; 42 | 43 | // Box-Shadow 44 | $default-box-shadow:rgba(54, 57, 164, 0.1) !important; 45 | $border-top-color: rgba(31, 55, 91, 0.08) !important; 46 | $divider-border-color: rgba(0,0,0,.05) !important; 47 | $card-border-color: rgba(0,0,0,.10) !important; 48 | -------------------------------------------------------------------------------- /bba-client/assets/sass/base/_animations.scss: -------------------------------------------------------------------------------- 1 | /**************** **************** 2 | Router Navigation Animation 3 | ***************** ****************/ 4 | 5 | .slide-enter-active, 6 | .slide-enter-leave { 7 | transition: opacity 0.5s ease-in-out, transform 0.5s ease; 8 | } 9 | 10 | .slide-enter-active { 11 | transition-delay: 0.5s; 12 | } 13 | 14 | .slide-enter, 15 | .slide-leave-to { 16 | opacity: 0; 17 | transform: translateX(-100px); 18 | } 19 | 20 | .slide-enter-to { 21 | opacity: 1; 22 | transform: translateX(0px); 23 | } 24 | 25 | .slide-leave { 26 | opacity: 1; 27 | transform: translateX(0px); 28 | } 29 | 30 | .slide-leave-to { 31 | opacity: 0; 32 | transform: translateX(100px); 33 | } 34 | 35 | /**************** **************** 36 | End Router Navigation Animation 37 | ***************** ****************/ 38 | 39 | @keyframes moveInLeft { 40 | 0% { 41 | opacity: 0; 42 | transform: translateX(-10rem); 43 | } 44 | 45 | 80% { 46 | transform: translateX(1rem); 47 | } 48 | 49 | 100% { 50 | opacity: 1; 51 | transform: translate(0); 52 | } 53 | } 54 | 55 | @keyframes moveInRight { 56 | 0% { 57 | opacity: 0; 58 | transform: translateX(10rem); 59 | } 60 | 61 | 80% { 62 | transform: translateX(-1rem); 63 | } 64 | 65 | 100% { 66 | opacity: 1; 67 | transform: translate(0); 68 | } 69 | } 70 | 71 | @keyframes moveInBottom { 72 | 0% { 73 | opacity: 0; 74 | transform: translateY(6rem); 75 | } 76 | 77 | 100% { 78 | opacity: 1; 79 | transform: translate(0); 80 | } 81 | } 82 | -------------------------------------------------------------------------------- /bba-client/assets/sass/base/_base.scss: -------------------------------------------------------------------------------- 1 | body, 2 | h1, 3 | h2, 4 | h3, 5 | h4, 6 | h5, 7 | h6, 8 | p, 9 | span { 10 | font-family: $body-font-family !important; 11 | } -------------------------------------------------------------------------------- /bba-client/assets/sass/base/_typhography.scss: -------------------------------------------------------------------------------- 1 | body { 2 | font-family: $body-font-family !important; 3 | font-weight: 400; 4 | /* font-size: 16px; */ 5 | line-height: 1.7; 6 | color: $color-grey-dark; 7 | } 8 | -------------------------------------------------------------------------------- /bba-client/assets/sass/base/_utilities.scss: -------------------------------------------------------------------------------- 1 | .cursor-pointer { 2 | cursor: pointer; 3 | } 4 | 5 | .mb-0 { 6 | margin-bottom: 0 !important; 7 | } 8 | 9 | .pl-30 { 10 | padding-left: 30px !important; 11 | } 12 | 13 | .card-box-shadow { 14 | box-shadow: 0px 5px 6px $default-box-shadow; 15 | } 16 | 17 | .card-border-color { 18 | border: 1px solid $card-border-color; 19 | } 20 | 21 | .button-box-shadow { 22 | box-shadow: 0px 5px 6px $default-box-shadow; 23 | } 24 | 25 | .divider-border-color { 26 | border-color: $divider-border-color; 27 | } 28 | 29 | .caret-up-icon { 30 | font-size: 18px !important; 31 | } 32 | 33 | .caret-down-icon { 34 | font-size: 18px !important; 35 | } 36 | 37 | /** 38 | * Font-Size 39 | * @desc Font-Size Common Code Will Be here 40 | * 41 | */ 42 | 43 | .fs-12 { 44 | font-size: 12px !important; 45 | } 46 | 47 | .fs-13 { 48 | font-size: 13px !important; 49 | } 50 | 51 | .fs-14 { 52 | font-size: 14px !important; 53 | } 54 | 55 | .fs-16 { 56 | font-size: 16px !important; 57 | } 58 | 59 | .fs-18 { 60 | font-size: 18px !important; 61 | } 62 | 63 | .fs-20 { 64 | font-size: 20px !important; 65 | } 66 | 67 | .fs-22 { 68 | font-size: 22px !important; 69 | } 70 | 71 | .fs-24 { 72 | font-size: 24px !important; 73 | } 74 | 75 | /** 76 | * Mobile-Divider-Design 77 | * @desc Mobile Divider Common Code Will Be here 78 | * 79 | */ 80 | // .mobile-divider { 81 | // max-width: 50%; 82 | // margin: 0 auto; 83 | // } 84 | -------------------------------------------------------------------------------- /bba-client/assets/sass/components/_user.scss: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jairo-matos/BikeDeliveryApp/2f323905cfa6f5a9ebe280529bc094b85fc9ca3e/bba-client/assets/sass/components/_user.scss -------------------------------------------------------------------------------- /bba-client/assets/sass/layout/_footer.scss: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jairo-matos/BikeDeliveryApp/2f323905cfa6f5a9ebe280529bc094b85fc9ca3e/bba-client/assets/sass/layout/_footer.scss -------------------------------------------------------------------------------- /bba-client/assets/sass/layout/_header.scss: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jairo-matos/BikeDeliveryApp/2f323905cfa6f5a9ebe280529bc094b85fc9ca3e/bba-client/assets/sass/layout/_header.scss -------------------------------------------------------------------------------- /bba-client/assets/sass/layout/_navigation.scss: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jairo-matos/BikeDeliveryApp/2f323905cfa6f5a9ebe280529bc094b85fc9ca3e/bba-client/assets/sass/layout/_navigation.scss -------------------------------------------------------------------------------- /bba-client/assets/sass/main.scss: -------------------------------------------------------------------------------- 1 | // font import 2 | @import url('https://fonts.googleapis.com/css2?family=Poppins:ital,wght@0,400;0,500;0,600;0,700;1,300&display=swap'); 3 | 4 | // abstracts scss 5 | @import 'abstracts/functions'; 6 | @import 'abstracts/mixins'; 7 | @import 'abstracts/variables'; 8 | 9 | // base scss 10 | @import 'base/base'; 11 | @import 'base/animations'; 12 | // @import "base/typhography"; 13 | @import 'base/utilities'; 14 | 15 | // components scss 16 | @import 'components/user'; 17 | 18 | // layout scss 19 | @import 'layout/navigation'; 20 | @import 'layout/header'; 21 | @import 'layout/footer'; 22 | 23 | // pages scss 24 | @import 'pages/users'; -------------------------------------------------------------------------------- /bba-client/assets/sass/pages/_users.scss: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jairo-matos/BikeDeliveryApp/2f323905cfa6f5a9ebe280529bc094b85fc9ca3e/bba-client/assets/sass/pages/_users.scss -------------------------------------------------------------------------------- /bba-client/assets/sass/variables.scss: -------------------------------------------------------------------------------- 1 | // Ref: https://github.com/nuxt-community/vuetify-module#customvariables 2 | // 3 | // The variables you want to modify 4 | // $font-size-root: 20px; 5 | -------------------------------------------------------------------------------- /bba-client/components/BarScanner.vue: -------------------------------------------------------------------------------- 1 | 17 | 18 | 51 | 52 | 68 | -------------------------------------------------------------------------------- /bba-client/components/FormUserProfile.vue: -------------------------------------------------------------------------------- 1 | 41 | 42 | 80 | -------------------------------------------------------------------------------- /bba-client/components/OverlayLoading.vue: -------------------------------------------------------------------------------- 1 | 10 | 26 | -------------------------------------------------------------------------------- /bba-client/components/PageSetting.vue: -------------------------------------------------------------------------------- 1 | 30 | 66 | -------------------------------------------------------------------------------- /bba-client/components/logistics/TruckBlock.vue: -------------------------------------------------------------------------------- 1 | 6 | 7 | 16 | 17 | 20 | -------------------------------------------------------------------------------- /bba-client/components/paradym/DateInput.vue: -------------------------------------------------------------------------------- 1 | 5 | 6 | 14 | 15 | 43 | 44 | 53 | -------------------------------------------------------------------------------- /bba-client/components/paradym/Dialog.vue: -------------------------------------------------------------------------------- 1 | 5 | 6 | 43 | 44 | 79 | 80 | 87 | -------------------------------------------------------------------------------- /bba-client/components/paradym/FloatingButton.vue: -------------------------------------------------------------------------------- 1 | 5 | 6 | 49 | 50 | 63 | -------------------------------------------------------------------------------- /bba-client/components/paradym/IconButton.vue: -------------------------------------------------------------------------------- 1 | 5 | 6 | 28 | 29 | 49 | 50 | 51 | -------------------------------------------------------------------------------- /bba-client/components/paradym/Page.vue: -------------------------------------------------------------------------------- 1 | 22 | 23 | 42 | 43 | 60 | -------------------------------------------------------------------------------- /bba-client/components/paradym/PageForm.vue: -------------------------------------------------------------------------------- 1 | 26 | 27 | 38 | 39 | 64 | -------------------------------------------------------------------------------- /bba-client/components/paradym/PageSection.vue: -------------------------------------------------------------------------------- 1 | 20 | 21 | 36 | 37 | 58 | -------------------------------------------------------------------------------- /bba-client/components/paradym/SettingsList.vue: -------------------------------------------------------------------------------- 1 | 27 | 28 | 39 | -------------------------------------------------------------------------------- /bba-client/components/paradym/Sidebar.vue: -------------------------------------------------------------------------------- 1 | 15 | 16 | 41 | 42 | 57 | -------------------------------------------------------------------------------- /bba-client/components/paradym/Snackbar.vue: -------------------------------------------------------------------------------- 1 | 5 | 6 | 24 | 25 | 49 | -------------------------------------------------------------------------------- /bba-client/components/paradym/TimeInput.vue: -------------------------------------------------------------------------------- 1 | 5 | 6 | 34 | 35 | 63 | 64 | 72 | -------------------------------------------------------------------------------- /bba-client/components/paradym/modals/ModalConfirm.vue: -------------------------------------------------------------------------------- 1 | 25 | 26 | 76 | -------------------------------------------------------------------------------- /bba-client/constants/index.js: -------------------------------------------------------------------------------- 1 | /************************** 2 | User Type Constant Variables 3 | ***************************/ 4 | export const CLIENT = "Client" 5 | export const DELVERY_DRIVER = "Delivery Driver" 6 | export const SYSTEM_ADMIN = "System Admin" 7 | 8 | export const CLIENT_NUMBER = "1" 9 | export const DELVERY_DRIVER_NUMBER = "2" 10 | export const SYSTEM_ADMIN_NUMBER = "3" 11 | 12 | /************************** 13 | Number Constant Variables 14 | ***************************/ 15 | export const NUMBER_0 = 0 16 | export const NUMBER_1 = 1 17 | export const NUMBER_2 = 2 18 | export const NUMBER_3 = 3 19 | export const NUMBER_16 = 16 20 | export const NUMBER_32 = 32 21 | export const NUMBER_64 = 64 22 | export const NUMBER_465 = 465 -------------------------------------------------------------------------------- /bba-client/env.example: -------------------------------------------------------------------------------- 1 | ############## 2 | # App Settings 3 | ############## 4 | APP_NAME=Bike Delivery App 5 | BASE_URL=http://localhost:3000 6 | API_URL=http://localhost:3100 7 | BODHYSIS_API_URL=https://api.bodhisys.io/ 8 | 9 | ############## 10 | # Server Settings 11 | ############## 12 | PORT=3000 13 | 14 | ############## 15 | # Color Settings 16 | ############## 17 | COLOR_PRIMARY=#4C9A2A 18 | COLOR_SECONDARY=#8b91a0 -------------------------------------------------------------------------------- /bba-client/jsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "baseUrl": ".", 4 | "paths": { 5 | "@/*": [ 6 | "src/*" 7 | ] 8 | } 9 | }, 10 | "vueCompilerOptions": { 11 | "target": 2.7, 12 | "extensions": [ 13 | ".vue" 14 | ] 15 | }, 16 | "exclude": [ 17 | "node_modules", 18 | "dist" 19 | ] 20 | } -------------------------------------------------------------------------------- /bba-client/layouts/error.vue: -------------------------------------------------------------------------------- 1 | 14 | 15 | 39 | 40 | 45 | -------------------------------------------------------------------------------- /bba-client/layouts/loggedOut.vue: -------------------------------------------------------------------------------- 1 | 8 | 9 | 14 | -------------------------------------------------------------------------------- /bba-client/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "paradym-client", 3 | "version": "1.2.5", 4 | "description": "The client template application for the Paradym framework", 5 | "author": "Paradynamix (https://www.paradynamix.com/)", 6 | "private": true, 7 | "scripts": { 8 | "dev": "nuxt", 9 | "build": "nuxt build", 10 | "start": "nuxt start", 11 | "generate": "nuxt generate", 12 | "buildmajor": "npm version major && ng build --prod", 13 | "buildminor": "npm version minor && ng build --prod", 14 | "buildpatch": "npm version patch && nuxt build" 15 | }, 16 | "dependencies": { 17 | "@googlemaps/js-api-loader": "^1.16.6", 18 | "@jamescoyle/vue-icon": "^0.1.0", 19 | "@mdi/js": "^5.9.55", 20 | "@nuxtjs/auth-next": "^5.0.0-1610809099.bcf293f", 21 | "@nuxtjs/axios": "^5.12.5", 22 | "@nuxtjs/pwa": "^3.3.4", 23 | "@nuxtjs/sentry": "^5.0.0", 24 | "core-js": "^3.8.2", 25 | "lodash": "^4.17.21", 26 | "moment": "^2.29.1", 27 | "moment-timezone": "^0.5.33", 28 | "nuxt": "^2.14.12", 29 | "sass": "~1.32.6", 30 | "vue-barcode-reader": "0.0.3", 31 | "vue-qrcode-reader": "^2.3.18", 32 | "vue2-google-maps": "^0.10.7", 33 | "vuedraggable": "^2.24.3", 34 | "vuetify-datetime-picker": "^2.1.1", 35 | "wavesurfer.js": "^4.5.0" 36 | }, 37 | "devDependencies": { 38 | "@nuxtjs/vuetify": "^1.11.3", 39 | "dotenv": "^8.2.0" 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /bba-client/pages/account/index.vue: -------------------------------------------------------------------------------- 1 | 9 | 10 | 49 | -------------------------------------------------------------------------------- /bba-client/pages/account/name.vue: -------------------------------------------------------------------------------- 1 | 30 | 31 | 88 | -------------------------------------------------------------------------------- /bba-client/pages/account/password.vue: -------------------------------------------------------------------------------- 1 | 17 | 18 | 72 | -------------------------------------------------------------------------------- /bba-client/pages/asset/index.vue: -------------------------------------------------------------------------------- 1 | 9 | 10 | -------------------------------------------------------------------------------- /bba-client/pages/backupDatabase.vue: -------------------------------------------------------------------------------- 1 | 4 | 5 | -------------------------------------------------------------------------------- /bba-client/pages/backupPhotos.vue: -------------------------------------------------------------------------------- 1 | 14 | 15 | 52 | -------------------------------------------------------------------------------- /bba-client/pages/deal/index.vue: -------------------------------------------------------------------------------- 1 | 6 | 7 | 54 | -------------------------------------------------------------------------------- /bba-client/pages/location-management/index.vue: -------------------------------------------------------------------------------- 1 | 25 | 26 | -------------------------------------------------------------------------------- /bba-client/pages/loginAndRegister.vue: -------------------------------------------------------------------------------- 1 | 20 | 21 | 71 | 72 | 73 | -------------------------------------------------------------------------------- /bba-client/pages/logout.vue: -------------------------------------------------------------------------------- 1 | 4 | 5 | 21 | -------------------------------------------------------------------------------- /bba-client/pages/problem-types/index.vue: -------------------------------------------------------------------------------- 1 | 7 | 8 | 54 | -------------------------------------------------------------------------------- /bba-client/pages/problem/index.vue: -------------------------------------------------------------------------------- 1 | 7 | 8 | 87 | -------------------------------------------------------------------------------- /bba-client/pages/register.vue: -------------------------------------------------------------------------------- 1 | 33 | 34 | 79 | -------------------------------------------------------------------------------- /bba-client/pages/resendVerificationEmail.vue: -------------------------------------------------------------------------------- 1 | 4 | 5 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /bba-client/pages/test.vue: -------------------------------------------------------------------------------- 1 | 4 | 5 | 22 | -------------------------------------------------------------------------------- /bba-client/pages/upload.vue: -------------------------------------------------------------------------------- 1 | 6 | 7 | 22 | -------------------------------------------------------------------------------- /bba-client/pages/users/index.vue: -------------------------------------------------------------------------------- 1 | 5 | 6 | -------------------------------------------------------------------------------- /bba-client/pages/verifyEmail.vue: -------------------------------------------------------------------------------- 1 | 5 | 27 | 28 | 82 | -------------------------------------------------------------------------------- /bba-client/pages/webHookSetting.vue: -------------------------------------------------------------------------------- 1 | 10 | 11 | 46 | -------------------------------------------------------------------------------- /bba-client/plugins/QReader.js: -------------------------------------------------------------------------------- 1 | import Vue from "vue"; 2 | import VueQrcodeReader from "vue-qrcode-reader"; 3 | 4 | Vue.use(VueQrcodeReader); 5 | -------------------------------------------------------------------------------- /bba-client/plugins/barCode.js: -------------------------------------------------------------------------------- 1 | import Vue from "vue"; 2 | import { StreamBarcodeReader } from "vue-barcode-reader"; 3 | 4 | Vue.component("StreamBarcodeReader", StreamBarcodeReader); 5 | Vue.use(StreamBarcodeReader); 6 | -------------------------------------------------------------------------------- /bba-client/plugins/dateTimePicker.js: -------------------------------------------------------------------------------- 1 | import Vue from 'vue' 2 | import DatetimePicker from 'vuetify-datetime-picker' 3 | // (Optional) import 'vuetify-datetime-picker/src/stylus/main.styl' 4 | 5 | // Vue.component("DatetimePicker", DatetimePicker); 6 | Vue.use(DatetimePicker) -------------------------------------------------------------------------------- /bba-client/plugins/google-maps.js: -------------------------------------------------------------------------------- 1 | import Vue from "vue"; 2 | import * as VueGoogleMaps from "vue2-google-maps"; 3 | 4 | Vue.use(VueGoogleMaps, { 5 | load: { 6 | key: "AIzaSyAHRmARgxzw11yFWM8RFFElkXCO0I2xGV0", 7 | libraries: "places", 8 | }, 9 | }); 10 | -------------------------------------------------------------------------------- /bba-client/plugins/queuedUploads.js: -------------------------------------------------------------------------------- 1 | const axios = require('axios'); 2 | 3 | export default ({ store, app, $vuetify }) => { 4 | const config = app.$config; 5 | 6 | const uploadPendingImages = async function() { 7 | const uploadQueue = JSON.parse(localStorage.getItem('uploadQueue')) || []; 8 | const successfulUploads = []; 9 | 10 | for (let i = 0; i < uploadQueue.length; i++) { 11 | const queueItem = uploadQueue[i]; 12 | 13 | try { 14 | const result = await axios.post(config.baseURL+`/api/user/upload?orderid=${pictureName}`, 15 | formData 16 | ); 17 | if (result.success) { 18 | console.log(`Photo upload was successful for ${queueItem.pictureName}`); 19 | successfulUploads.push(i); 20 | } else { 21 | console.log(`Failed to upload photo for ${queueItem.pictureName}`); 22 | } 23 | } catch (error) { 24 | console.error('Error uploading image:', error); 25 | } 26 | } 27 | 28 | successfulUploads.reverse().forEach((index) => { 29 | uploadQueue.splice(index, 1); 30 | }); 31 | 32 | localStorage.setItem('uploadQueue', JSON.stringify(uploadQueue)); 33 | }; 34 | 35 | const handleNetworkChange = function() { 36 | if (navigator.onLine) { 37 | console.log('Internet connection restored!'); 38 | uploadPendingImages(); 39 | } 40 | }; 41 | 42 | app.mounted = async () => { 43 | window.addEventListener('online', handleNetworkChange); 44 | } 45 | } -------------------------------------------------------------------------------- /bba-client/plugins/theme.js: -------------------------------------------------------------------------------- 1 | export default ({ store, app, $vuetify }) => { 2 | function updateVuetifyTheme() { 3 | $vuetify.theme.isDark = store.state.theme.dark; 4 | $vuetify.theme.theme = store.state.theme.theme; 5 | 6 | let allThemes = store.state.theme.themes; 7 | allThemes.forEach((theme) => { 8 | if (theme.name == store.state.theme.theme) { 9 | console.log(`Applying theme '${theme.name}'`); 10 | $vuetify.theme.themes.dark = {}; 11 | $vuetify.theme.themes.light = {}; 12 | if (theme.hasOwnProperty("dark")) 13 | $vuetify.theme.themes.dark = theme.dark; 14 | if (theme.hasOwnProperty("light")) 15 | $vuetify.theme.themes.light = theme.light; 16 | if (theme.hasOwnProperty("theme")) { 17 | $vuetify.theme.themes.dark = theme.theme; 18 | $vuetify.theme.themes.light = theme.theme; 19 | } 20 | } 21 | }); 22 | } 23 | 24 | app.mounted = async () => { 25 | // Initialize theme 26 | await store.commit( 27 | "theme/initialize", 28 | Object.assign({}, $vuetify.theme.themes) 29 | ); // Load saved values from local storage into state 30 | updateVuetifyTheme(); 31 | // Watch for state changes & update theme 32 | store.subscribe((mutation, state) => { 33 | switch (mutation.type) { 34 | case "theme/setDark": 35 | case "theme/setTheme": 36 | localStorage.setItem( 37 | "theme", 38 | JSON.stringify({ 39 | dark: state.theme.dark, 40 | theme: state.theme.theme, 41 | }) 42 | ); 43 | updateVuetifyTheme(); 44 | } 45 | }); 46 | }; 47 | }; 48 | -------------------------------------------------------------------------------- /bba-client/static/favicon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jairo-matos/BikeDeliveryApp/2f323905cfa6f5a9ebe280529bc094b85fc9ca3e/bba-client/static/favicon.png -------------------------------------------------------------------------------- /bba-client/static/paradym_icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jairo-matos/BikeDeliveryApp/2f323905cfa6f5a9ebe280529bc094b85fc9ca3e/bba-client/static/paradym_icon.png -------------------------------------------------------------------------------- /bba-client/static/sw.js: -------------------------------------------------------------------------------- 1 | // THIS FILE SHOULD NOT BE VERSION CONTROLLED 2 | 3 | // https://github.com/NekR/self-destroying-sw 4 | 5 | self.addEventListener('install', function (e) { 6 | self.skipWaiting() 7 | }) 8 | 9 | self.addEventListener('activate', function (e) { 10 | self.registration.unregister() 11 | .then(function () { 12 | return self.clients.matchAll() 13 | }) 14 | .then(function (clients) { 15 | clients.forEach(client => client.navigate(client.url)) 16 | }) 17 | }) 18 | -------------------------------------------------------------------------------- /bba-client/store/index.js: -------------------------------------------------------------------------------- 1 | export const state = () => ({ 2 | hideNav: false, 3 | capturedImages: [], 4 | capturedPickupImages: [] 5 | }); 6 | export const mutations = { 7 | SET_CAPTURED_IMAGES_IN_VUEX(state, images) { 8 | state.capturedImages = images 9 | }, 10 | SET_CAPTURED_PICKUP_IMAGES_IN_VUEX(state, images) { 11 | state.capturedPickupImages = images 12 | }, 13 | showNav(state) { 14 | state.hideNav = false; 15 | }, 16 | hideNav(state) { 17 | state.hideNav = true; 18 | }, 19 | }; 20 | -------------------------------------------------------------------------------- /bba-client/store/snackbar.js: -------------------------------------------------------------------------------- 1 | import themes from "@/themes.json"; 2 | import Vue from "vue"; 3 | 4 | export const state = () => ({ 5 | busy: false, 6 | message: "Loading...", 7 | timeout: 5000, 8 | color: "", 9 | canClose: false, 10 | }); 11 | 12 | export const mutations = { 13 | resetState(state) { 14 | state.busy = false; 15 | state.message = "Loading..."; 16 | state.timeout = 5000; 17 | state.color = ""; 18 | state.canClose = false; 19 | }, 20 | setBusy(state, value) { 21 | state.busy = value; 22 | }, 23 | setMessage(state, value) { 24 | state.message = value; 25 | }, 26 | setTimeout(state, value) { 27 | state.timeout = value; 28 | }, 29 | setColor(state, value) { 30 | state.color = value; 31 | }, 32 | setCanClose(state, value) { 33 | state.canClose = value; 34 | }, 35 | }; 36 | 37 | export const actions = { 38 | // Settings 39 | async busy({ commit }, value) { 40 | // Reset State 41 | await commit("resetState"); 42 | 43 | // Set Timeout 44 | if (value.timeout) commit("setTimeout", parseInt(value.timeout)); 45 | else if (value.canClose) commit("setTimeout", 5000); 46 | 47 | // Set Color 48 | if (value.color) commit("setColor", value.color); 49 | else if (value.canClose) commit("setColor", "primary"); 50 | 51 | // Set TextColor 52 | if (value.textColor) commit("setTextColor", value.textColor); 53 | 54 | // Set CanClose 55 | if (value.canClose) commit("setCanClose", value.canClose); 56 | 57 | // Set Message 58 | if (value.message) commit("setMessage", value.message); 59 | 60 | // Make Busy 61 | commit("setBusy", true); 62 | }, 63 | 64 | async error({ commit, dispatch }, message) { 65 | dispatch("busy", { 66 | timeout: -1, 67 | color: "error", 68 | canClose: true, 69 | message: message, 70 | }); 71 | }, 72 | 73 | async success({ commit, dispatch }, message) { 74 | dispatch("busy", { 75 | timeout: 2000, 76 | color: "success", 77 | canClose: false, 78 | message: message, 79 | }); 80 | }, 81 | 82 | async warning({ commit, dispatch }, message) { 83 | dispatch("busy", { 84 | timeout: 3000, 85 | color: "warning", 86 | textColor: "black", 87 | canClose: true, 88 | message: message, 89 | }); 90 | }, 91 | }; 92 | -------------------------------------------------------------------------------- /bba-client/store/theme.js: -------------------------------------------------------------------------------- 1 | import themes from "@/themes.json"; 2 | import Vue from "vue"; 3 | 4 | export const state = () => ({ 5 | dark: false, 6 | theme: null, 7 | themes: themes, 8 | }); 9 | 10 | export const mutations = { 11 | initialize(state, vuetifyThemes) { 12 | vuetifyThemes.name = "Default"; 13 | state.themes = [vuetifyThemes, ...themes]; 14 | let saved = JSON.parse(localStorage.getItem("theme")); 15 | if (saved) { 16 | state.theme = saved.theme || "Default"; 17 | state.dark = saved.dark || false; 18 | } 19 | }, 20 | setTheme(state, value) { 21 | state.theme = value; 22 | }, 23 | setDark(state, value) { 24 | state.dark = value; 25 | }, 26 | toggleDark(state, value) { 27 | state.dark = !state.dark; 28 | }, 29 | }; 30 | -------------------------------------------------------------------------------- /bba-client/themes.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "name": "test2", 4 | "theme": { 5 | "primary": "#3f51b5", 6 | "accent": "#8c9eff", 7 | "secondary": "#b0bec5", 8 | "error": "#b71c1c", 9 | "info": "#4CAF50", 10 | "warning": "#2196F3", 11 | "success": "#4CAF50" 12 | } 13 | }, 14 | { 15 | "name": "lobo_tuerto", 16 | "dark": { 17 | "primary": "#21CFF3", 18 | "secondary": "#FF4081", 19 | "accent": "#ffe18d", 20 | "info": "#4CAF50", 21 | "warning": "#2196F3", 22 | "error": "#FB8C00", 23 | "success": "#4CAF50" 24 | }, 25 | "light": { 26 | "primary": "#1976D2", 27 | "secondary": "#e91e63", 28 | "accent": "#30b1dc", 29 | "success": "#4CAF50", 30 | "info": "#2196F3", 31 | "warning": "#FB8C00", 32 | "error": "#FF5252" 33 | } 34 | } 35 | ] 36 | -------------------------------------------------------------------------------- /bba-server/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jairo-matos/BikeDeliveryApp/2f323905cfa6f5a9ebe280529bc094b85fc9ca3e/bba-server/.DS_Store -------------------------------------------------------------------------------- /bba-server/api/extensions/fileFilter.js: -------------------------------------------------------------------------------- 1 | const matchAnything = /.*/; 2 | 3 | function isValid(file, accept) { 4 | let valid = validTypes(accept); 5 | let isValid = 6 | valid.extensions.reduce( 7 | (prev, regex) => prev || !!file.originalname.match(regex), 8 | false 9 | ) || 10 | valid.mimetypes.reduce( 11 | (prev, regex) => prev || !!file.mimetype.match(regex), 12 | false 13 | ); 14 | return isValid; 15 | } 16 | 17 | function validTypes(accept) { 18 | let validated = validatedAccept(accept); 19 | if (validated) { 20 | return { 21 | extensions: validated.extensions 22 | .map((ext) => ext.replace(/(\W)/g, "\\$1")) // Escape all potential regex tokens 23 | .map((rgxstr) => new RegExp(`${rgxstr}$`, "i")), // Transform into regex to look for extension 24 | mimetypes: validated.mimetypes 25 | .map((mt) => mt.replace(/([\-\+\/])/g, "\\$1")) // Escape special characters 26 | .map((mt) => mt.replace(/\*/g, "(?:[A-Za-z0-9\\-\\+]*)*")) // Enable wildcards 27 | .map((rgxstr) => new RegExp(`^${rgxstr}$`)), // Transform into regex 28 | }; 29 | } else { 30 | return { 31 | extensions: [matchAnything], 32 | mimetypes: [matchAnything], 33 | }; 34 | } 35 | } 36 | 37 | function validatedAccept(accept) { 38 | if (accept) { 39 | return { 40 | extensions: accept.split(",").filter((type) => type.match(/^\.(?!.*\/)/)), // Get only extension filters 41 | mimetypes: accept 42 | .split(",") 43 | .filter((type) => 44 | type.match( 45 | /^(?:(?:[A-Za-z0-9\-\+]*)|\*)\/(?:(?:[A-Za-z0-9\-\+]*)|\*)$/ 46 | ) 47 | ), // Get only mimetype filters 48 | }; 49 | } else { 50 | return null; 51 | } 52 | } 53 | 54 | module.exports = { isValid }; 55 | -------------------------------------------------------------------------------- /bba-server/api/extensions/verifyAuthHeader.js: -------------------------------------------------------------------------------- 1 | const jwt = require("jsonwebtoken"); 2 | const constVariables = require("./../../constants"); 3 | 4 | module.exports = (authHeader) => { 5 | // Check if a valid JWT token exists in the header 6 | if ( 7 | authHeader && 8 | authHeader.split(" ")[constVariables.NUMBER_0] === "Bearer" 9 | ) { 10 | const authorization = authHeader.split(" ")[constVariables.NUMBER_1]; 11 | try { 12 | const decoded = jwt.verify( 13 | authorization, 14 | process.env.JWT_SECRET /*, { ignoreExpiration: true } */ 15 | ); 16 | 17 | return decoded; 18 | } catch (e) { 19 | return null; 20 | } 21 | } else return null; 22 | }; 23 | -------------------------------------------------------------------------------- /bba-server/api/functions/notifications.js: -------------------------------------------------------------------------------- 1 | const { Notification, User } = require("./../../models"); 2 | 3 | module.exports.sendNotification = async function sendNotification(message, type, deliveryOrderId, tripId, userType, userId) 4 | { 5 | 6 | console.log('sending notification', message); 7 | 8 | var users = await User.findAll({ 9 | where: { 10 | userType: userType 11 | } 12 | }); 13 | 14 | //console.log(users, users); 15 | 16 | 17 | if(userId > 0) { 18 | Notification.create({ 19 | message: message, 20 | type: 1, 21 | deliveryOrderId: deliveryOrderId, 22 | tripId: tripId, 23 | userId: userId 24 | }); 25 | console.log(`Created notification successfully for user ${userId}`); 26 | } 27 | else { 28 | users.forEach( user => { 29 | console.log(`notifying ${user.email}`); 30 | Notification.create({ 31 | message: message, 32 | type: 1, 33 | deliveryOrderId: deliveryOrderId, 34 | tripId: tripId, 35 | userId: user.id 36 | }); 37 | 38 | console.log(`Created notification successfully for user ${user.id}`); 39 | }); 40 | 41 | } 42 | 43 | 44 | } 45 | -------------------------------------------------------------------------------- /bba-server/api/functions/sendEmail.js: -------------------------------------------------------------------------------- 1 | const nodemailer = require("nodemailer"); 2 | 3 | module.exports.sendEmail = async function sendEmail(message) { 4 | console.log('Sending an email message...') 5 | try { 6 | let transporter = nodemailer.createTransport({ 7 | host: process.env.SMTP_SERVER, 8 | port: process.env.SMTP_PORT, 9 | secure: process.env.SMTP_PORT == 465 ? true : false, 10 | auth: { 11 | user: process.env.SMTP_USER, 12 | pass: process.env.SMTP_PASSWORD, 13 | }, 14 | }) 15 | let result = await transporter.sendMail(message) 16 | console.log('Email sent.') 17 | return { success: true, messageId: result.messageId } 18 | } catch (err) { 19 | console.log('Error sending email: ' + err) 20 | return { error: true, message: err } 21 | } 22 | } -------------------------------------------------------------------------------- /bba-server/api/protected/user/allUsers.js: -------------------------------------------------------------------------------- 1 | const express = require("express"); 2 | const router = express.Router(); 3 | const status = require("http-status"); 4 | 5 | const models = require("../../../models"); 6 | const apiError = require("../../../libs/apiError"); 7 | const constVariables = require("../../../constants"); 8 | const apiMessage = require("./../../../language/en.json"); 9 | const verifyAuthHeader = require("../../extensions/verifyAuthHeader"); 10 | 11 | // ***************** 12 | // All Users Route 13 | // ***************** 14 | router.get("/", async (req, res) => { 15 | // Authenticate request & decode token 16 | const decodedToken = verifyAuthHeader(req.headers.authorization); 17 | if (!decodedToken || !decodedToken.id) 18 | return apiError( 19 | res, 20 | { 21 | type: "authentication", 22 | message: apiMessage.user.api_message.common.unauthorized_request, 23 | }, 24 | status.UNAUTHORIZED 25 | ); 26 | 27 | try { 28 | const email = req.query.email; 29 | const condition = email 30 | ? { email: { [models.Sequelize.Op.like]: `%${email}%` } } 31 | : null; 32 | 33 | // Find all users in the database 34 | const allUsers = await models.User.findAll({ 35 | where: condition, 36 | }); 37 | 38 | console.log(allUsers); 39 | 40 | if (!allUsers) 41 | return apiError( 42 | res, 43 | { 44 | type: "user", 45 | message: 46 | apiMessage.user.api_message.all_users.retrieving_all_users_error, 47 | }, 48 | status.INTERNAL_SERVER_ERROR 49 | ); 50 | else { 51 | const response = { 52 | success: true, 53 | allUsers: allUsers, 54 | message: 55 | apiMessage.user.api_message.all_users.retrieving_all_users_success, 56 | }; 57 | 58 | // Send the response 59 | return res.send(response); 60 | } 61 | } catch (error) { 62 | // Handle other errors 63 | if (error.errors) 64 | return apiError( 65 | res, 66 | { 67 | type: "unknown", 68 | message: error.errors[constVariables.NUMBER_0].message, 69 | }, 70 | status.INTERNAL_SERVER_ERROR 71 | ); 72 | else 73 | return apiError( 74 | res, 75 | { type: "unknown", message: error }, 76 | status.INTERNAL_SERVER_ERROR 77 | ); 78 | } 79 | }); 80 | 81 | module.exports = router; 82 | -------------------------------------------------------------------------------- /bba-server/api/protected/webHook/allWebHooks.js: -------------------------------------------------------------------------------- 1 | const express = require("express"); 2 | const router = express.Router(); 3 | const status = require("http-status"); 4 | 5 | const models = require("./../../../models"); 6 | const apiError = require("../../../libs/apiError"); 7 | const constVariables = require("../../../constants"); 8 | const apiMessage = require("./../../../language/en.json"); 9 | const verifyAuthHeader = require("./../../extensions/verifyAuthHeader"); 10 | 11 | // ***************** 12 | // Get All Web Hooks Route 13 | // ***************** 14 | router.get("/", async (req, res) => { 15 | // Authenticate request & decode token 16 | const decodedToken = verifyAuthHeader(req.headers.authorization); 17 | if (!decodedToken || !decodedToken.id) 18 | return apiError( 19 | res, 20 | { 21 | type: "authentication", 22 | message: apiMessage.user.api_message.common.unauthorized_request, 23 | }, 24 | status.UNAUTHORIZED 25 | ); 26 | 27 | try { 28 | const webHookUrl = req.query.webHookUrl; 29 | const condition = webHookUrl 30 | ? { webHookUrl: { [models.Sequelize.Op.like]: `%${webHookUrl}%` } } 31 | : null; 32 | 33 | // Find all web hooks in the database 34 | const allWebHooks = await models.WebHook.findAll({ 35 | where: condition, 36 | }); 37 | 38 | if (!allWebHooks) 39 | return apiError( 40 | res, 41 | { 42 | type: "webHook", 43 | message: 44 | apiMessage.web_hook.api_message.retrieving_all_web_hook_error, 45 | }, 46 | status.INTERNAL_SERVER_ERROR 47 | ); 48 | else { 49 | const response = { 50 | success: true, 51 | allWebHooks: allWebHooks, 52 | message: 53 | apiMessage.web_hook.api_message.retrieving_all_web_hook_success, 54 | }; 55 | 56 | // Send the response 57 | return res.send(response); 58 | } 59 | } catch (error) { 60 | // Handle other errors 61 | if (error.errors) 62 | return apiError( 63 | res, 64 | { 65 | type: "unknown", 66 | message: error.errors[constVariables.NUMBER_0].message, 67 | }, 68 | status.INTERNAL_SERVER_ERROR 69 | ); 70 | else 71 | return apiError( 72 | res, 73 | { type: "unknown", message: error }, 74 | status.INTERNAL_SERVER_ERROR 75 | ); 76 | } 77 | }); 78 | 79 | module.exports = router; 80 | -------------------------------------------------------------------------------- /bba-server/api/protected/webHook/createWebHook.js: -------------------------------------------------------------------------------- 1 | const express = require("express"); 2 | const router = express.Router(); 3 | const status = require("http-status"); 4 | 5 | const models = require("./../../../models"); 6 | const apiError = require("./../../../libs/apiError"); 7 | const constVariables = require("./../../../constants"); 8 | const apiMessage = require("./../../../language/en.json"); 9 | 10 | // ***************** 11 | // Create Web Hook route 12 | // ***************** 13 | router.post("/", async (req, res) => { 14 | // Check if webHookUrl was provided 15 | if (!req.body.webHookUrl) 16 | return apiError(res, { 17 | type: "webHook", 18 | message: apiMessage.web_hook.api_message.web_hook_url_required, 19 | }); 20 | 21 | try { 22 | // Create the web hook url 23 | const newWebHookUrl = await models.WebHook.build({ 24 | webHookUrl: req.body.webHookUrl, 25 | }).save(); 26 | 27 | if (newWebHookUrl) { 28 | const response = { 29 | success: true, 30 | webHookUrl: req.body.webHookUrl, 31 | message: apiMessage.web_hook.api_message.web_hook_created, 32 | }; 33 | 34 | // Send the response 35 | return res.send(response); 36 | } else 37 | return apiError( 38 | res, 39 | { 40 | type: "unknown", 41 | message: apiMessage.web_hook.api_message.error_creating_web_hook_url, 42 | }, 43 | status.INTERNAL_SERVER_ERROR 44 | ); 45 | } catch (error) { 46 | // Handle other errors 47 | if (error.errors) 48 | return apiError( 49 | res, 50 | { 51 | type: "unknown", 52 | message: error.errors[constVariables.NUMBER_0].message, 53 | }, 54 | status.INTERNAL_SERVER_ERROR 55 | ); 56 | else 57 | return apiError( 58 | res, 59 | { type: "unknown", message: error }, 60 | status.INTERNAL_SERVER_ERROR 61 | ); 62 | } 63 | }); 64 | 65 | module.exports = router; 66 | -------------------------------------------------------------------------------- /bba-server/api/protected/webHook/updateWebHook.js: -------------------------------------------------------------------------------- 1 | const express = require("express"); 2 | const router = express.Router(); 3 | const status = require("http-status"); 4 | 5 | const models = require("./../../../models"); 6 | const apiError = require("./../../../libs/apiError"); 7 | const constVariables = require("./../../../constants"); 8 | const apiMessage = require("./../../../language/en.json"); 9 | 10 | // ***************** 11 | // Create Web Hook route 12 | // ***************** 13 | router.put("/:id", async (req, res) => { 14 | // Check if webHookUrl was provided 15 | if (!req.body.webHookUrl) 16 | return apiError(res, { 17 | type: "webHook", 18 | message: apiMessage.web_hook.api_message.web_hook_url_required, 19 | }); 20 | 21 | try { 22 | const id = req.params.id; 23 | 24 | // Update the web hook url 25 | const updateWebHookUrl = await models.WebHook.update(req.body, { 26 | where: { id: id }, 27 | }); 28 | 29 | if (updateWebHookUrl) { 30 | const response = { 31 | success: true, 32 | webHookUrl: req.body.webHookUrl, 33 | message: apiMessage.web_hook.api_message.web_hook_updated, 34 | }; 35 | 36 | // Send the response 37 | return res.send(response); 38 | } else 39 | return apiError( 40 | res, 41 | { 42 | type: "unknown", 43 | message: apiMessage.web_hook.api_message.error_creating_web_hook_url, 44 | }, 45 | status.INTERNAL_SERVER_ERROR 46 | ); 47 | } catch (error) { 48 | // Handle other errors 49 | if (error.errors) 50 | return apiError( 51 | res, 52 | { 53 | type: "unknown", 54 | message: error.errors[constVariables.NUMBER_0].message, 55 | }, 56 | status.INTERNAL_SERVER_ERROR 57 | ); 58 | else 59 | return apiError( 60 | res, 61 | { type: "unknown", message: error }, 62 | status.INTERNAL_SERVER_ERROR 63 | ); 64 | } 65 | }); 66 | 67 | module.exports = router; 68 | -------------------------------------------------------------------------------- /bba-server/api/unprotected/user/activity.js: -------------------------------------------------------------------------------- 1 | const express = require("express"); 2 | const models = require("./../../../models"); 3 | 4 | const router = express.Router(); 5 | 6 | /** 7 | * Get all Activity 8 | * 9 | * @param {Request} req 10 | * @param {Response} res 11 | */ 12 | async function getAllActivities(_, res) { 13 | try { 14 | const data = await models.Activity.findAll(); 15 | 16 | return res.send(data); 17 | } catch (error) { 18 | console.log(error); 19 | } 20 | } 21 | 22 | /** 23 | * Create an Activity type 24 | * 25 | * @param {Request} req 26 | * @param {Response} res 27 | */ 28 | async function createAnActivity(req, res) { 29 | try { 30 | const newActivity = await models.Activity.create({ 31 | ...req.body, 32 | TimeStamp: new Date() 33 | }) 34 | return res.send(newActivity); 35 | } catch (error) { 36 | console.log(error); 37 | } 38 | } 39 | 40 | /** 41 | * Update an Activity type 42 | * 43 | * @param {Request} req 44 | * @param {Response} res 45 | */ 46 | async function updateAnActivity(req, res) { 47 | try { 48 | const Activity = await models.Activity.update({ 49 | ...req.body 50 | }, { 51 | where: { 52 | id: req.body.itemID 53 | } 54 | }) 55 | return res.send(Activity); 56 | } catch (error) { 57 | console.log(error); 58 | } 59 | } 60 | 61 | /** 62 | * Delete an Activity type 63 | * 64 | * @param {Request} req 65 | * @param {Response} res 66 | */ 67 | async function deleteAnActivity(req, res) { 68 | try { 69 | const deletedActivity = await models.Activity.destroy({ 70 | where: { 71 | id: req.body.itemID 72 | } 73 | }) 74 | 75 | const response = { 76 | success: true, 77 | result: deletedActivity, 78 | message: 79 | "Activity was successfully found and deleted.", 80 | }; 81 | return res.send(response); 82 | } catch (error) { 83 | console.log(error); 84 | } 85 | } 86 | 87 | router.get("/", getAllActivities); 88 | router.post("/", createAnActivity); 89 | router.put("/", updateAnActivity); 90 | router.delete("/", deleteAnActivity); 91 | 92 | module.exports = router; -------------------------------------------------------------------------------- /bba-server/api/unprotected/user/asset.js: -------------------------------------------------------------------------------- 1 | const express = require("express"); 2 | const router = express.Router(); 3 | const { Op, where } = require("sequelize"); 4 | const models = require("./../../../models"); 5 | 6 | router.post("/", async (req, res) => { 7 | try { 8 | console.log(req.body); 9 | const newAsset = await models.Asset.create({ 10 | barcode: req.body.barcode, 11 | item: req.body.item, 12 | lastDelivery: req.body.lastDelivery, 13 | status: req.body.status, 14 | 15 | }) 16 | return res.send(newAsset); 17 | } catch (error) { 18 | console.log(error); 19 | } 20 | }); 21 | 22 | router.put("/", async (req, res) => { 23 | try { 24 | console.log(req.body); 25 | const updateAsset = await models.Asset.update({ 26 | barcode: req.body.barcode, 27 | item: req.body.item, 28 | lastDelivery: req.body.lastDelivery, 29 | status: req.body.status, 30 | }, 31 | { 32 | where: { 33 | id: req.body.itemID 34 | } 35 | }); 36 | return res.send(updateAsset); 37 | } catch (error) { 38 | console.log(error); 39 | } 40 | }); 41 | 42 | router.delete("/", async (req, res) => { 43 | try { 44 | const deleteAsset = await models.Asset.destroy( 45 | { 46 | where: { 47 | id: req.body.itemID 48 | } 49 | }); 50 | const response = { 51 | success: true, 52 | result: deleteAsset, 53 | message: 54 | "Asset was successfully found and deleted.", 55 | }; 56 | return res.send(response); 57 | } catch (error) { 58 | console.log(error); 59 | } 60 | }); 61 | 62 | router.get("/", async (req,res) => { 63 | try { 64 | let data = []; 65 | data = await models.Asset.findAll({ 66 | 67 | }); 68 | return res.send(data); 69 | } catch (error) { 70 | console.log(error) 71 | } 72 | }); 73 | 74 | module.exports = router; -------------------------------------------------------------------------------- /bba-server/api/unprotected/user/communicationMessage.js: -------------------------------------------------------------------------------- 1 | const express = require("express"); 2 | const models = require("./../../../models"); 3 | 4 | const router = express.Router(); 5 | 6 | 7 | /** 8 | * Get all messages against a single delivery order 9 | * 10 | * @param {Request} req 11 | * @param {Response} res 12 | */ 13 | async function getMessagesForADeliveryOrder(req, res) { 14 | try { 15 | const deliveryOrderId = req.params.id; 16 | const data = await models.CommunicationMessage.findAll({ 17 | where: { 18 | DeliveryId: deliveryOrderId 19 | }, 20 | order: [["id", "ASC"]] 21 | }); 22 | 23 | return res.send(data); 24 | } catch (error) { 25 | console.log(error); 26 | } 27 | } 28 | 29 | /** 30 | * Get all messages against a single delivery order 31 | * 32 | * @param {Request} req 33 | * @param {Response} res 34 | */ 35 | async function createAMessagesForADeliveryOrder(req, res) { 36 | try { 37 | const data = await models.CommunicationMessage.create({ 38 | ...req.body, 39 | Direction: 1, 40 | Sent: new Date() 41 | }); 42 | 43 | return res.send(data); 44 | } catch (error) { 45 | console.log(error); 46 | } 47 | } 48 | router.get("/:id", getMessagesForADeliveryOrder); 49 | router.post("/", createAMessagesForADeliveryOrder); 50 | 51 | module.exports = router; 52 | -------------------------------------------------------------------------------- /bba-server/api/unprotected/user/deal.js: -------------------------------------------------------------------------------- 1 | const express = require("express"); 2 | const models = require("./../../../models"); 3 | 4 | const router = express.Router(); 5 | 6 | /** 7 | * Get all Deal types 8 | * 9 | * @param {Request} req 10 | * @param {Response} res 11 | */ 12 | async function getAllDeals(_, res) { 13 | try { 14 | const data = await models.Deal.findAll(); 15 | 16 | return res.send(data); 17 | } catch (error) { 18 | console.log(error); 19 | } 20 | } 21 | 22 | /** 23 | * Create an Deal type 24 | * 25 | * @param {Request} req 26 | * @param {Response} res 27 | */ 28 | async function createADeal(req, res) { 29 | try { 30 | const newDeal = await models.Deal.create({ 31 | ...req.body, 32 | TimeStamp: new Date() 33 | }) 34 | return res.send(newDeal); 35 | } catch (error) { 36 | console.log(error); 37 | } 38 | } 39 | 40 | /** 41 | * Update an Deal type 42 | * 43 | * @param {Request} req 44 | * @param {Response} res 45 | */ 46 | async function updateADeal(req, res) { 47 | try { 48 | const Deal = await models.Deal.update({ 49 | ...req.body 50 | }, { 51 | where: { 52 | id: req.body.itemID 53 | } 54 | }) 55 | return res.send(Deal); 56 | } catch (error) { 57 | console.log(error); 58 | } 59 | } 60 | 61 | /** 62 | * Delete an Deal type 63 | * 64 | * @param {Request} req 65 | * @param {Response} res 66 | */ 67 | async function deleteADeal(req, res) { 68 | try { 69 | const deletedDeal = await models.Deal.destroy({ 70 | where: { 71 | id: req.body.itemID 72 | } 73 | }) 74 | 75 | const response = { 76 | success: true, 77 | result: deletedDeal, 78 | message: 79 | "Deal was successfully found and deleted.", 80 | }; 81 | return res.send(response); 82 | } catch (error) { 83 | console.log(error); 84 | } 85 | } 86 | 87 | router.get("/", getAllDeals); 88 | router.post("/", createADeal); 89 | router.put("/", updateADeal); 90 | router.delete("/", deleteADeal); 91 | 92 | module.exports = router; -------------------------------------------------------------------------------- /bba-server/api/unprotected/user/downloadBackUpPhotos.js: -------------------------------------------------------------------------------- 1 | const express = require("express"); 2 | const router = express.Router(); 3 | const AdmZip = require('adm-zip'); 4 | const { readdirSync } = require("fs"); 5 | 6 | router.get("/", (req, res) => { 7 | try { 8 | let zip = new AdmZip(); 9 | readdirSync("./public").map((file) => zip.addLocalFile('./public/' + file)); 10 | zip.writeZip("./public/files.zip"); 11 | 12 | const data = zip.toBuffer(); 13 | 14 | return res.send(data); 15 | } catch (error) { 16 | console.log('error', error) 17 | } 18 | }); 19 | 20 | 21 | module.exports = router; -------------------------------------------------------------------------------- /bba-server/api/unprotected/user/drivers.js: -------------------------------------------------------------------------------- 1 | const express = require("express"); 2 | const models = require("../../../models"); 3 | 4 | const router = express.Router(); 5 | 6 | /** 7 | * Get all Deal types 8 | * 9 | * @param {Request} req 10 | * @param {Response} res 11 | */ 12 | async function getAllDrivers(_, res) { 13 | try { 14 | const data = await models.User.findAll({ 15 | where: { 16 | userType: 2 17 | } 18 | }); 19 | 20 | return res.send(data); 21 | } catch (error) { 22 | console.log(error); 23 | } 24 | } 25 | 26 | router.get("/", getAllDrivers); 27 | 28 | module.exports = router; -------------------------------------------------------------------------------- /bba-server/api/unprotected/user/getOrder.js: -------------------------------------------------------------------------------- 1 | const express = require("express"); 2 | const router = express.Router(); 3 | const { Op } = require("sequelize"); 4 | const moment = require("moment"); 5 | 6 | const models = require("./../../../models"); 7 | const { RecordingSettingsContext } = require("twilio/lib/rest/video/v1/recordingSettings"); 8 | const DeliveryOrderQuery = require("../../../translation/DeliveryOrderQuery"); 9 | 10 | router.post("/", async (req, res) => { 11 | // const deliveryOrder = await models.DeliveryOrders.findOne( 12 | // { 13 | // where: 14 | // { 15 | // orderid:req.query.orderid 16 | // } 17 | // }); 18 | 19 | const whereConditions = { 20 | and: { 21 | orderid:req.query.orderid 22 | }, 23 | } 24 | const query = DeliveryOrderQuery.translateDeliveryOrder(whereConditions); 25 | let data = await models.sequelize.query(query, { 26 | type: models.sequelize.QueryTypes.SELECT, 27 | }); 28 | let deliveryOrder = data[0]; 29 | if (deliveryOrder) { 30 | return 1; 31 | } else { 32 | return 0; 33 | } 34 | }); 35 | 36 | router.get("/", async (req, res) => { 37 | // const deliveryOrder = await models.DeliveryOrders.findOne( 38 | // { 39 | // where: 40 | // { 41 | // orderid:req.query.orderid 42 | // } 43 | // }); 44 | const whereConditions = { 45 | and: { 46 | orderid:req.query.orderid 47 | }, 48 | } 49 | const query = DeliveryOrderQuery.translateDeliveryOrder(whereConditions); 50 | let data = await models.sequelize.query(query, { 51 | type: models.sequelize.QueryTypes.SELECT 52 | }); 53 | let deliveryOrder = data[0]; 54 | if (deliveryOrder) { 55 | console.log("IN GET SUCCESS"); 56 | return res.send(deliveryOrder); 57 | } else { 58 | console.log("IN GET FAILURE"); 59 | return res.send(null); 60 | } 61 | }); 62 | 63 | module.exports = router; 64 | -------------------------------------------------------------------------------- /bba-server/api/unprotected/user/location.controller.js: -------------------------------------------------------------------------------- 1 | const express = require("express"); 2 | 3 | const router = express.Router(); 4 | 5 | const { 6 | getAllAreas, 7 | createAnArea, 8 | updateAnArea, 9 | deleteAnArea, 10 | getAllVillas, 11 | createAVilla, 12 | updateAVilla, 13 | deleteAVilla, 14 | getAllStreetAddresses, 15 | createAStreetAddress, 16 | updateAStreetAddress, 17 | deleteAStreetAddress, 18 | getAllVillasByArea, 19 | getAllStreetAddressesByVilla 20 | } = require("./location.service"); 21 | 22 | const AREA_RESOURCE_PATH = "/areas" 23 | const VILLA_RESOURCE_PATH = "/villas" 24 | const STREET_ADDRESS_RESOURCE_PATH = "/street-addresses" 25 | 26 | // Area 27 | router.get(AREA_RESOURCE_PATH, getAllAreas); 28 | router.post(AREA_RESOURCE_PATH, createAnArea); 29 | router.put(`${AREA_RESOURCE_PATH}/:id`, updateAnArea); 30 | router.delete(`${AREA_RESOURCE_PATH}/:id`, deleteAnArea); 31 | 32 | // Villa 33 | router.get(`${AREA_RESOURCE_PATH}${VILLA_RESOURCE_PATH}`, getAllVillas); 34 | router.get(`${AREA_RESOURCE_PATH}/:areaId${VILLA_RESOURCE_PATH}`, getAllVillasByArea); 35 | router.post(`${AREA_RESOURCE_PATH}/:areaId${VILLA_RESOURCE_PATH}`, createAVilla); 36 | router.put(`${AREA_RESOURCE_PATH}${VILLA_RESOURCE_PATH}/:id`, updateAVilla); 37 | router.delete(`${AREA_RESOURCE_PATH}${VILLA_RESOURCE_PATH}/:id`, deleteAVilla); 38 | 39 | // Street address 40 | router.get(`${AREA_RESOURCE_PATH}${VILLA_RESOURCE_PATH}${STREET_ADDRESS_RESOURCE_PATH}`, getAllStreetAddresses); 41 | router.get(`${AREA_RESOURCE_PATH}${VILLA_RESOURCE_PATH}/:villaId${STREET_ADDRESS_RESOURCE_PATH}`, getAllStreetAddressesByVilla); 42 | router.post(`${AREA_RESOURCE_PATH}${VILLA_RESOURCE_PATH}/:villaId${STREET_ADDRESS_RESOURCE_PATH}`, createAStreetAddress); 43 | router.put(`${AREA_RESOURCE_PATH}${VILLA_RESOURCE_PATH}${STREET_ADDRESS_RESOURCE_PATH}/:id`, updateAStreetAddress); 44 | router.delete(`${AREA_RESOURCE_PATH}${VILLA_RESOURCE_PATH}${STREET_ADDRESS_RESOURCE_PATH}/:id`, deleteAStreetAddress); 45 | 46 | module.exports = router; -------------------------------------------------------------------------------- /bba-server/api/unprotected/user/problem.js: -------------------------------------------------------------------------------- 1 | const express = require("express"); 2 | const models = require("./../../../models"); 3 | 4 | const router = express.Router(); 5 | 6 | /** 7 | * Get all Problem types 8 | * 9 | * @param {Request} req 10 | * @param {Response} res 11 | */ 12 | async function getAllProblems(_, res) { 13 | try { 14 | const data = await models.Problem.findAll(); 15 | 16 | return res.send(data); 17 | } catch (error) { 18 | console.log(error); 19 | } 20 | } 21 | 22 | /** 23 | * Create an Problem type 24 | * 25 | * @param {Request} req 26 | * @param {Response} res 27 | */ 28 | async function createAProblem(req, res) { 29 | try { 30 | const newProblem = await models.Problem.create({ 31 | ...req.body 32 | }) 33 | return res.send(newProblem); 34 | } catch (error) { 35 | console.log(error); 36 | } 37 | } 38 | 39 | /** 40 | * Update an Problem type 41 | * 42 | * @param {Request} req 43 | * @param {Response} res 44 | */ 45 | async function updateAProblem(req, res) { 46 | try { 47 | const Problem = await models.Problem.update({ 48 | ...req.body 49 | }, { 50 | where: { 51 | id: req.body.itemID 52 | } 53 | }) 54 | return res.send(Problem); 55 | } catch (error) { 56 | console.log(error); 57 | } 58 | } 59 | 60 | /** 61 | * Delete an Problem type 62 | * 63 | * @param {Request} req 64 | * @param {Response} res 65 | */ 66 | async function deleteAProblem(req, res) { 67 | try { 68 | const deletedProblem = await models.Problem.destroy({ 69 | where: { 70 | id: req.body.itemID 71 | } 72 | }) 73 | 74 | const response = { 75 | success: true, 76 | result: deletedProblem, 77 | message: 78 | "Problem was successfully found and deleted.", 79 | }; 80 | return res.send(response); 81 | } catch (error) { 82 | console.log(error); 83 | } 84 | } 85 | 86 | router.get("/", getAllProblems); 87 | router.post("/", createAProblem); 88 | router.put("/", updateAProblem); 89 | router.delete("/", deleteAProblem); 90 | 91 | module.exports = router; -------------------------------------------------------------------------------- /bba-server/api/unprotected/user/problemType.js: -------------------------------------------------------------------------------- 1 | const express = require("express"); 2 | const models = require("./../../../models"); 3 | 4 | const router = express.Router(); 5 | 6 | /** 7 | * Get all Problem types 8 | * 9 | * @param {Request} req 10 | * @param {Response} res 11 | */ 12 | async function getAllProblemTypes(_, res) { 13 | try { 14 | const data = await models.ProblemType.findAll(); 15 | 16 | return res.send(data); 17 | } catch (error) { 18 | console.log(error); 19 | } 20 | } 21 | 22 | /** 23 | * Create an Problem type 24 | * 25 | * @param {Request} req 26 | * @param {Response} res 27 | */ 28 | async function createAProblemType(req, res) { 29 | try { 30 | const newProblemType = await models.ProblemType.create({ 31 | ...req.body 32 | }) 33 | return res.send(newProblemType); 34 | } catch (error) { 35 | console.log(error); 36 | } 37 | } 38 | 39 | /** 40 | * Update an Problem type 41 | * 42 | * @param {Request} req 43 | * @param {Response} res 44 | */ 45 | async function updateAProblemType(req, res) { 46 | try { 47 | const ProblemType = await models.ProblemType.update({ 48 | ...req.body 49 | }, { 50 | where: { 51 | id: req.body.itemID 52 | } 53 | }) 54 | return res.send(ProblemType); 55 | } catch (error) { 56 | console.log(error); 57 | } 58 | } 59 | 60 | /** 61 | * Delete an Problem type 62 | * 63 | * @param {Request} req 64 | * @param {Response} res 65 | */ 66 | async function deleteAProblemType(req, res) { 67 | try { 68 | const deletedProblemType = await models.ProblemType.destroy({ 69 | where: { 70 | id: req.body.itemID 71 | } 72 | }) 73 | 74 | const response = { 75 | success: true, 76 | result: deletedProblemType, 77 | message: 78 | "Problem type was successfully found and deleted.", 79 | }; 80 | return res.send(response); 81 | } catch (error) { 82 | console.log(error); 83 | } 84 | } 85 | 86 | router.get("/", getAllProblemTypes); 87 | router.post("/", createAProblemType); 88 | router.put("/", updateAProblemType); 89 | router.delete("/", deleteAProblemType); 90 | 91 | module.exports = router; -------------------------------------------------------------------------------- /bba-server/api/unprotected/user/sendSMS.js: -------------------------------------------------------------------------------- 1 | const twilio = require("twilio"); 2 | const accountSid = process.env.ACCOUNT_SID; 3 | const authToken = process.env.AUTH_TOKEN; 4 | const client = require("twilio")(accountSid, authToken); 5 | 6 | const express = require("express"); 7 | const cors = require('cors'); 8 | const router = express.Router(); 9 | router.use(cors()); 10 | 11 | router.post("/", async (req, res) => { 12 | try 13 | { 14 | //LOCAL TESTING 15 | console.log("Hello from SendSMS", req.body.mediaUrl); 16 | 17 | let response = {}; 18 | if (req.body.mediaUrl === undefined || req.body.mediaUrl.length == 0) 19 | { 20 | response = await client.messages.create({ 21 | body: req.body.message, 22 | from: process.env.TWILIO_NUMBER, 23 | to: req.body.to, 24 | }); 25 | } 26 | else 27 | { 28 | let formattedNumber = req.body.to; 29 | if (formattedNumber.startsWith('+1')) { 30 | formattedNumber = formattedNumber.slice(2); 31 | } 32 | 33 | response = await client.messages.create({ 34 | body: req.body.message, 35 | from: process.env.TWILIO_NUMBER, 36 | to: formattedNumber, 37 | mediaUrl: req.body.mediaUrl 38 | }); 39 | } 40 | 41 | return res.status(200).json({ 42 | response: response, 43 | message: `Message Sent To ${req.body.to}`, 44 | }); 45 | } 46 | catch (err) 47 | { 48 | console.log(err); 49 | // res.status(500).json({ 50 | // Error: err, 51 | // }); 52 | } 53 | 54 | res.status(200).json({ 55 | Error: `Delivery has been completed, but the confirmation message was not sent.`, 56 | }); 57 | }); 58 | 59 | 60 | 61 | module.exports = router; 62 | -------------------------------------------------------------------------------- /bba-server/api/unprotected/user/template.js: -------------------------------------------------------------------------------- 1 | const express = require("express"); 2 | const router = express.Router(); 3 | const status = require("http-status"); 4 | const { Op } = require("sequelize"); 5 | 6 | const models = require("../../../models"); 7 | const apiError = require("../../../libs/apiError"); 8 | const constVariables = require("../../../constants"); 9 | const apiMessage = require("../../../language/en.json"); 10 | 11 | router.post("/", async (req, res) => { 12 | const data = await models.Templates.findOne(); 13 | if (data) { 14 | data.body = req.body.template; 15 | await data.save(); 16 | } else { 17 | await models.Templates.build({ body: req.body.template }).save(); 18 | } 19 | //received the json here req.body 20 | // console.log(req.body) 21 | res.send(req.body); 22 | }); 23 | 24 | router.get("/", async (req, res) => { 25 | const data = await models.Templates.findAll(); 26 | return res.send(data[0]); 27 | }); 28 | 29 | module.exports = router; 30 | -------------------------------------------------------------------------------- /bba-server/api/unprotected/user/trip.controller.js: -------------------------------------------------------------------------------- 1 | const express = require("express"); 2 | 3 | const router = express.Router(); 4 | 5 | const { 6 | newTrip, 7 | getAllTrips, 8 | getActiveTrips, 9 | getTripDetail, 10 | releaseTrip, 11 | checkStock, 12 | createTrip, 13 | checkOrderStock 14 | } = require("./trip.service"); 15 | 16 | // Area 17 | router.get("/", getAllTrips); 18 | router.get("/active", getActiveTrips); 19 | router.get("/:id", getTripDetail); 20 | // router.post(AREA_RESOURCE_PATH, createAnArea); 21 | // router.put(`${AREA_RESOURCE_PATH}/:id`, updateAnArea); 22 | // router.delete(`${AREA_RESOURCE_PATH}/:id`, deleteAnArea); 23 | 24 | 25 | router.post('/', newTrip); 26 | router.post('/release', releaseTrip); 27 | router.post('/createTrip', createTrip); 28 | router.post('/checkstock', checkStock); 29 | router.get('/checkOrderStock', checkOrderStock); 30 | 31 | module.exports = router; 32 | -------------------------------------------------------------------------------- /bba-server/api/unprotected/user/twilio.js: -------------------------------------------------------------------------------- 1 | const twilio = require("twilio"); 2 | const accountSid = process.env.ACCOUNT_SID; 3 | const authToken = process.env.AUTH_TOKEN; 4 | const client = require("twilio")(accountSid, authToken); 5 | const MessagingResponse = require('twilio').twiml.MessagingResponse; 6 | 7 | const express = require("express"); 8 | const cors = require('cors'); 9 | const router = express.Router(); 10 | router.use(cors()); 11 | 12 | router.get("/", async (req, res) => { 13 | const search = req.query.search; 14 | const phoneNumber = req.query.phoneNumber 15 | let fromMessages = []; 16 | let toMessages = []; 17 | console.log(req.query); 18 | 19 | if (phoneNumber) { 20 | client.messages.list({ limit: 1000, from: phoneNumber }).then(messages => { 21 | messages.forEach(x => { 22 | x.dateSent = x.dateSent.toLocaleString('en-US'); 23 | fromMessages = messages; 24 | }); 25 | }); 26 | client.messages.list({ limit: 1000, to: phoneNumber }).then(secondMessages => { 27 | secondMessages.forEach(x => { 28 | x.dateSent = x.dateSent.toLocaleString('en-US'); 29 | toMessages = secondMessages; 30 | }); 31 | return res.send(fromMessages.concat(toMessages)); 32 | }); 33 | } else { 34 | client.messages.list({ limit: 1000 }).then(messages => { 35 | messages.forEach(x => { 36 | x.dateSent = x.dateSent.toLocaleString('en-US') 37 | }); 38 | return res.send(messages); 39 | }); 40 | } 41 | }) 42 | 43 | router.post("/sms", async (req, res) => { 44 | const twiml = new MessagingResponse(); 45 | 46 | twiml.message('Any messages will not currently been seen by a support individual. If you are having an issue with your delivery, please contact that following number: 843-678-3720'); 47 | 48 | res.writeHead(200, { 'Content-Type': 'text/xml' }); 49 | res.end(twiml.toString()); 50 | }); 51 | 52 | 53 | 54 | module.exports = router; 55 | -------------------------------------------------------------------------------- /bba-server/api/unprotected/user/webhookmap.js: -------------------------------------------------------------------------------- 1 | const express = require("express"); 2 | const router = express.Router(); 3 | const status = require("http-status"); 4 | const { Op } = require("sequelize"); 5 | 6 | const models = require("../../../models"); 7 | const apiError = require("../../../libs/apiError"); 8 | const constVariables = require("../../../constants"); 9 | const apiMessage = require("../../../language/en.json"); 10 | 11 | 12 | router.post("/", async (req, res) => { 13 | 14 | const data = JSON.parse(JSON.stringify(req.body)); 15 | for(let i =0;i { 36 | const data = await models.WebhookMaps.findAll(); 37 | return res.send(data); 38 | }); 39 | 40 | module.exports = router; 41 | -------------------------------------------------------------------------------- /bba-server/config/config.js: -------------------------------------------------------------------------------- 1 | require('dotenv').config() 2 | 3 | module.exports = { 4 | development: { 5 | username: process.env.DB_USER, 6 | password: process.env.DB_PASSWORD, 7 | database: process.env.DB_NAME, 8 | host: process.env.DB_HOST, 9 | dialect: 'mysql', 10 | logging: process.env.LOG_SQL == 1 ? true : false, 11 | }, 12 | test: { 13 | username: process.env.DB_USER, 14 | password: process.env.DB_PASSWORD, 15 | database: process.env.DB_NAME, 16 | host: process.env.DB_HOST, 17 | dialect: 'mysql', 18 | logging: process.env.LOG_SQL == 1 ? true : false, 19 | }, 20 | production: { 21 | username: process.env.DB_USER, 22 | password: process.env.DB_PASSWORD, 23 | database: process.env.DB_NAME, 24 | host: process.env.DB_HOST, 25 | dialect: 'mysql', 26 | logging: process.env.LOG_SQL == 1 ? true : false, 27 | }, 28 | } 29 | 30 | -------------------------------------------------------------------------------- /bba-server/constants/constant.js: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jairo-matos/BikeDeliveryApp/2f323905cfa6f5a9ebe280529bc094b85fc9ca3e/bba-server/constants/constant.js -------------------------------------------------------------------------------- /bba-server/constants/index.js: -------------------------------------------------------------------------------- 1 | /************************** 2 | Number Constant Variables 3 | ***************************/ 4 | const NUMBER_0 = 0 5 | const NUMBER_1 = 1 6 | const NUMBER_16 = 16 7 | const NUMBER_32 = 32 8 | const NUMBER_64 = 64 9 | const NUMBER_465 = 465 10 | 11 | module.exports = { 12 | NUMBER_0, 13 | NUMBER_1, 14 | NUMBER_16, 15 | NUMBER_32, 16 | NUMBER_64, 17 | NUMBER_465 18 | } -------------------------------------------------------------------------------- /bba-server/ecosystem.config.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | apps: [{ 3 | name: 'bba-server', 4 | script: 'index.js', // the path of the script you want to execute, 5 | // Options reference: https://pm2.keymetrics.io/docs/usage/application-declaration/ 6 | instances: 1, 7 | autorestart: true, 8 | watch: false, 9 | error_file: 'err.log', 10 | out_file: 'out.log', 11 | log_file: 'combined.log', 12 | time: true, 13 | env: { 14 | }, 15 | }], 16 | }; -------------------------------------------------------------------------------- /bba-server/env.example: -------------------------------------------------------------------------------- 1 | ############## 2 | # App Settings 3 | ############## 4 | APP_NAME=Bike Delivery App 5 | APP_EMAIL=krahamatullah@paradynamix.com 6 | BASE_URL=http://localhost:3100 7 | CLIENT_URL=http://localhost:3000 8 | 9 | ################ 10 | # Color Settings 11 | ################ 12 | COLOR_PRIMARY=#4C9A2A 13 | COLOR_SECONDARY=#B50000 14 | 15 | ################# 16 | # Server Settings 17 | ################# 18 | PORT=3100 19 | JWT_SECRET=SECRET_KEY 20 | 21 | ################### 22 | # Database Settings 23 | ################### 24 | DB_HOST=127.0.0.1 25 | DB_USER=root 26 | DB_PASSWORD= 27 | DB_NAME=bbapp_dev 28 | SEED=1 29 | LOG_SQL=0 30 | 31 | ############### 32 | # SMTP Settings 33 | ############### 34 | SMTP_USER=AKIA227L6NAZORZI6THJ 35 | SMTP_PASSWORD=BHiIldH71AdvWkzzdrKpJtB7dCVF14jQLyMDrJ6kdEPf 36 | SMTP_SERVER=email-smtp.us-east-1.amazonaws.com 37 | SMTP_PORT=465 38 | 39 | ################# 40 | # Upload Settings 41 | ################# 42 | UPLOAD_ACCEPT=image/gif,.jpg,text/css,.txt 43 | 44 | ################# 45 | # Sentry Settings 46 | ################# 47 | SENTRY_DSN=https://b4b485cdbb6b421493eb57a4bcf42b61@o382651.ingest.sentry.io/5620152 48 | 49 | 50 | ################# 51 | # Twilio Settings 52 | ################# 53 | ACCOUNT_SID=ACe0b5b9e4e3af7f70aa79825edc30295e 54 | AUTH_TOKEN=fd5a29c4afcca0c2fbafdc68d2d04ecd 55 | TWILIO_NUMBER=+17144850047 -------------------------------------------------------------------------------- /bba-server/libs/apiError.js: -------------------------------------------------------------------------------- 1 | const status = require('http-status'); 2 | 3 | module.exports = (res, msg, code) => { 4 | code = code ? code : status.BAD_REQUEST; 5 | console.log(`Error ${code}: ${msg.message}`); 6 | return res.status(code).send(msg); 7 | }; 8 | -------------------------------------------------------------------------------- /bba-server/libs/generateOTPPassword.js: -------------------------------------------------------------------------------- 1 | module.exports = (length) => { 2 | const charset = "0123456789"; 3 | let result = ""; 4 | for (let i = 0, n = charset.length; i < length; ++i) { 5 | result += charset.charAt(Math.floor(Math.random() * n)); 6 | } 7 | return result; 8 | }; 9 | -------------------------------------------------------------------------------- /bba-server/libs/iterate.js: -------------------------------------------------------------------------------- 1 | module.exports = function iterate(obj, key){ 2 | var result; 3 | for (var property in obj) { 4 | if (obj.hasOwnProperty(property)) { 5 | // in case it is an object 6 | if (typeof obj[property] === "object") { 7 | result = iterate(obj[property], key); 8 | 9 | if (typeof result !== "undefined") { 10 | return result; 11 | } 12 | } 13 | else if (property === key) { 14 | return obj[key]; // returns the value 15 | } 16 | } 17 | } 18 | }; -------------------------------------------------------------------------------- /bba-server/libs/randomCharacters.js: -------------------------------------------------------------------------------- 1 | module.exports = (length) => { 2 | let result = ""; 3 | const characters = 4 | "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"; 5 | let charactersLength = characters.length; 6 | for (let i = 0; i < length; i++) { 7 | result += characters.charAt(Math.floor(Math.random() * charactersLength)); 8 | } 9 | return result; 10 | }; 11 | -------------------------------------------------------------------------------- /bba-server/libs/randomDate.js: -------------------------------------------------------------------------------- 1 | module.exports = (start, end) => { 2 | if (!start) start = new Date(2012, 0, 1); 3 | if (!end) end = new Date(); 4 | 5 | return new Date( 6 | start.getTime() + Math.random() * (end.getTime() - start.getTime()) 7 | ); 8 | } 9 | -------------------------------------------------------------------------------- /bba-server/libs/validateEmail.js: -------------------------------------------------------------------------------- 1 | module.exports = (email) => { 2 | const re = /^(([^<>()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/; 3 | return re.test(email); 4 | }; 5 | -------------------------------------------------------------------------------- /bba-server/middleware/auth.js: -------------------------------------------------------------------------------- 1 | require("dotenv").config(); 2 | 3 | const jwt = require("jsonwebtoken"); 4 | const status = require("http-status"); 5 | const models = require("../models"); 6 | const constVariables = require("./../constants"); 7 | const apiMessage = require("./../language/en.json"); 8 | 9 | module.exports = (req, res, next) => { 10 | try { 11 | // Decode the token & get the user id 12 | const token = req.headers.authorization.split(" ")[constVariables.NUMBER_1]; 13 | const decoded = jwt.verify(token, process.env.JWT_SECRET); 14 | const userId = decoded.id; 15 | // Locate the user 16 | models.User 17 | .findOne({ where: { id: userId } }) 18 | .then((user) => { 19 | if (user) { 20 | next(); 21 | } // user found 22 | else { 23 | throw "User not found"; 24 | } // user not found 25 | }) 26 | .catch((err) => { 27 | throw err; 28 | }); 29 | } catch { 30 | res.status(status.UNAUTHORIZED).send({ 31 | type: "auth", 32 | message: apiMessage.user.api_message.common.unauthorized_request, 33 | }); 34 | } 35 | }; 36 | -------------------------------------------------------------------------------- /bba-server/migrations/01-create-Users.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | module.exports = { 3 | up: async (queryInterface, Sequelize) => { 4 | await queryInterface.createTable("Users", { 5 | id: { 6 | type: Sequelize.INTEGER, 7 | primaryKey: true, 8 | allowNull: false, 9 | autoIncrement: true, 10 | }, 11 | email: { 12 | type: Sequelize.STRING, 13 | allowNull: false, 14 | unique: true, 15 | }, 16 | password: { 17 | type: Sequelize.STRING, 18 | allowNull: false, 19 | }, 20 | name: { 21 | type: Sequelize.STRING, 22 | }, 23 | isVerified: { 24 | type: Sequelize.BOOLEAN, 25 | defaultValue: 0, 26 | }, 27 | userType: { 28 | type: Sequelize.INTEGER, 29 | defaultValue: 1, 30 | comment: "1=client; 2=delivery driver; 3=system admin" 31 | }, 32 | createdAt: { 33 | allowNull: true, 34 | type: Sequelize.DATE, 35 | }, 36 | updatedAt: { 37 | allowNull: true, 38 | type: Sequelize.DATE, 39 | }, 40 | deletedAt: { 41 | allowNull: true, 42 | type: Sequelize.DATE, 43 | }, 44 | }); 45 | 46 | // Expire users after 1 month of being unverified (check every day) 47 | queryInterface.sequelize.query(` 48 | CREATE EVENT IF NOT EXISTS expireUsers 49 | ON SCHEDULE EVERY 1 DAY 50 | DO DELETE FROM users WHERE isVerified = FALSE AND createdAt < DATE_SUB(NOW(), INTERVAL 1 MONTH); 51 | `); 52 | console.log("expireUsers event created"); 53 | }, 54 | down: async (queryInterface, Sequelize) => { 55 | await queryInterface.dropTable("Users"); 56 | queryInterface.sequelize.query(`DROP EVENT IF EXISTS expireUsers`); 57 | console.log("expireUsers event dropped"); 58 | }, 59 | }; 60 | -------------------------------------------------------------------------------- /bba-server/migrations/02-create-VerificationTokens.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | module.exports = { 3 | up: async (queryInterface, Sequelize) => { 4 | await queryInterface.createTable("VerificationTokens", { 5 | id: { 6 | type: Sequelize.INTEGER, 7 | primaryKey: true, 8 | allowNull: false, 9 | autoIncrement: true, 10 | }, 11 | userId: { 12 | type: Sequelize.INTEGER, 13 | references: { 14 | model: "Users", 15 | key: "id", 16 | }, 17 | allowNull: false, 18 | onDelete: "cascade", 19 | }, 20 | token: { 21 | type: Sequelize.STRING, 22 | allowNull: false, 23 | }, 24 | createdAt: { 25 | allowNull: true, 26 | type: Sequelize.DATE, 27 | }, 28 | }); 29 | 30 | // Expire tokens after 1 day (check every hour) 31 | queryInterface.sequelize.query(` 32 | CREATE EVENT IF NOT EXISTS expireVerificationTokens 33 | ON SCHEDULE EVERY 1 HOUR 34 | DO DELETE FROM verificationtokens WHERE createdAt < DATE_SUB(NOW(), INTERVAL 1 DAY); 35 | `); 36 | console.log("expireVerificationTokens event created"); 37 | }, 38 | down: async (queryInterface, Sequelize) => { 39 | await queryInterface.dropTable("VerificationTokens"); 40 | queryInterface.sequelize.query( 41 | `DROP EVENT IF EXISTS expireVerificationTokens` 42 | ); 43 | console.log("expireVerificationTokens event dropped"); 44 | }, 45 | }; 46 | -------------------------------------------------------------------------------- /bba-server/migrations/03-create-ResetTokens.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | module.exports = { 3 | up: async (queryInterface, Sequelize) => { 4 | await queryInterface.createTable("ResetTokens", { 5 | id: { 6 | type: Sequelize.INTEGER, 7 | primaryKey: true, 8 | allowNull: false, 9 | autoIncrement: true, 10 | }, 11 | userId: { 12 | type: Sequelize.INTEGER, 13 | references: { 14 | model: "Users", 15 | key: "id", 16 | }, 17 | allowNull: false, 18 | onDelete: "cascade", 19 | }, 20 | token: { 21 | type: Sequelize.STRING, 22 | allowNull: false, 23 | }, 24 | createdAt: { 25 | allowNull: true, 26 | type: Sequelize.DATE, 27 | }, 28 | }); 29 | 30 | // Expire tokens after 1 hour (check every 15 minutes) 31 | queryInterface.sequelize.query(` 32 | CREATE EVENT IF NOT EXISTS expireResetTokens 33 | ON SCHEDULE EVERY 15 MINUTE 34 | DO DELETE FROM resettokens WHERE createdAt < DATE_SUB(NOW(), INTERVAL 1 HOUR); 35 | `); 36 | console.log("expireResetTokens event created"); 37 | }, 38 | down: async (queryInterface, Sequelize) => { 39 | await queryInterface.dropTable("ResetTokens"); 40 | queryInterface.sequelize.query(`DROP EVENT IF EXISTS expireResetTokens`); 41 | console.log("expireResetTokens event dropped"); 42 | }, 43 | }; 44 | -------------------------------------------------------------------------------- /bba-server/migrations/04-create-Uploads.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | module.exports = { 3 | up: async (queryInterface, Sequelize) => { 4 | await queryInterface.createTable('Uploads', { 5 | id: { 6 | allowNull: false, 7 | autoIncrement: true, 8 | primaryKey: true, 9 | type: Sequelize.INTEGER 10 | }, 11 | filename: Sequelize.STRING, 12 | originalName: Sequelize.STRING, 13 | encoding: Sequelize.STRING, 14 | mimetype: Sequelize.STRING, 15 | size: Sequelize.INTEGER, 16 | createdAt: { 17 | allowNull: true, 18 | type: Sequelize.DATE 19 | } 20 | }); 21 | }, 22 | down: async (queryInterface, Sequelize) => { 23 | await queryInterface.dropTable('Uploads'); 24 | } 25 | }; 26 | -------------------------------------------------------------------------------- /bba-server/migrations/05-create-WebHook.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | module.exports = { 3 | up: async (queryInterface, Sequelize) => { 4 | await queryInterface.createTable("WebHooks", { 5 | id: { 6 | allowNull: false, 7 | autoIncrement: true, 8 | primaryKey: true, 9 | type: Sequelize.INTEGER, 10 | }, 11 | webHookUrl: { 12 | type: Sequelize.STRING, 13 | validate: { 14 | isUrl: true, 15 | }, 16 | }, 17 | isActive: { 18 | allowNull: false, 19 | type: Sequelize.BOOLEAN, 20 | }, 21 | userId: { 22 | type: Sequelize.INTEGER, 23 | references: { 24 | model: "Users", 25 | key: "id", 26 | }, 27 | allowNull: false, 28 | onDelete: "cascade", 29 | }, 30 | createdAt: { 31 | allowNull: true, 32 | type: Sequelize.DATE, 33 | }, 34 | updatedAt: { 35 | allowNull: true, 36 | type: Sequelize.DATE, 37 | }, 38 | }); 39 | }, 40 | down: async (queryInterface, Sequelize) => { 41 | await queryInterface.dropTable("WebHooks"); 42 | }, 43 | }; 44 | -------------------------------------------------------------------------------- /bba-server/migrations/06-create-DeliveryOrder.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | module.exports = { 3 | up: async (queryInterface, Sequelize) => { 4 | await queryInterface.createTable("DeliveryOrders", { 5 | id: { 6 | allowNull: false, 7 | autoIncrement: true, 8 | primaryKey: true, 9 | type: Sequelize.INTEGER, 10 | }, 11 | date: { 12 | type: Sequelize.DATE, 13 | allowNull: true, 14 | }, 15 | name: { 16 | type: Sequelize.STRING, 17 | allowNull: true, 18 | }, 19 | location: { 20 | type: Sequelize.STRING, 21 | allowNull: true, 22 | }, 23 | orderid: { 24 | type: Sequelize.STRING, 25 | allowNull: true, 26 | }, 27 | rack: { 28 | type: Sequelize.STRING, 29 | allowNull: true, 30 | }, 31 | color: { 32 | type: Sequelize.STRING, 33 | allowNull: true, 34 | }, 35 | combination: { 36 | type: Sequelize.STRING, 37 | allowNull: true, 38 | }, 39 | lock: { 40 | type: Sequelize.STRING, 41 | allowNull: true, 42 | }, 43 | mobileNo: { 44 | type: Sequelize.STRING, 45 | allowNull: true, 46 | }, 47 | barcode: { 48 | type: Sequelize.STRING, 49 | allowNull: true, 50 | }, 51 | createdAt: { 52 | allowNull: true, 53 | type: Sequelize.DATE, 54 | }, 55 | updatedAt: { 56 | allowNull: true, 57 | type: Sequelize.DATE, 58 | }, 59 | }); 60 | }, 61 | down: async (queryInterface, Sequelize) => { 62 | await queryInterface.dropTable("WebHooks"); 63 | }, 64 | }; 65 | -------------------------------------------------------------------------------- /bba-server/migrations/07-create-WebhookMap.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | module.exports = { 3 | up: async (queryInterface, Sequelize) => { 4 | await queryInterface.createTable("WebhookMaps", { 5 | id: { 6 | allowNull: false, 7 | autoIncrement: true, 8 | primaryKey: true, 9 | type: Sequelize.INTEGER, 10 | }, 11 | 12 | table_key: { 13 | type: Sequelize.STRING, 14 | allowNull: true, 15 | }, 16 | 17 | json_key: { 18 | type: Sequelize.STRING, 19 | allowNull: true, 20 | }, 21 | 22 | createdAt: { 23 | allowNull: true, 24 | type: Sequelize.DATE, 25 | }, 26 | updatedAt: { 27 | allowNull: true, 28 | type: Sequelize.DATE, 29 | }, 30 | }); 31 | }, 32 | down: async (queryInterface, Sequelize) => { 33 | await queryInterface.dropTable("WebhookMaps"); 34 | }, 35 | }; 36 | -------------------------------------------------------------------------------- /bba-server/migrations/08-create-Template.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | module.exports = { 3 | up: async (queryInterface, Sequelize) => { 4 | await queryInterface.createTable("Templates", { 5 | id: { 6 | allowNull: false, 7 | autoIncrement: true, 8 | primaryKey: true, 9 | type: Sequelize.INTEGER, 10 | }, 11 | 12 | body: { 13 | type: Sequelize.STRING, 14 | allowNull: true, 15 | }, 16 | 17 | createdAt: { 18 | allowNull: true, 19 | type: Sequelize.DATE, 20 | }, 21 | updatedAt: { 22 | allowNull: true, 23 | type: Sequelize.DATE, 24 | }, 25 | }); 26 | }, 27 | down: async (queryInterface, Sequelize) => { 28 | await queryInterface.dropTable("Templates"); 29 | }, 30 | }; 31 | -------------------------------------------------------------------------------- /bba-server/migrations/09-create-File.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | module.exports = { 3 | up: async (queryInterface, Sequelize) => { 4 | await queryInterface.createTable("Files", { 5 | id: { 6 | allowNull: false, 7 | autoIncrement: true, 8 | primaryKey: true, 9 | type: Sequelize.INTEGER, 10 | }, 11 | 12 | orderid: { 13 | type: Sequelize.STRING, 14 | allowNull: true, 15 | }, 16 | filepath: { 17 | type: Sequelize.STRING, 18 | allowNull: true, 19 | }, 20 | 21 | createdAt: { 22 | allowNull: true, 23 | type: Sequelize.DATE, 24 | }, 25 | updatedAt: { 26 | allowNull: true, 27 | type: Sequelize.DATE, 28 | }, 29 | }); 30 | }, 31 | down: async (queryInterface, Sequelize) => { 32 | await queryInterface.dropTable("Files"); 33 | }, 34 | }; 35 | -------------------------------------------------------------------------------- /bba-server/migrations/09-create-Log.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | module.exports = { 3 | up: async (queryInterface, Sequelize) => { 4 | await queryInterface.createTable("Logs", { 5 | id: { 6 | allowNull: false, 7 | autoIncrement: true, 8 | primaryKey: true, 9 | type: Sequelize.INTEGER, 10 | }, 11 | 12 | json: { 13 | type: Sequelize.TEXT, 14 | allowNull: true, 15 | }, 16 | createdAt: { 17 | allowNull: true, 18 | type: Sequelize.DATE, 19 | }, 20 | updatedAt: { 21 | allowNull: true, 22 | type: Sequelize.DATE, 23 | }, 24 | }); 25 | }, 26 | down: async (queryInterface, Sequelize) => { 27 | await queryInterface.dropTable("Logs"); 28 | }, 29 | }; 30 | -------------------------------------------------------------------------------- /bba-server/migrations/10-create-Lock.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | module.exports = { 3 | up: async (queryInterface, Sequelize) => { 4 | await queryInterface.createTable("Locks", { 5 | id: { 6 | allowNull: false, 7 | autoIncrement: true, 8 | primaryKey: true, 9 | type: Sequelize.INTEGER, 10 | }, 11 | 12 | orderid: { 13 | type: Sequelize.STRING, 14 | allowNull: true, 15 | }, 16 | 17 | lockId: { 18 | type: Sequelize.STRING, 19 | allowNull: true, 20 | }, 21 | 22 | color: { 23 | type: Sequelize.STRING, 24 | allowNull: true, 25 | }, 26 | 27 | combination: { 28 | type: Sequelize.STRING, 29 | allowNull: true, 30 | }, 31 | 32 | createdAt: { 33 | allowNull: true, 34 | type: Sequelize.DATE, 35 | }, 36 | updatedAt: { 37 | allowNull: true, 38 | type: Sequelize.DATE, 39 | }, 40 | }); 41 | }, 42 | down: async (queryInterface, Sequelize) => { 43 | await queryInterface.dropTable("Locks"); 44 | }, 45 | }; 46 | -------------------------------------------------------------------------------- /bba-server/migrations/11-update-DeliveryOrder copy.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | const tableName = 'DeliveryOrders'; 3 | const columnName = 'status' 4 | module.exports = { 5 | up: (queryInterface, Sequelize) => { 6 | return queryInterface.describeTable(tableName).then(tableDefinition => { 7 | if (!tableDefinition[columnName]){ 8 | return queryInterface.addColumn( 9 | tableName, 10 | columnName, 11 | { 12 | type: Sequelize.INTEGER, 13 | defaultValue: 0, 14 | after: "barcode" 15 | }, 16 | ); 17 | } else { 18 | return Promise.resolve(true); 19 | } 20 | }); 21 | 22 | }, 23 | down: (queryInterface, Sequelize) => { 24 | return queryInterface.removeColumn( 25 | tableName, 26 | columnName 27 | ); 28 | }, 29 | }; 30 | -------------------------------------------------------------------------------- /bba-server/migrations/12-update-Lock.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | const tableName = 'Locks'; 3 | const columnName = 'orderid' 4 | module.exports = { 5 | down: (queryInterface, Sequelize) => { 6 | return queryInterface.describeTable(tableName).then(tableDefinition => { 7 | if (!tableDefinition[columnName]){ 8 | return queryInterface.addColumn( 9 | tableName, 10 | columnName, 11 | { 12 | type: Sequelize.INTEGER, 13 | defaultValue: 0, 14 | after: "id" 15 | }, 16 | ); 17 | } else { 18 | return Promise.resolve(true); 19 | } 20 | }); 21 | 22 | }, 23 | up: (queryInterface, Sequelize) => { 24 | return queryInterface.removeColumn( 25 | tableName, 26 | columnName 27 | ); 28 | }, 29 | }; 30 | -------------------------------------------------------------------------------- /bba-server/migrations/20210519144448-ColorValues.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | module.exports = { 4 | up: async (queryInterface, Sequelize) => { 5 | return Promise.all([ 6 | // queryInterface.addColumn( 7 | // 'Locks', 8 | // 'ColorValue', 9 | // Sequelize.STRING 10 | // ), 11 | ]); 12 | /** 13 | * Add altering commands here. 14 | * 15 | * Example: 16 | * await queryInterface.createTable('users', { id: Sequelize.INTEGER }); 17 | */ 18 | 19 | }, 20 | 21 | down: async (queryInterface, Sequelize) => { 22 | /** 23 | * Add reverting commands here. 24 | * 25 | * Example: 26 | * await queryInterface.dropTable('users'); 27 | */ 28 | } 29 | }; 30 | -------------------------------------------------------------------------------- /bba-server/migrations/20210529215855-create-asset.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | module.exports = { 3 | up: async (queryInterface, Sequelize) => { 4 | await queryInterface.createTable('Assets', { 5 | id: { 6 | allowNull: false, 7 | autoIncrement: true, 8 | primaryKey: true, 9 | type: Sequelize.INTEGER 10 | }, 11 | barcode: { 12 | type: Sequelize.STRING 13 | }, 14 | item: { 15 | type: Sequelize.STRING 16 | }, 17 | lastDelivery: { 18 | type: Sequelize.DATE 19 | }, 20 | status: { 21 | type: Sequelize.STRING 22 | }, 23 | createdAt: { 24 | allowNull: false, 25 | type: Sequelize.DATE 26 | }, 27 | updatedAt: { 28 | allowNull: false, 29 | type: Sequelize.DATE 30 | } 31 | }); 32 | }, 33 | down: async (queryInterface, Sequelize) => { 34 | await queryInterface.dropTable('Assets'); 35 | } 36 | }; -------------------------------------------------------------------------------- /bba-server/migrations/20210529220117-create-truck.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | module.exports = { 3 | up: async (queryInterface, Sequelize) => { 4 | await queryInterface.createTable('Trucks', { 5 | id: { 6 | allowNull: false, 7 | autoIncrement: true, 8 | primaryKey: true, 9 | type: Sequelize.INTEGER 10 | }, 11 | notes: { 12 | type: Sequelize.STRING 13 | }, 14 | createdAt: { 15 | allowNull: false, 16 | type: Sequelize.DATE 17 | }, 18 | updatedAt: { 19 | allowNull: false, 20 | type: Sequelize.DATE 21 | } 22 | }); 23 | }, 24 | down: async (queryInterface, Sequelize) => { 25 | await queryInterface.dropTable('Trucks'); 26 | } 27 | }; -------------------------------------------------------------------------------- /bba-server/migrations/20210601095359-add_new_truck_id_column.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | module.exports = { 4 | up: async (queryInterface, Sequelize) => { 5 | /** 6 | * Add altering commands here. 7 | * 8 | * Example: 9 | * await queryInterface.createTable('users', { id: Sequelize.INTEGER }); 10 | */ 11 | return Promise.all([ 12 | queryInterface.addColumn( 13 | 'deliveryOrders', 14 | 'truckID', 15 | Sequelize.INTEGER 16 | ), 17 | ]); 18 | }, 19 | 20 | down: async (queryInterface, Sequelize) => { 21 | /** 22 | * Add reverting commands here. 23 | * 24 | * Example: 25 | * await queryInterface.dropTable('users'); 26 | */ 27 | } 28 | }; 29 | -------------------------------------------------------------------------------- /bba-server/migrations/20230608124844-create-area.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | /** @type {import('sequelize-cli').Migration} */ 3 | module.exports = { 4 | async up(queryInterface, Sequelize) { 5 | await queryInterface.createTable('Areas', { 6 | id: { 7 | allowNull: false, 8 | autoIncrement: true, 9 | primaryKey: true, 10 | type: Sequelize.INTEGER 11 | }, 12 | name: { 13 | type: Sequelize.STRING 14 | }, 15 | priority: { 16 | type: Sequelize.INTEGER 17 | } 18 | }); 19 | }, 20 | async down(queryInterface, Sequelize) { 21 | await queryInterface.dropTable('Areas'); 22 | } 23 | }; -------------------------------------------------------------------------------- /bba-server/migrations/20230608125239-create-villa.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | /** @type {import('sequelize-cli').Migration} */ 3 | module.exports = { 4 | async up(queryInterface, Sequelize) { 5 | await queryInterface.createTable('Villa', { 6 | id: { 7 | allowNull: false, 8 | autoIncrement: true, 9 | primaryKey: true, 10 | type: Sequelize.INTEGER 11 | }, 12 | parent: { 13 | type: Sequelize.INTEGER 14 | }, 15 | priority: { 16 | type: Sequelize.INTEGER 17 | } 18 | }); 19 | }, 20 | async down(queryInterface, Sequelize) { 21 | await queryInterface.dropTable('Villa'); 22 | } 23 | }; -------------------------------------------------------------------------------- /bba-server/mockData.js: -------------------------------------------------------------------------------- 1 | const MOCK_DATA_TWILIO = [ 2 | { 3 | "sid": "SM1234567890", 4 | "accountSid": "AC9876543210", 5 | "dateCreated": "2023-06-01T10:15:30Z", 6 | "dateUpdated": "2023-06-01T10:15:30Z", 7 | "dateSent": "2023-06-01T10:15:30Z", 8 | "direction": "outbound", 9 | "from": "+1234567890", 10 | "to": "+9876543210", 11 | "body": "Hello, how are you?" 12 | }, 13 | { 14 | "sid": "SM2345678901", 15 | "accountSid": "AC8765432109", 16 | "dateCreated": "2023-06-02T15:30:45Z", 17 | "dateUpdated": "2023-06-02T15:30:45Z", 18 | "dateSent": "2023-06-02T15:30:45Z", 19 | "direction": "inbound", 20 | "from": "+9876543210", 21 | "to": "+1234567890", 22 | "body": "I'm doing great, thank you!" 23 | }, 24 | { 25 | "sid": "SM3456789012", 26 | "accountSid": "AC7654321098", 27 | "dateCreated": "2023-06-03T09:45:15Z", 28 | "dateUpdated": "2023-06-03T09:45:15Z", 29 | "dateSent": "2023-06-03T09:45:15Z", 30 | "direction": "outbound", 31 | "from": "+1234567890", 32 | "to": "+3308190838", 33 | "body": "Are you available for a call later?" 34 | } 35 | ]; 36 | 37 | 38 | module.exports = { MOCK_DATA_TWILIO }; -------------------------------------------------------------------------------- /bba-server/models/Activity.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | 3 | const { Model } = require("sequelize"); 4 | 5 | module.exports = (sequelize, DataTypes) => { 6 | class Activity extends Model { 7 | static associate(models) { 8 | // define association here 9 | } 10 | }; 11 | 12 | Activity.init({ 13 | id: { 14 | type: DataTypes.INTEGER, 15 | primaryKey: true, 16 | autoIncrement: true, 17 | }, 18 | Title: { 19 | type: DataTypes.STRING, 20 | }, 21 | Description: { 22 | type: DataTypes.STRING, 23 | }, 24 | ImagePath: { 25 | type: DataTypes.STRING, 26 | }, 27 | LocationId: { 28 | type: DataTypes.INTEGER, 29 | }, 30 | WebPath: { 31 | type: DataTypes.STRING, 32 | }, 33 | Notes: { 34 | type: DataTypes.STRING, 35 | }, 36 | Status: { 37 | type: DataTypes.STRING, 38 | }, 39 | TimeStamp: { 40 | type: DataTypes.DATE, 41 | } 42 | }, { 43 | sequelize, 44 | modelName: "Activity", 45 | tableName: "activities", 46 | timestamps: false 47 | }); 48 | 49 | return Activity; 50 | }; -------------------------------------------------------------------------------- /bba-server/models/Area.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | const { 3 | Model 4 | } = require("sequelize"); 5 | module.exports = (sequelize, DataTypes) => { 6 | class Area extends Model { 7 | /** 8 | * Helper method for defining associations. 9 | * This method is not a part of Sequelize lifecycle. 10 | * The `models/index` file will call this method automatically. 11 | */ 12 | static associate(models) { 13 | // define association here 14 | } 15 | } 16 | Area.init({ 17 | name: DataTypes.STRING(255), 18 | priority: DataTypes.INTEGER(10), 19 | }, { 20 | sequelize, 21 | modelName: "Area", 22 | tableName: "area", 23 | timestamps: false 24 | }); 25 | return Area; 26 | }; -------------------------------------------------------------------------------- /bba-server/models/CommunicationMessage.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | 3 | const { 4 | Model 5 | } = require("sequelize"); 6 | 7 | module.exports = (sequelize, DataTypes) => { 8 | class CommunicationMessage extends Model { 9 | /** 10 | * Helper method for defining associations. 11 | * This method is not a part of Sequelize lifecycle. 12 | * The `models/index` file will call this method automatically. 13 | */ 14 | static associate(models) { 15 | // define association here 16 | this.belongsTo(models.DeliveryOrders, { 17 | foreignKey: "DeliveryId", 18 | as: "deliveryOrder", 19 | }) 20 | } 21 | }; 22 | 23 | CommunicationMessage.init({ 24 | id: { 25 | type: DataTypes.INTEGER, 26 | primaryKey: true, 27 | autoIncrement: true, 28 | }, 29 | MessageText: { 30 | type: DataTypes.STRING 31 | }, 32 | Direction: { 33 | type: DataTypes.INTEGER 34 | }, 35 | Sent: { 36 | type: DataTypes.DATE 37 | } 38 | }, { 39 | sequelize, 40 | modelName: "CommunicationMessage", 41 | timestamps: false, 42 | tableName: "communicationsMessages", 43 | }); 44 | 45 | return CommunicationMessage; 46 | }; -------------------------------------------------------------------------------- /bba-server/models/Deal.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | 3 | const { Model } = require("sequelize"); 4 | 5 | module.exports = (sequelize, DataTypes) => { 6 | class Deal extends Model { 7 | static associate(models) { 8 | // define association here 9 | } 10 | }; 11 | 12 | Deal.init({ 13 | id: { 14 | type: DataTypes.INTEGER, 15 | primaryKey: true, 16 | autoIncrement: true, 17 | }, 18 | Title: { 19 | type: DataTypes.STRING, 20 | }, 21 | Description: { 22 | type: DataTypes.STRING, 23 | }, 24 | ImagePath: { 25 | type: DataTypes.STRING, 26 | }, 27 | WebPath: { 28 | type: DataTypes.STRING, 29 | }, 30 | Notes: { 31 | type: DataTypes.STRING, 32 | }, 33 | Status: { 34 | type: DataTypes.STRING, 35 | }, 36 | TimeStamp: { 37 | type: DataTypes.DATE, 38 | } 39 | }, { 40 | sequelize, 41 | modelName: "Deal", 42 | tableName: "deals", 43 | }); 44 | 45 | return Deal; 46 | }; -------------------------------------------------------------------------------- /bba-server/models/EquipmentType.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | 3 | const { Model } = require("sequelize"); 4 | 5 | module.exports = (sequelize, DataTypes) => { 6 | class EquipmentType extends Model { 7 | static associate(models) { 8 | // define association here 9 | } 10 | }; 11 | 12 | EquipmentType.init({ 13 | id: { 14 | type: DataTypes.INTEGER, 15 | primaryKey: true, 16 | autoIncrement: true, 17 | }, 18 | Label: { 19 | type: DataTypes.STRING, 20 | }, 21 | BarcodePrefix: { 22 | type: DataTypes.STRING, 23 | }, 24 | CapacityConsumption: { 25 | type: DataTypes.INTEGER, 26 | }, 27 | IsDeleted: { 28 | type: DataTypes.BOOLEAN, 29 | defaultValue: false, 30 | }, 31 | ProductLineId: { 32 | type: DataTypes.STRING, 33 | }, 34 | qty: { 35 | type: DataTypes.INTEGER, 36 | defaultValue: 0, 37 | }, 38 | qtyAvailable: { 39 | type: DataTypes.INTEGER, 40 | defaultValue: 0, 41 | }, 42 | }, { 43 | sequelize, 44 | modelName: "EquipmentType", 45 | tableName: "equipment_type", 46 | timestamps: false 47 | }); 48 | 49 | return EquipmentType; 50 | }; -------------------------------------------------------------------------------- /bba-server/models/Notification.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | const { 3 | Model 4 | } = require("sequelize"); 5 | module.exports = (sequelize, DataTypes) => { 6 | class Notification extends Model { 7 | /** 8 | * Helper method for defining associations. 9 | * This method is not a part of Sequelize lifecycle. 10 | * The `models/index` file will call this method automatically. 11 | */ 12 | static associate(models) { 13 | // define association here 14 | } 15 | } 16 | Notification.init({ 17 | message: DataTypes.STRING(255), 18 | type: DataTypes.BOOLEAN, 19 | deliveryOrderId: DataTypes.INTEGER(10), 20 | tripId: DataTypes.INTEGER(10), 21 | userId: DataTypes.INTEGER(10), 22 | createdAt: DataTypes.DATE 23 | }, { 24 | sequelize, 25 | modelName: "Notification", 26 | tableName: "notifications", 27 | timestamps: false 28 | }); 29 | 30 | Notification.associate = function(models) { 31 | Notification.hasOne(models.DeliveryOrders, {foreignKey: 'id', sourceKey: 'deliveryOrderId'}); 32 | } 33 | return Notification; 34 | }; -------------------------------------------------------------------------------- /bba-server/models/Problem.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | 3 | const { Model } = require("sequelize"); 4 | 5 | module.exports = (sequelize, DataTypes) => { 6 | class Problem extends Model { 7 | static associate(models) { 8 | // define association here 9 | } 10 | }; 11 | 12 | Problem.init({ 13 | id: { 14 | type: DataTypes.INTEGER, 15 | primaryKey: true, 16 | autoIncrement: true, 17 | }, 18 | Notes: { 19 | type: DataTypes.STRING, 20 | }, 21 | Status: { 22 | type: DataTypes.STRING, 23 | }, 24 | TypeDesc: { 25 | type: DataTypes.STRING, 26 | }, 27 | Tag: { 28 | type: DataTypes.STRING, 29 | }, 30 | Email: { 31 | type: DataTypes.STRING, 32 | }, 33 | Barcode: { 34 | type: DataTypes.STRING, 35 | }, 36 | TimeStamp: { 37 | type: DataTypes.DATE, 38 | }, 39 | }, { 40 | sequelize, 41 | modelName: "Problem", 42 | tableName: "problems", 43 | timestamps: false 44 | }); 45 | 46 | return Problem; 47 | }; -------------------------------------------------------------------------------- /bba-server/models/ProblemType.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | 3 | const { Model } = require("sequelize"); 4 | 5 | module.exports = (sequelize, DataTypes) => { 6 | class ProblemType extends Model { 7 | static associate(models) { 8 | // define association here 9 | } 10 | }; 11 | 12 | ProblemType.init({ 13 | id: { 14 | type: DataTypes.INTEGER, 15 | primaryKey: true, 16 | autoIncrement: true, 17 | }, 18 | Name: { 19 | type: DataTypes.STRING, 20 | }, 21 | Description: { 22 | type: DataTypes.STRING, 23 | }, 24 | }, { 25 | sequelize, 26 | modelName: "ProblemType", 27 | tableName: "problem_types", 28 | timestamps: false 29 | }); 30 | 31 | return ProblemType; 32 | }; -------------------------------------------------------------------------------- /bba-server/models/StreetAddress.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | const { 3 | Model 4 | } = require("sequelize"); 5 | module.exports = (sequelize, DataTypes) => { 6 | class StreetAddress extends Model { 7 | /** 8 | * Helper method for defining associations. 9 | * This method is not a part of Sequelize lifecycle. 10 | * The `models/index` file will call this method automatically. 11 | */ 12 | static associate(models) { 13 | // define association here 14 | StreetAddress.belongsTo(models.Villa, { foreignKey: "parent" }); 15 | } 16 | } 17 | StreetAddress.init({ 18 | name: DataTypes.STRING(255), 19 | bikeRack: DataTypes.STRING(255), 20 | parent: DataTypes.INTEGER, 21 | priority: DataTypes.INTEGER(10), 22 | }, { 23 | sequelize, 24 | modelName: "StreetAddress", 25 | tableName: "street_address", 26 | timestamps: false 27 | }); 28 | return StreetAddress; 29 | }; -------------------------------------------------------------------------------- /bba-server/models/Timeclock.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | 3 | const { Model } = require("sequelize"); 4 | 5 | module.exports = (sequelize, DataTypes) => { 6 | class Timeclock extends Model { 7 | static associate(models) { 8 | // define association here 9 | } 10 | }; 11 | 12 | Timeclock.init({ 13 | id: { 14 | type: DataTypes.INTEGER, 15 | primaryKey: true, 16 | autoIncrement: true, 17 | }, 18 | user_id: { 19 | type: DataTypes.INTEGER, 20 | }, 21 | status: { 22 | type: DataTypes.INTEGER, 23 | }, 24 | duration: { 25 | type: DataTypes.INTEGER, 26 | }, 27 | lat: { 28 | type: DataTypes.FLOAT, 29 | }, 30 | lng: { 31 | type: DataTypes.FLOAT, 32 | }, 33 | location: { 34 | type: DataTypes.STRING, 35 | }, 36 | note: { 37 | type: DataTypes.STRING, 38 | }, 39 | deletedAt: { 40 | type: DataTypes.DATE 41 | } 42 | }, { 43 | sequelize, 44 | modelName: "Timeclock", 45 | tableName: "timeclock_logs", 46 | }); 47 | 48 | return Timeclock; 49 | }; -------------------------------------------------------------------------------- /bba-server/models/Villa.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | const { 3 | Model 4 | } = require("sequelize"); 5 | module.exports = (sequelize, DataTypes) => { 6 | class Villa extends Model { 7 | /** 8 | * Helper method for defining associations. 9 | * This method is not a part of Sequelize lifecycle. 10 | * The `models/index` file will call this method automatically. 11 | */ 12 | static associate(models) { 13 | // define association here 14 | Villa.belongsTo(models.Area, { foreignKey: "parent" }); 15 | } 16 | } 17 | Villa.init({ 18 | name: DataTypes.STRING(255), 19 | parent: DataTypes.INTEGER, 20 | priority: DataTypes.INTEGER(10), 21 | }, { 22 | sequelize, 23 | modelName: "Villa", 24 | tableName: "villas", 25 | timestamps: false 26 | }); 27 | return Villa; 28 | }; -------------------------------------------------------------------------------- /bba-server/models/asset.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | const { 3 | Model 4 | } = require('sequelize'); 5 | module.exports = (sequelize, DataTypes) => { 6 | class Asset extends Model { 7 | /** 8 | * Helper method for defining associations. 9 | * This method is not a part of Sequelize lifecycle. 10 | * The `models/index` file will call this method automatically. 11 | */ 12 | static associate(models) { 13 | // define association here 14 | } 15 | }; 16 | Asset.init({ 17 | barcode: DataTypes.STRING, 18 | item: DataTypes.STRING, 19 | lastDelivery: DataTypes.DATE, 20 | status: DataTypes.STRING 21 | }, { 22 | sequelize, 23 | modelName: 'Asset', 24 | tableName: 'assets', 25 | }); 26 | return Asset; 27 | }; -------------------------------------------------------------------------------- /bba-server/models/deliveryExtras.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | const { Model } = require("sequelize"); 3 | 4 | module.exports = (sequelize, DataTypes) => { 5 | class DeliveryExtras extends Model { 6 | static associate(models) { 7 | // define association here 8 | /*this.belongsTo(models.DeliveryItem, { 9 | foreignKey: { name: "deliveryOrderId", allowNull: false }, 10 | });*/ 11 | } 12 | } 13 | DeliveryExtras.init( 14 | { 15 | deliveryOrderId: DataTypes.INTEGER, 16 | extraName: DataTypes.STRING, 17 | createdAt: DataTypes.DATE, 18 | updatedAt: DataTypes.DATE 19 | }, 20 | { 21 | sequelize, 22 | modelName: "DeliveryExtras", 23 | tableName: "delivery_extras", 24 | } 25 | ); 26 | return DeliveryExtras; 27 | }; 28 | -------------------------------------------------------------------------------- /bba-server/models/deliveryItem.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | const { Model } = require("sequelize"); 3 | 4 | module.exports = (sequelize, DataTypes) => { 5 | class DeliveryItem extends Model { 6 | static associate(models) { 7 | // define association here 8 | 9 | } 10 | } 11 | DeliveryItem.init( 12 | { 13 | deliveryID: DataTypes.INTEGER, 14 | item: DataTypes.STRING, 15 | serialbarcode: DataTypes.STRING, 16 | active: DataTypes.BOOLEAN, 17 | checkedDelievery: DataTypes.BOOLEAN, 18 | checkPickup: DataTypes.BOOLEAN, 19 | EquipmentTypeId: DataTypes.INTEGER, 20 | 21 | }, 22 | { 23 | sequelize, 24 | modelName: "DeliveryItem", 25 | tableName: "delivery_items", 26 | } 27 | ); 28 | return DeliveryItem; 29 | }; 30 | -------------------------------------------------------------------------------- /bba-server/models/deliveryOrder.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | const { Model } = require("sequelize"); 3 | 4 | module.exports = (sequelize, DataTypes) => { 5 | class DeliveryOrder extends Model { 6 | static associate(models) { 7 | // define association here 8 | 9 | } 10 | } 11 | DeliveryOrder.init( 12 | { 13 | date: DataTypes.DATE, 14 | name: DataTypes.STRING, 15 | location: DataTypes.STRING, 16 | orderid: DataTypes.STRING, 17 | rack: DataTypes.STRING, 18 | color: DataTypes.STRING, 19 | combination: DataTypes.STRING, 20 | lock: DataTypes.STRING, 21 | mobileNo: DataTypes.STRING, 22 | barcode: DataTypes.STRING, 23 | status: DataTypes.INTEGER, 24 | updatedAt: DataTypes.DATE, 25 | email: DataTypes.STRING, 26 | note: DataTypes.STRING, 27 | plantation: DataTypes.STRING, 28 | area: DataTypes.STRING, 29 | // email: DataTypes.STRING, 30 | endDate: DataTypes.DATE, 31 | PickedUp: DataTypes.BOOLEAN, 32 | PickupNotes: DataTypes.STRING, 33 | truckID: DataTypes.INTEGER, 34 | TruckId1: DataTypes.INTEGER, 35 | tripID1: DataTypes.INTEGER, 36 | tripID2: DataTypes.INTEGER, 37 | tripPriority1: { 38 | type: DataTypes.INTEGER, 39 | defaultValue: 0 40 | }, 41 | tripPriority2: { 42 | type: DataTypes.INTEGER, 43 | defaultValue: 0 44 | }, 45 | textSent: DataTypes.BOOLEAN, 46 | picturesSent: DataTypes.BOOLEAN, 47 | driverDeliveredBy: DataTypes.STRING, 48 | driverPickedUpBy: DataTypes.STRING, 49 | swapOrderDeliveryId: { 50 | type: DataTypes.STRING, 51 | defaultValue: '' 52 | }, 53 | swapOrder: { 54 | type: DataTypes.BOOLEAN, 55 | defaultValue: false 56 | }, 57 | extrasDelivered: { 58 | type: DataTypes.BOOLEAN, 59 | defaultValue: false 60 | }, 61 | extrasPickedUp: { 62 | type: DataTypes.BOOLEAN, 63 | defaultValue: false 64 | }, 65 | extrasDeliveredReason: { 66 | type: DataTypes.STRING, 67 | defaultValue: '' 68 | }, 69 | extrasPickedUpReason: { 70 | type: DataTypes.STRING, 71 | defaultValue: '' 72 | }, 73 | }, 74 | { 75 | sequelize, 76 | modelName: "DeliveryOrders", 77 | tableName: "delivery_orders", 78 | } 79 | ); 80 | return DeliveryOrder; 81 | }; 82 | -------------------------------------------------------------------------------- /bba-server/models/file.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | const { Model } = require("sequelize"); 3 | 4 | module.exports = (sequelize, DataTypes) => { 5 | class File extends Model { 6 | static associate(models) { 7 | // define association here 8 | 9 | } 10 | } 11 | File.init( 12 | { 13 | 14 | orderid: DataTypes.STRING, 15 | filepath: DataTypes.STRING, 16 | }, 17 | { 18 | sequelize, 19 | modelName: "Files", 20 | tableName: "files", 21 | } 22 | ); 23 | return File; 24 | }; 25 | -------------------------------------------------------------------------------- /bba-server/models/index.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | const fs = require('fs'); 4 | const path = require('path'); 5 | const Sequelize = require('sequelize'); 6 | const basename = path.basename(__filename); 7 | const env = process.env.NODE_ENV || 'development'; 8 | const config = require(__dirname + '/../config/config.js')[env]; 9 | const db = {}; 10 | 11 | const options = { 12 | // timezone: 'America/New_York', // Set timezone to New York 13 | }; 14 | 15 | let sequelize; 16 | if (config.use_env_variable) { 17 | sequelize = new Sequelize(process.env[config.use_env_variable], {...options, ...config}); 18 | } else { 19 | sequelize = new Sequelize(config.database, config.username, config.password, {...options, ...config}); 20 | } 21 | 22 | fs 23 | .readdirSync(__dirname) 24 | .filter(file => { 25 | return (file.indexOf('.') !== 0) && (file !== basename) && (file.slice(-3) === '.js'); 26 | }) 27 | .forEach(file => { 28 | const model = require(path.join(__dirname, file))(sequelize, Sequelize.DataTypes); 29 | db[model.name] = model; 30 | }); 31 | 32 | Object.keys(db).forEach(modelName => { 33 | if (db[modelName].associate) { 34 | db[modelName].associate(db); 35 | } 36 | }); 37 | 38 | db.sequelize = sequelize; 39 | db.Sequelize = Sequelize; 40 | 41 | module.exports = db; 42 | -------------------------------------------------------------------------------- /bba-server/models/lock.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | const { Model } = require("sequelize"); 3 | 4 | module.exports = (sequelize, DataTypes) => { 5 | class Lock extends Model { 6 | static associate(models) { 7 | // define association here 8 | 9 | } 10 | } 11 | Lock.init( 12 | { 13 | id: { 14 | type: DataTypes.INTEGER, 15 | primaryKey: true, 16 | autoIncrement: true, 17 | }, 18 | lockId: DataTypes.STRING, 19 | color: DataTypes.STRING, 20 | combination: DataTypes.STRING, 21 | ColorValue: DataTypes.STRING 22 | }, 23 | { 24 | sequelize, 25 | modelName: "Locks", 26 | tableName: "locks", 27 | } 28 | ); 29 | return Lock; 30 | }; 31 | -------------------------------------------------------------------------------- /bba-server/models/log.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | const { Model } = require("sequelize"); 3 | 4 | module.exports = (sequelize, DataTypes) => { 5 | class Log extends Model { 6 | static associate(models) { 7 | // define association here 8 | 9 | } 10 | } 11 | Log.init( 12 | { 13 | json: DataTypes.TEXT, 14 | }, 15 | { 16 | sequelize, 17 | modelName: "Logs", 18 | tableName: "logs", 19 | } 20 | ); 21 | return Log; 22 | }; 23 | -------------------------------------------------------------------------------- /bba-server/models/resetToken.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | const { Model } = require("sequelize"); 3 | module.exports = (sequelize, DataTypes) => { 4 | class ResetToken extends Model { 5 | static associate(models) { 6 | this.belongsTo(models.User, { 7 | foreignKey: { name: "userId", allowNull: false }, 8 | }); // adds userId 9 | } 10 | } 11 | ResetToken.init( 12 | { 13 | token: { 14 | type: DataTypes.STRING, 15 | allowNull: false, 16 | }, 17 | }, 18 | { 19 | sequelize, 20 | modelName: "ResetToken", 21 | timestamps: true, 22 | updatedAt: false, 23 | } 24 | ); 25 | 26 | return ResetToken; 27 | }; 28 | -------------------------------------------------------------------------------- /bba-server/models/template.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | const { Model } = require("sequelize"); 3 | 4 | module.exports = (sequelize, DataTypes) => { 5 | class Template extends Model { 6 | static associate(models) { 7 | // define association here 8 | 9 | } 10 | } 11 | Template.init( 12 | { 13 | 14 | body: DataTypes.STRING, 15 | }, 16 | { 17 | sequelize, 18 | modelName: "Templates", 19 | tableName: "templates", 20 | } 21 | ); 22 | return Template; 23 | }; 24 | -------------------------------------------------------------------------------- /bba-server/models/trip.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | const { Model } = require("sequelize"); 3 | 4 | module.exports = (sequelize, DataTypes) => { 5 | class Trip extends Model { 6 | static associate(models) { 7 | // define association here 8 | } 9 | } 10 | Trip.init( 11 | { 12 | tripNumber: DataTypes.INTEGER, 13 | date: DataTypes.DATEONLY, 14 | truckId: DataTypes.INTEGER, 15 | released: DataTypes.BOOLEAN, 16 | complete: DataTypes.BOOLEAN, 17 | notifyYardMAnager: DataTypes.BOOLEAN, 18 | driverId: DataTypes.INTEGER 19 | }, 20 | { 21 | sequelize, 22 | modelName: "Trip", 23 | tableName: "trips", 24 | timestamps: false 25 | } 26 | ); 27 | return Trip; 28 | }; 29 | -------------------------------------------------------------------------------- /bba-server/models/truck.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | 3 | const { 4 | Model 5 | } = require("sequelize"); 6 | 7 | module.exports = (sequelize, DataTypes) => { 8 | class Truck extends Model { 9 | /** 10 | * Helper method for defining associations. 11 | * This method is not a part of Sequelize lifecycle. 12 | * The `models/index` file will call this method automatically. 13 | */ 14 | static associate(models) { 15 | // define association here 16 | } 17 | }; 18 | Truck.init({ 19 | id: { 20 | type: DataTypes.INTEGER, 21 | primaryKey: true, 22 | autoIncrement: true, 23 | }, 24 | notes: DataTypes.STRING, 25 | LicensePlate: DataTypes.STRING, 26 | TruckName: DataTypes.STRING, 27 | MaxCapacity: DataTypes.STRING, 28 | HHI_Resort: DataTypes.STRING, 29 | Ocean_1: DataTypes.STRING, 30 | PD_Pass: DataTypes.STRING, 31 | SP_Pass: DataTypes.STRING, 32 | SY_Pass: DataTypes.STRING, 33 | createdAt: DataTypes.DATE, 34 | updatedAt: DataTypes.DATE, 35 | }, { 36 | sequelize, 37 | modelName: "Truck", 38 | tableName: "trucks", 39 | timestamps: true, 40 | }); 41 | 42 | Truck.beforeCreate((truck, _) => { 43 | truck.createdAt = new Date(); 44 | truck.updatedAt = new Date(); 45 | }); 46 | 47 | Truck.beforeUpdate((truck, _) => { 48 | truck.updatedAt = new Date(); 49 | }); 50 | 51 | return Truck; 52 | }; -------------------------------------------------------------------------------- /bba-server/models/uploads.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | const { Model } = require('sequelize'); 3 | module.exports = (sequelize, DataTypes) => { 4 | class Upload extends Model { 5 | static associate(models) {} 6 | }; 7 | Upload.init({ 8 | filename: DataTypes.STRING, 9 | originalName: DataTypes.STRING, 10 | encoding: DataTypes.STRING, 11 | mimetype: DataTypes.STRING, 12 | size: DataTypes.INTEGER, 13 | }, { 14 | sequelize, 15 | modelName: 'Upload', 16 | tableName: 'uploads', 17 | timestamps: true, 18 | updatedAt: false, 19 | }); 20 | 21 | return Upload; 22 | }; 23 | -------------------------------------------------------------------------------- /bba-server/models/user.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | const bcrypt = require("bcrypt"); 3 | const saltRounds = 12; 4 | 5 | const { Model } = require("sequelize"); 6 | module.exports = (sequelize, DataTypes) => { 7 | class User extends Model { 8 | /** 9 | * Helper method for defining associations. 10 | * This method is not a part of Sequelize lifecycle. 11 | * The `models/index` file will call this method automatically. 12 | */ 13 | static associate(models) { 14 | // define association here 15 | } 16 | } 17 | User.init( 18 | { 19 | id: { 20 | type: DataTypes.INTEGER, 21 | primaryKey: true, 22 | autoIncrement: true, 23 | }, 24 | email: DataTypes.STRING, 25 | password: DataTypes.STRING, 26 | name: DataTypes.STRING, 27 | isVerified: DataTypes.BOOLEAN, 28 | createdAt: DataTypes.DATE, 29 | updatedAt: DataTypes.DATE, 30 | deletedAt: DataTypes.DATE, 31 | userType: DataTypes.INTEGER, 32 | displayName: { 33 | type: DataTypes.VIRTUAL, 34 | get() { 35 | if (this.name) return this.name; 36 | else return this.email; 37 | }, 38 | set(value) { 39 | throw new Error("Unable to set displayName."); 40 | }, 41 | }, 42 | }, 43 | { 44 | sequelize, 45 | modelName: "User", 46 | tableName: 'users', 47 | timestamps: true, 48 | paranoid: true, 49 | } 50 | ); 51 | 52 | User.prototype.validPassword = async function (password) { 53 | return await bcrypt.compare(password, this.password); 54 | }; 55 | User.prototype.encryptPassword = async function (password) { 56 | return await bcrypt.hash(user.password, saltRounds); 57 | }; 58 | User.beforeUpdate(async (user, options) => { 59 | if (user.changed("password") && user.password) 60 | user.password = await bcrypt.hash(user.password, saltRounds); 61 | }); 62 | User.beforeCreate(async (user, options) => { 63 | user.password = await bcrypt.hash(user.password, saltRounds); 64 | }); 65 | 66 | return User; 67 | }; 68 | -------------------------------------------------------------------------------- /bba-server/models/verificationToken.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | const { Model } = require("sequelize"); 3 | module.exports = (sequelize, DataTypes) => { 4 | class VerificationToken extends Model { 5 | static associate(models) { 6 | this.belongsTo(models.User, { 7 | foreignKey: { name: "userId", allowNull: false }, 8 | }); // adds userId 9 | } 10 | } 11 | VerificationToken.init( 12 | { 13 | token: { 14 | type: DataTypes.STRING, 15 | allowNull: false, 16 | }, 17 | }, 18 | { 19 | sequelize, 20 | modelName: "VerificationToken", 21 | tableName: "verificationTokens", 22 | timestamps: true, 23 | updatedAt: false, 24 | } 25 | ); 26 | 27 | return VerificationToken; 28 | }; 29 | -------------------------------------------------------------------------------- /bba-server/models/webhook.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | const { Model } = require("sequelize"); 3 | module.exports = (sequelize, DataTypes) => { 4 | class WebHook extends Model { 5 | static associate(models) { 6 | // define association here 7 | this.belongsTo(models.User, { 8 | foreignKey: { name: "userId", allowNull: false }, 9 | }); // adds userId 10 | } 11 | } 12 | WebHook.init( 13 | { 14 | webHookUrl: DataTypes.STRING, 15 | isActive: DataTypes.BOOLEAN, 16 | createdAt: DataTypes.DATE, 17 | updatedAt: DataTypes.DATE, 18 | }, 19 | { 20 | sequelize, 21 | modelName: "WebHook", 22 | tableName: "webhooks", 23 | } 24 | ); 25 | return WebHook; 26 | }; 27 | -------------------------------------------------------------------------------- /bba-server/models/webhookMap.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | const { Model } = require("sequelize"); 3 | 4 | module.exports = (sequelize, DataTypes) => { 5 | class WebhookMap extends Model { 6 | static associate(models) { 7 | // define association here 8 | 9 | } 10 | } 11 | WebhookMap.init( 12 | { 13 | 14 | table_key: DataTypes.STRING, 15 | json_key: DataTypes.STRING, 16 | }, 17 | { 18 | sequelize, 19 | modelName: "WebhookMaps", 20 | tableName: "webhookMaps", 21 | } 22 | ); 23 | return WebhookMap; 24 | }; 25 | -------------------------------------------------------------------------------- /bba-server/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "bullock-bike-server", 3 | "version": "1.1.0", 4 | "description": "A Bullock Bike Delivery App", 5 | "main": "index.js", 6 | "scripts": { 7 | "test": "echo \"Error: no test specified\" && exit 1", 8 | "bba-client": "cd .. && cd bba-client && yarn dev", 9 | "dev": "concurrently -n 'server,client' -c 'blue,green' \"nodemon index.js\" \"yarn bba-client\"", 10 | "start": "node index.js" 11 | }, 12 | "author": "krahamatullah@paradynamix.com", 13 | "license": "ISC", 14 | "dependencies": { 15 | "@aws-sdk/client-s3": "^3.583.0", 16 | "@aws-sdk/lib-storage": "^3.583.0", 17 | "@sentry/node": "^6.5.0", 18 | "@sentry/tracing": "^6.5.0", 19 | "adm-zip": "^0.5.5", 20 | "aws-sdk": "^2.1153.0", 21 | "bcrypt": "^5.0.1", 22 | "consola": "^2.15.3", 23 | "cookie-parser": "^1.4.6", 24 | "cors": "^2.8.5", 25 | "crypto-random-string": "^3.3.1", 26 | "express": "^4.17.1", 27 | "finale-rest": "^1.1.1", 28 | "http-status": "^1.5.0", 29 | "jsonwebtoken": "^8.5.1", 30 | "lodash": "^4.17.21", 31 | "moment": "^2.29.1", 32 | "multer": "^1.4.5-lts.1", 33 | "multer-s3": "^3.0.1", 34 | "mysql2": "^2.2.5", 35 | "node-fetch": "^3.2.6", 36 | "nodemailer": "^6.6.1", 37 | "request": "^2.88.2", 38 | "sequelize": "^6.5.0", 39 | "twilio": "^3.67.2", 40 | "url-exist": "^3.0.0", 41 | "vuetify-datetime-picker": "^2.1.1" 42 | }, 43 | "devDependencies": { 44 | "concurrently": "^6.2.0", 45 | "dotenv": "^8.6.0", 46 | "morgan": "^1.10.0", 47 | "nodemon": "^2.0.7", 48 | "sequelize-cli": "^6.2.0" 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /bba-server/public/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jairo-matos/BikeDeliveryApp/2f323905cfa6f5a9ebe280529bc094b85fc9ca3e/bba-server/public/.DS_Store -------------------------------------------------------------------------------- /bba-server/public/Apr999-21-0.jpeg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jairo-matos/BikeDeliveryApp/2f323905cfa6f5a9ebe280529bc094b85fc9ca3e/bba-server/public/Apr999-21-0.jpeg -------------------------------------------------------------------------------- /bba-server/public/Apr999-21-1.jpeg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jairo-matos/BikeDeliveryApp/2f323905cfa6f5a9ebe280529bc094b85fc9ca3e/bba-server/public/Apr999-21-1.jpeg -------------------------------------------------------------------------------- /bba-server/public/Apr999-21-2.jpeg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jairo-matos/BikeDeliveryApp/2f323905cfa6f5a9ebe280529bc094b85fc9ca3e/bba-server/public/Apr999-21-2.jpeg -------------------------------------------------------------------------------- /bba-server/public/Aug0005-23-0.jpeg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jairo-matos/BikeDeliveryApp/2f323905cfa6f5a9ebe280529bc094b85fc9ca3e/bba-server/public/Aug0005-23-0.jpeg -------------------------------------------------------------------------------- /bba-server/public/Aug0006-23-0.jpeg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jairo-matos/BikeDeliveryApp/2f323905cfa6f5a9ebe280529bc094b85fc9ca3e/bba-server/public/Aug0006-23-0.jpeg -------------------------------------------------------------------------------- /bba-server/public/Aug0006-23-pickup-1.jpeg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jairo-matos/BikeDeliveryApp/2f323905cfa6f5a9ebe280529bc094b85fc9ca3e/bba-server/public/Aug0006-23-pickup-1.jpeg -------------------------------------------------------------------------------- /bba-server/public/Jul0281-21-0.jpeg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jairo-matos/BikeDeliveryApp/2f323905cfa6f5a9ebe280529bc094b85fc9ca3e/bba-server/public/Jul0281-21-0.jpeg -------------------------------------------------------------------------------- /bba-server/public/Jun0140-21-0.jpeg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jairo-matos/BikeDeliveryApp/2f323905cfa6f5a9ebe280529bc094b85fc9ca3e/bba-server/public/Jun0140-21-0.jpeg -------------------------------------------------------------------------------- /bba-server/public/Jun0140-21-1.jpeg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jairo-matos/BikeDeliveryApp/2f323905cfa6f5a9ebe280529bc094b85fc9ca3e/bba-server/public/Jun0140-21-1.jpeg -------------------------------------------------------------------------------- /bba-server/public/Jun0156-21-0.jpeg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jairo-matos/BikeDeliveryApp/2f323905cfa6f5a9ebe280529bc094b85fc9ca3e/bba-server/public/Jun0156-21-0.jpeg -------------------------------------------------------------------------------- /bba-server/public/Jun999-21-0.jpeg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jairo-matos/BikeDeliveryApp/2f323905cfa6f5a9ebe280529bc094b85fc9ca3e/bba-server/public/Jun999-21-0.jpeg -------------------------------------------------------------------------------- /bba-server/public/Sep0001-23-0.jpeg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jairo-matos/BikeDeliveryApp/2f323905cfa6f5a9ebe280529bc094b85fc9ca3e/bba-server/public/Sep0001-23-0.jpeg -------------------------------------------------------------------------------- /bba-server/public/Sep0001-23-pickup-1.jpeg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jairo-matos/BikeDeliveryApp/2f323905cfa6f5a9ebe280529bc094b85fc9ca3e/bba-server/public/Sep0001-23-pickup-1.jpeg -------------------------------------------------------------------------------- /bba-server/public/pickup/Aug0005-23-0.jpeg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jairo-matos/BikeDeliveryApp/2f323905cfa6f5a9ebe280529bc094b85fc9ca3e/bba-server/public/pickup/Aug0005-23-0.jpeg -------------------------------------------------------------------------------- /bba-server/public/pickup/Jun0156-21-0.jpeg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jairo-matos/BikeDeliveryApp/2f323905cfa6f5a9ebe280529bc094b85fc9ca3e/bba-server/public/pickup/Jun0156-21-0.jpeg -------------------------------------------------------------------------------- /bba-server/public/pickup/Jun0156-21-1.jpeg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jairo-matos/BikeDeliveryApp/2f323905cfa6f5a9ebe280529bc094b85fc9ca3e/bba-server/public/pickup/Jun0156-21-1.jpeg -------------------------------------------------------------------------------- /bba-server/public/pickup/Jun0156-21-2.jpeg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jairo-matos/BikeDeliveryApp/2f323905cfa6f5a9ebe280529bc094b85fc9ca3e/bba-server/public/pickup/Jun0156-21-2.jpeg -------------------------------------------------------------------------------- /bba-server/public/pickup/May0070-23-0.jpeg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jairo-matos/BikeDeliveryApp/2f323905cfa6f5a9ebe280529bc094b85fc9ca3e/bba-server/public/pickup/May0070-23-0.jpeg -------------------------------------------------------------------------------- /bba-server/public/pickup/May0168-23-0.jpeg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jairo-matos/BikeDeliveryApp/2f323905cfa6f5a9ebe280529bc094b85fc9ca3e/bba-server/public/pickup/May0168-23-0.jpeg -------------------------------------------------------------------------------- /bba-server/public/pickup/May0284-23-0.jpeg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jairo-matos/BikeDeliveryApp/2f323905cfa6f5a9ebe280529bc094b85fc9ca3e/bba-server/public/pickup/May0284-23-0.jpeg -------------------------------------------------------------------------------- /bba-server/seed.js: -------------------------------------------------------------------------------- 1 | const consola = require("consola"); 2 | const models = require("./models/index.js"); 3 | const options = { 4 | seedUsers: true, 5 | }; 6 | 7 | module.exports = async () => { 8 | const usersToCreate = [ 9 | { 10 | name: "Super Admin", 11 | email: "admin@paradynamix.com", 12 | password: "password", 13 | isVerified: true, 14 | userType: 3, 15 | }, 16 | ]; 17 | await models.User.build(usersToCreate[0]).save() 18 | if (options.seedUsers) { 19 | await models.User.findAll().then(async function (users) { 20 | if (!users.length) { 21 | for (let i = 0; i < usersToCreate.length; i++) { 22 | await models.User.build(usersToCreate[i]).save(); 23 | console.log("User Created: " + usersToCreate[i].name); 24 | } 25 | } else { 26 | console.log("User already exist. Not seeding Users."); 27 | } 28 | }); 29 | } 30 | 31 | // if (options.seedUsers) { 32 | // await models.User.findAll().then(async function (users) { 33 | // if (!users.length) { 34 | // console.log("Creating 50 Users..."); 35 | // for (let i = 1; i <= 50; i++) { 36 | // await models.User.build({ 37 | // name: `user${i}`, 38 | // email: `user${i}@gmail.com`, 39 | // password: "password", 40 | // isVerified: true, 41 | // }).save(); 42 | // } 43 | // console.log("Users Created"); 44 | // } else { 45 | // console.log("Users already exist. Not seeding Users."); 46 | // } 47 | // }); 48 | // } 49 | 50 | consola.success("Database seeding completed."); 51 | }; 52 | -------------------------------------------------------------------------------- /bba-server/translation/colorLocksQuery.js: -------------------------------------------------------------------------------- 1 | const generateWhereString = require("./generateWhereString"); 2 | 3 | const translateColorLocks = (whereConditions = null) => { 4 | const query = ` 5 | SELECT 6 | id, 7 | lock_id AS lockId, 8 | color_key AS color, 9 | combination, 10 | color AS ColorValue 11 | FROM 12 | settings_colorcombinations 13 | `; 14 | 15 | const whereClause = whereConditions ? generateWhereString(whereConditions) : ''; 16 | if(whereClause) { 17 | return `SELECT * FROM (${query}) AS sub WHERE ${whereClause}` 18 | } 19 | 20 | return query; 21 | }; 22 | 23 | module.exports = {translateColorLocks}; -------------------------------------------------------------------------------- /bba-server/translation/deliveryExtrasQuery.js: -------------------------------------------------------------------------------- 1 | const generateWhereString = require("./generateWhereString"); 2 | 3 | const translateDeliveryExtras = (whereConditions = null) => { 4 | const query = ` 5 | SELECT 6 | t1.id, 7 | t1.item_id, 8 | t1.extra_id, 9 | t3.id AS deliveryOrderId, 10 | t4.name AS extraName, 11 | t2.createdAt, 12 | t2.updatedAt 13 | FROM 14 | reservation_items_extras as t1 15 | left join reservation_items as t2 16 | on t1.item_id = t2.id 17 | left join reservations as t3 18 | on t2.reservation_id = t3.id 19 | left join settings_extras as t4 20 | on t1.extra_id = t4.id 21 | `; 22 | 23 | const whereClause = whereConditions ? generateWhereString(whereConditions) : ''; 24 | if(whereClause) { 25 | return `SELECT * FROM (${query}) AS sub WHERE ${whereClause}` 26 | } 27 | 28 | return query; 29 | }; 30 | 31 | module.exports = translateDeliveryExtras; -------------------------------------------------------------------------------- /bba-server/translation/generateWhereString.js: -------------------------------------------------------------------------------- 1 | const generateWhereString = (whereConditions) => { 2 | let whereString = ''; 3 | 4 | const processConditions = (conditions, operator) => { 5 | return Object.keys(conditions).map((field) => { 6 | if (conditions[field] === null) { 7 | return `${field} is null`; 8 | } else if (conditions[field] == 'NOT NULL') { 9 | return `${field} is not null`; 10 | } else if (typeof conditions[field] === 'object') { 11 | return Object.keys(conditions[field]).map((operation) => { 12 | return `\`${field}\` ${operation} '${conditions[field][operation]}'`; 13 | }).join(' AND '); 14 | } else { 15 | return `${field} = '${conditions[field]}'`; 16 | } 17 | }).join(` ${operator} `); 18 | }; 19 | 20 | const orConditions = whereConditions?.or ? processConditions(whereConditions.or, 'OR') : ''; 21 | const andConditions = whereConditions?.and ? processConditions(whereConditions.and, 'AND') : ''; 22 | 23 | if (orConditions && andConditions) { 24 | whereString = `(${orConditions}) AND ${andConditions}`; 25 | } else { 26 | whereString = orConditions || andConditions; 27 | } 28 | 29 | return whereString; 30 | }; 31 | 32 | module.exports = generateWhereString; -------------------------------------------------------------------------------- /bba-server/webHook/index.js: -------------------------------------------------------------------------------- 1 | const webHook = require("./webHook"); 2 | 3 | 4 | module.exports = { 5 | create: (app) => { 6 | // Create the routes 7 | app.use("/webhook", webHook); 8 | }, 9 | }; 10 | -------------------------------------------------------------------------------- /bba-server/webHook/webHook.js: -------------------------------------------------------------------------------- 1 | const express = require("express"); 2 | const router = express.Router(); 3 | fs = require('fs'); 4 | var path = require('path'); 5 | const axios = require('axios'); 6 | 7 | const models = require("../models"); 8 | 9 | router.get('/', (req, res) => { 10 | //For testing, send to the /delivery endpoint after read JSON file (log.json for the mockup data) 11 | var jsonPath = path.join(__dirname, '..', 'log.json'); 12 | // Instead of fs.readFile function, to getting the real data from outside endpoint, 13 | // need to add outside endpoint here. 14 | try{ 15 | fs.readFile(jsonPath, 'utf8', async function (err,data) { 16 | if (err) { 17 | return res.send(err) 18 | } 19 | try{ 20 | let payload = JSON.parse(data); 21 | const request = await axios.post(process.env.BASE_URL + "/api/user/deliveryorder", payload, { headers: {'Content-Type': 'application/json'} }); 22 | }catch(error){ 23 | 24 | } 25 | 26 | //axios post to deliveryorder endpoint 27 | return res.send(data) 28 | 29 | }); 30 | }catch(error){ 31 | res.send(error) 32 | } 33 | }) 34 | 35 | module.exports = router; 36 | -------------------------------------------------------------------------------- /client.DockerFile: -------------------------------------------------------------------------------- 1 | FROM node:14.17.1 -------------------------------------------------------------------------------- /demo-3rdP/app.js: -------------------------------------------------------------------------------- 1 | const express = require("express"); 2 | const app = express(); 3 | const port = 8000; 4 | fs = require("fs"); 5 | const axios = require("axios"); 6 | 7 | app.get('/webhook', (req, res) => { 8 | //read JSON and send to the /delivery endpoint 9 | try{ 10 | fs.readFile('data.json', 'utf8', async function (err,data) { 11 | if (err) { 12 | return res.send(err) 13 | } 14 | try{ 15 | let payload = JSON.parse(data); 16 | const request = await axios.post("http://localhost:3100/api/user/deliveryorder", payload, { headers: {'Content-Type': 'application/json'} }); 17 | }catch(error){ 18 | console.log(error) 19 | } 20 | 21 | //axios post to deliveryorder endpoint 22 | return res.send(data); 23 | }); 24 | } catch (error) { 25 | res.send(error); 26 | } 27 | 28 | 29 | }) 30 | async function webhookEvent(){ 31 | try{ 32 | await axios.get('http://localhost:8000/webhook').then(result =>{ 33 | // console.log(result) 34 | }); 35 | }catch(error){ 36 | console.log(error) 37 | } 38 | 39 | } 40 | app.listen(port, () => { 41 | webhookEvent(); 42 | console.log(`app listening at http://localhost:${port}`); 43 | }); 44 | -------------------------------------------------------------------------------- /demo-3rdP/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "bba-webhook", 3 | "version": "1.0.0", 4 | "description": "", 5 | "main": "index.js", 6 | "scripts": { 7 | "test": "echo \"Error: no test specified\" && exit 1" 8 | }, 9 | "author": "", 10 | "license": "ISC", 11 | "dependencies": { 12 | "axios": "^0.21.1", 13 | "express": "^4.17.1" 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /node_modules/.yarn-integrity: -------------------------------------------------------------------------------- 1 | { 2 | "systemParams": "linux-x64-115", 3 | "modulesFolders": [ 4 | "node_modules" 5 | ], 6 | "flags": [], 7 | "linkedModules": [], 8 | "topLevelPatterns": [ 9 | "idb@^8.0.0" 10 | ], 11 | "lockfileEntries": { 12 | "idb@^8.0.0": "https://registry.yarnpkg.com/idb/-/idb-8.0.0.tgz#33d7ed894ed36e23bcb542fb701ad579bfaad41f" 13 | }, 14 | "files": [], 15 | "artifacts": {} 16 | } -------------------------------------------------------------------------------- /node_modules/idb/LICENSE: -------------------------------------------------------------------------------- 1 | ISC License (ISC) 2 | Copyright (c) 2016, Jake Archibald 3 | 4 | Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted, provided that the above copyright notice and this permission notice appear in all copies. 5 | 6 | THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 7 | -------------------------------------------------------------------------------- /node_modules/idb/build/async-iterators.d.ts: -------------------------------------------------------------------------------- 1 | export {}; 2 | -------------------------------------------------------------------------------- /node_modules/idb/build/database-extras.d.ts: -------------------------------------------------------------------------------- 1 | export {}; 2 | -------------------------------------------------------------------------------- /node_modules/idb/build/index.d.ts: -------------------------------------------------------------------------------- 1 | export * from './entry.js'; 2 | import './database-extras.js'; 3 | import './async-iterators.js'; 4 | -------------------------------------------------------------------------------- /node_modules/idb/build/util.d.ts: -------------------------------------------------------------------------------- 1 | export declare type Constructor = new (...args: any[]) => any; 2 | export declare type Func = (...args: any[]) => any; 3 | export declare const instanceOfAny: (object: any, constructors: Constructor[]) => boolean; 4 | -------------------------------------------------------------------------------- /node_modules/idb/build/wrap-idb-value.d.ts: -------------------------------------------------------------------------------- 1 | import { IDBPCursor, IDBPCursorWithValue, IDBPDatabase, IDBPIndex, IDBPObjectStore, IDBPTransaction } from './entry.js'; 2 | export declare const reverseTransformCache: WeakMap; 3 | export declare function replaceTraps(callback: (currentTraps: ProxyHandler) => ProxyHandler): void; 4 | /** 5 | * Enhance an IDB object with helpers. 6 | * 7 | * @param value The thing to enhance. 8 | */ 9 | export declare function wrap(value: IDBDatabase): IDBPDatabase; 10 | export declare function wrap(value: IDBIndex): IDBPIndex; 11 | export declare function wrap(value: IDBObjectStore): IDBPObjectStore; 12 | export declare function wrap(value: IDBTransaction): IDBPTransaction; 13 | export declare function wrap(value: IDBOpenDBRequest): Promise; 14 | export declare function wrap(value: IDBRequest): Promise; 15 | /** 16 | * Revert an enhanced IDB object to a plain old miserable IDB one. 17 | * 18 | * Will also revert a promise back to an IDBRequest. 19 | * 20 | * @param value The enhanced object to revert. 21 | */ 22 | interface Unwrap { 23 | (value: IDBPCursorWithValue): IDBCursorWithValue; 24 | (value: IDBPCursor): IDBCursor; 25 | (value: IDBPDatabase): IDBDatabase; 26 | (value: IDBPIndex): IDBIndex; 27 | (value: IDBPObjectStore): IDBObjectStore; 28 | (value: IDBPTransaction): IDBTransaction; 29 | (value: Promise>): IDBOpenDBRequest; 30 | (value: Promise): IDBOpenDBRequest; 31 | (value: Promise): IDBRequest; 32 | } 33 | export declare const unwrap: Unwrap; 34 | export {}; 35 | -------------------------------------------------------------------------------- /node_modules/idb/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "idb", 3 | "version": "8.0.0", 4 | "description": "A small wrapper that makes IndexedDB usable", 5 | "main": "./build/index.cjs", 6 | "module": "./build/index.js", 7 | "types": "./build/index.d.ts", 8 | "exports": { 9 | ".": { 10 | "types": "./build/index.d.ts", 11 | "module": "./build/index.js", 12 | "import": "./build/index.js", 13 | "default": "./build/index.cjs" 14 | }, 15 | "./build/*": "./build/*", 16 | "./package.json": "./package.json" 17 | }, 18 | "files": [ 19 | "build/**", 20 | "with-*", 21 | "CHANGELOG.md" 22 | ], 23 | "type": "module", 24 | "scripts": { 25 | "build": "PRODUCTION=1 rollup -c && node --experimental-modules lib/size-report.mjs", 26 | "dev": "rollup -c --watch", 27 | "prepack": "npm run build" 28 | }, 29 | "repository": { 30 | "type": "git", 31 | "url": "git://github.com/jakearchibald/idb.git" 32 | }, 33 | "author": "Jake Archibald", 34 | "license": "ISC", 35 | "devDependencies": { 36 | "@rollup/plugin-commonjs": "^22.0.2", 37 | "@rollup/plugin-node-resolve": "^14.1.0", 38 | "@types/chai": "^4.3.3", 39 | "@types/estree": "^1.0.0", 40 | "@types/mocha": "^9.1.1", 41 | "chai": "^4.3.6", 42 | "conditional-type-checks": "^1.0.6", 43 | "del": "^7.0.0", 44 | "filesize": "^9.0.11", 45 | "glob": "^8.0.3", 46 | "mocha": "^10.0.0", 47 | "prettier": "^2.7.1", 48 | "rollup": "^2.79.0", 49 | "rollup-plugin-terser": "^7.0.2", 50 | "typescript": "^4.8.3" 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "dependencies": { 3 | "idb": "^8.0.0" 4 | } 5 | } 6 | -------------------------------------------------------------------------------- /server.DockerFile: -------------------------------------------------------------------------------- 1 | # Use node 14.17.1 LTS 2 | FROM node:14.17.1 3 | ENV LAST_UPDATED 20210617T132300 4 | 5 | #Copy Source Code 6 | COPY . /bba-server 7 | 8 | #Change Working Directory 9 | WORKDIR /bba-server 10 | 11 | #Install Dependencies 12 | RUN npm install pm2 -g 13 | RUN npm install 14 | 15 | #EXPOSE API Port to the Outside 16 | EXPOSE 80 17 | 18 | #LAUCNH APPLICATION 19 | CMD ["pm2-runtime", "ecosystem.config.js"] --------------------------------------------------------------------------------