How to use baseServer method in mountebank

Best JavaScript code snippet using mountebank

data.factory.js

Source:data.factory.js Github

copy

Full Screen

1'use strict';2angular.module('dmc.data', [])3 .factory('dataFactory', function($window, $location) {4 var baseServer = $window.apiUrl ? $window.apiUrl : '/static/?p=';5 var baseServerStatic = $window.apiUrl ? $window.apiUrl.substring(0, $window.apiUrl.length - 5) + '/static' : '/static';6 var localhost = ($location.$$absUrl.indexOf('http://localhost') != -1 || $location.$$absUrl.indexOf(':9000') != -1 ? 'http://localhost:3000/' : '');7 //localhost = $window.apiUrl ? $window.apiUrl + '/' : localhost;8 localhost = 'http://localhost:3000/';9 console.log('localhost ' + localhost)10 var urlSocketServer = 'http://localhost:3000/';11 var appendId = function(id) {12 return ($window.apiUrl && id ? '/' + id : '');13 };14 var webServiceUrl = function(path, action, id) {15 var wsurl;16 if ($window.apiUrl && id) {17 wsurl = '/' + path + '/' + id;18 wsurl += action ? '/' + action : '';19 } else {20 wsurl = '/' + action;21 }22 return wsurl;23 };24 var convertParams = function(params) {25 return $.map(params, function(item, key) {26 return key + '=' + item;27 }).join('&');28 };29return {30 get_result: function(data) {31 var obj = {};32 if ($window.apiUrl) {33 if (data.length >= 1) {34 obj.result = data;35 obj.count = data.length;36 } else {37 obj.result = data;38 }39 } else {40 obj = data;41 }42 return obj;43 },44 get_request_obj: function(source) {45 var obj = {}46 if ($window.apiUrl) {47 obj = _.transform(source, function(result, value, key) {48 if (value && key != 'projectId' && key != 'profileId' && key != 'companyId') {49 result['_' + key] = value;50 }51 });52 } else {53 obj = source;54 }55 return obj;56 },57 url_php_server: function() {58 return baseServer;59 },60 url_socket_server: function() {61 return urlSocketServer;62 },63 getUrlAllServices: function(id) {64 // return baseServer+'/services'+appendId(id);65 return baseServer + webServiceUrl('projects', 'services', id);66 },67 getUrlChangeService: function(id) {68 return baseServer + '/change_service' + appendId(id);69 },70 getStaticJSON: function(id) {71 return baseServerStatic + '/staticJSON.php?title=' + id;72 },73 getUrlAllTasks: function(id) {74 // return baseServer+'/tasks'+appendId(id);75 return baseServer + webServiceUrl('projects', 'tasks', id);76 },77 getUrlChangeTask: function(id) {78 return baseServer + '/change_tasks' + appendId(id);79 },80 getUrlAllDiscussions: function(id) {81 // return baseServer+'/discussions'+appendId(id);82 return baseServer + webServiceUrl('projects', 'all-discussions', id);83 },84 getUrlAllProjects: function(id) {85 return baseServer + '/projects';86 },87 getWorspaceByName: function(name) {88 return localhost + 'searchworkspace/' + name;89 },90 getUrlAllComponents: function(id) {91 return baseServer + webServiceUrl('projects', 'components', id);92 },93 getUrlAllProducts: function() {94 return baseServer + '/products';95 },96 getUrlAddToProject: function(id) {97 return baseServer + '/add_to_project' + appendId(id);98 },99 getUrlRemoveFromProject: function(id) {100 return baseServer + '/remove_from_project' + appendId(id);101 },102 getUrlAllDocuments: function(id) {103 return baseServer + '/documents' + appendId(id);104 },105 getDocumentUpload: function(id) {106 return baseServer + '/upload' + appendId(id);107 },108 documentUpload: function() {109 return baseServer + '/upload';110 },111 getUrlCreateTask: function(id) {112 var url = baseServer + '/create_task' + appendId(id);113 if (window.apiUrl) {114 url = baseServer + '/tasks/create';115 }116 return url117 },118 getProduct: function() {119 return baseServer + '/product';120 },121 getProductReview: function() {122 return baseServer + '/get_product_review';123 },124 addProductReview: function() {125 return baseServer + '/add_product_review';126 },127 addLikeDislike: function() {128 return baseServer + '/add_like_dislike';129 },130 editProduct: function() {131 return baseServer + '/edit_product';132 },133 uploadAccountPictureUrl: function() {134 return baseServer + '/upp';135 },136 uploadCompanyPictureUrl: function() {137 return baseServer + '/ucp';138 },139 uploadCompanyLogoUrl: function() {140 return baseServer + '/ucl';141 },142 uploadCompanyProfileImageUrl: function() {143 return baseServer + '/uci';144 },145 uploadCompanyProfileSkillImageUrl: function() {146 return baseServer + '/ucsi';147 },148 uploadProfilePictureUrl: function() {149 return baseServer + '/uprpic';150 },151 removeCompanyImages: function() {152 return baseServer + '/remove_company_images';153 },154 removeCompanySkillsImages: function() {155 return baseServer + '/remove_company_skills_images';156 },157 getAccountUrl: function(id) {158 return baseServer + '/get_account' + appendId(id);159 },160 getCompanyUrl: function(id) {161 var idString = $window.apiUrl ? '' : '&id=' + id;162 return baseServer + '/companies' + appendId(id) + idString;163 },164 getCompanyShortUrl: function(id){165 return baseServer+'/companies/short';166 },167 getCompanyReviewUrl: function(id) {168 // return baseServer+'/get_review_company';169 return baseServer + webServiceUrl('companies', 'company_reviews', id);170 },171 addCompanyReviewUrl: function() {172 return baseServer + '/add_review_company';173 },174 getFeaturesCompany: function(id) {175 // return baseServer+'/company_featured';176 return baseServer + webServiceUrl('companies', 'company_featured', id);177 },178 saveCompanyChanges: function() {179 return baseServer + '/save_company_changes';180 },181 addProductToFavorite: function() {182 return baseServer + '/add_product_to_favorite';183 },184 getProfile: function(id) {185 return baseServer + '/profiles' + appendId(id);186 },187 editProfile: function() {188 return baseServer + '/edit_profile';189 },190 getProfileReview: function(id) {191 return baseServer + webServiceUrl('profiles', 'profile_reviews', id);192 },193 addProfileReview: function() {194 return baseServer + '/add_profile_review';195 },196 updateFeaturesPosition: function() {197 return baseServer + '/update_features_position';198 },199 addDiscussionLikeDislike: function() {200 return baseServer + '/add_discussion_like_dislike';201 },202 logoutUrl: function(custom) {203 var home = $window.location.origin;204 return home + '/Shibboleth.sso/Logout?return=' + (custom || home);205 },206 // direct requests207 shareService: function() {208 return localhost + 'shared-services';209 },210 deleteService: function(id) {211 return localhost + 'services/' + id;212 },213 followDiscussion: function() {214 return localhost + 'follow_discussions';215 },216 isUserFollowedDiscussion: function(id) {217 return localhost + 'accounts/' + id + '/follow_discussions';218 },219 unfollowDiscussion: function(id) {220 return localhost + 'follow_discussions/' + id;221 },222 getChildren: function() {223 return localhost + 'getChildren';224 },225 getModel: function() {226 return localhost + 'getModel';227 },228 runModel: function() {229 return localhost + 'model_run';230 },231 runModelWithFile: function() {232 return localhost + 'model_run_file';233 },234 pollModel: function(id) {235 return localhost + 'model_poll/' + id;236 },237 updateServiceStatus: function(id) {238 return localhost + 'service_runs/' + id;239 },240 cancelServiceRun: function(id) {241 return localhost + 'service_runs/cancel_run/' + id;242 },243 getServiceRun: function(id) {244 return localhost + 'service_runs/' + id;245 },246 runService: function() {247 return localhost + 'service_runs';248 },249 getServiceStatus: function(id) {250 return localhost + 'services/' + id + '/service_runs';251 },252 createPublishService: function() {253 return localhost + 'publish-services';254 },255 getFollowCompanies: function(id) {256 return localhost + 'accounts/' + id + '/following_companies';257 },258 getFollowCompanyServices: function() {259 return localhost + 'follow-company-services';260 },261 getServiceDocuments: function(id) {262 return localhost + 'service/' + id + '/service_documents';263 },264 getProjectDocuments: function(id) {265 return localhost + 'projects/' + id + '/project_documents';266 },267 addProjectDocument: function() {268 return localhost + 'project_documents';269 },270 updateProjectDocument: function(id) {271 return localhost + 'project_documents/' + id;272 },273 deleteProjectDocument: function(id) {274 return localhost + 'project_documents/' + id;275 },276 addServiceToProject: function(id) {277 return localhost + 'services/' + id;278 },279 getMembersUrl: function(id) {280 return localhost + 'members';281 },282 getMembersToProject: function() {283 return localhost + 'projects_members';284 },285 createMembersToProject: function() {286 return localhost + 'projects_members';287 },288 acceptProject: function(projectId, memberId) {289 return localhost + 'projects/' + projectId + '/accept/' + memberId;290 },291 declineProject: function(projectId, memberId) {292 return localhost + 'projects/' + projectId + '/reject/' + memberId;293 },294 getProjectMembers: function(id) {295 return localhost + 'projects_members';296 },297 getMembersToProjectById: function(id) {298 return localhost + 'projects_members/' + id;299 },300 updateMembersToProject: function(id) {301 return localhost + 'projects_members/' + id;302 },303 inviteToProject: function(pid, uid) {304 return localhost + 'project/' + pid + '/invite/' + uid;305 },306 removeMembersToProject: function(id) {307 return localhost + 'projects_members/' + id;308 },309 joinProject: function() {310 return localhost + 'projects_join_requests';311 },312 joinProjectRequests: function(id) {313 return localhost + 'projects/' + id + '/joinApprovalRequests';314 },315 manageJoinRequests: function(id) {316 return {317 accept: localhost + 'projectJoinApprovalRequests/' + id + '?action=approve',318 decline: localhost + 'projectJoinApprovalRequests/' + id + '?action=decline'319 };320 },321 getProjectsJoinRequests: function() {322 return localhost + 'projects_join_requests';323 },324 getProjectJoinRequests: function(id) {325 return localhost + 'projects/' + id + '/projects_join_requests';326 },327 deleteProjectJoinRequests: function(id) {328 return localhost + 'projects_join_requests/' + id;329 },330 updateProjectJoinRequests: function(id) {331 return localhost + 'projects_join_requests/' + id;332 },333 addCompanyJoinRequest: function() {334 return localhost + 'companies_join_requests';335 },336 cancelCompanyJoinRequest: function(id) {337 return localhost + 'companies_join_requests/' + id;338 },339 getProfileCompanyJoinRequest: function(id) {340 return localhost + 'profiles/' + id + '/companies_join_requests';341 },342 addSuggestJoinCompany: function() {343 return localhost + 'suggest_join_companies';344 },345 cancelSuggestJoinCompany: function(id) {346 return localhost + 'suggest_join_companies/' + id;347 },348 getSuggestJoinCompany: function(id) {349 return localhost + 'companies/' + id + '/suggest_join_companies';350 },351 followMember: function(id) {352 return localhost + 'following_members' + (id ? '/' + id : '');353 },354 getAccountFollowedMembers: function(id) {355 return localhost + 'accounts/' + id + '/following_members';356 },357 projectMembers: function(id) {358 return localhost + 'projects/' + id + '/projects_members';359 },360 deleteProjectMember: function(id) {361 return localhost + 'projects_members/' + id;362 },363 deleteProject: function(id) {364 return localhost + 'projects/' + id;365 },366 getCreateProject: function() {367 return localhost + 'projects/create';368 },369 getProjects: function(type) {370 return localhost + (type == 'all-projects' ? 'projects/all' : 'projects');371 },372 getPublicProjects: function() {373 return localhost + 'projects/public';374 },375 getMyProjects: function() {376 return localhost + 'projects/my-projects';377 },378 getProject: function(id) {379 return localhost + 'projects/' + id;380 },381 updateProject: function(id) {382 return localhost + 'projects/' + id;383 },384 addProjectTag: function() {385 return localhost + 'projects_tags';386 },387 getProjectsTags: function() {388 return localhost + 'projects_tags';389 },390 deleteProjectTag: function(id) {391 return localhost + 'projects_tags/' + id;392 },393 getProjectTags: function(id) {394 return localhost + 'projects/' + id + '/projects_tags/';395 },396 getAssignUsers: function() {397 return localhost + 'assign_users';398 },399 createTask: function() {400 return localhost + 'tasks/create';401 },402 updateTask: function(id) {403 return localhost + 'tasks/' + id;404 },405 getMyServices: function() {406 return localhost + 'my-services';407 },408 getMyTasks: function() {409 return localhost + 'my-tasks';410 },411 getTasks: function(projectId) {412 if (projectId) {413 return localhost + 'projects/' + projectId + '/tasks';414 } else {415 return localhost + 'tasks';416 }417 },418 getTask: function(id) {419 return localhost + 'tasks/' + id;420 },421 deleteTask: function(id) {422 return localhost + 'tasks/' + id;423 },424 followCompany: function() {425 return localhost + 'company/follow';426 },427 unfollowCompany: function(id) {428 return localhost + 'company/unfollow/' + id;429 },430 getRelatedArticles: function(id) {431 return localhost + 'faq_articles';432 },433 getFAQArticle: function(id) {434 return localhost + 'faq_articles/' + id;435 },436 getFAQSubcategories: function() {437 return localhost + 'faq_subcategories';438 },439 getFAQCategories: function() {440 return localhost + 'faq_categories';441 },442 getEvents: function() {443 return localhost + 'events';444 },445 getAnnouncements: function() {446 return localhost + 'announcements';447 },448 getAnnouncementsComments: function(id) {449 return localhost + 'announcements/' + id + '/announcement_comments';450 },451 updateCompanyFeaturedPosition: function(id) {452 return localhost + 'company_featured/' + id + '/position';453 },454 addCompanyFeatured: function() {455 return localhost + 'company_featured/add';456 },457 removeCompanyFeatured: function(id) {458 return localhost + 'company_featured/' + id;459 },460 getCompanyFeatured: function(id) {461 return localhost + 'companies/' + id + '/company_featured';462 },463 getCompanyServices: function(id) {464 return localhost + 'companies/' + id + '/company_services';465 },466 getCompanyComponents: function(id) {467 return localhost + 'companies/' + id + '/company_components';468 },469 getNewCompanyServices: function(id) {470 return localhost + 'companies/' + id + '/new';471 },472 createStorefrontMessage: function() {473 return localhost + 'messages';474 },475 userRole: function() {476 return localhost + 'userRole';477 },478 updateUser: function() {479 return localhost + 'user';480 },481 generateToken: function(id) {482 return localhost + 'user/createtoken?userId=' + id;483 },484 emailToken: function(id, token) {485 return localhost + 'users/' + id + '/email?token=' + token;486 },487 validateToken: function(id, token) {488 return localhost + 'users/' + id + '?action=verify'489 },490 unverify: function(id) {491 return localhost + 'users/' + id + '?action=unverify';492 },493 declineMember: function(id) {494 return localhost + 'users/' + id + '?action=decline';495 },496 uploadApplication: function() {497 return localhost + 'appSubmission';498 },499 getApplicationNames: function() {500 return localhost + 'appSubmission/appName';501 },502 getDmdiiMemberTags: function() {503 return localhost + 'tags/dmdiiMember';504 },505 getOrgTags: function() {506 return localhost + 'tags/organization';507 },508 getUsersByOrganization: function(id) {509 return localhost + 'user/organization/' + id510 //add paged and filtered511 },512 changeUserOrganization: function(id) {513 return localhost + 'users/' + id + '/organizations';514 },515 getOrganizationList: function() {516 return localhost + 'organizations';517 },518 getOrganization: function(id) {519 return localhost + 'organizations/' + id;520 },521 updateOrganization: function(id) {522 return localhost + 'organizations/' + id;523 },524 createOrganization: function(id) {525 return localhost + 'organizations/';526 },527 deleteOrganization: function(id) {528 return localhost + 'organizations/' + id;529 },530 getDocument: function() {531 return {532 byType: localhost + 'documents/organization'533 }534 },535 getDMDIIMember: function(id) {536 return {537 get: localhost + 'dmdiiMember/' + id,538 all: localhost + 'dmdiiMember',539 full: localhost + 'dmdiiMember/all',540 search: localhost + 'dmdiiMember/search',541 map: localhost + 'dmdiiMember/mapEntry'542 }543 },544 dmdiiMemberNewsUrl: function(id) {545 return {546 get: localhost + 'dmdiiMember/news',547 save: localhost + 'dmdiiMember/news',548 delete: localhost + 'dmdiiMember/news/' + id549 }550 },551 dmdiiMemberEventUrl: function(id) {552 return {553 get: localhost + 'dmdiiMember/events',554 save: localhost + 'dmdiiMember/events',555 delete: localhost + 'dmdiiMember/events/' + id556 }557 },558 getDMDIIMemberProjects: function() {559 return {560 prime: localhost + 'dmdiiprojects/member',561 contributing: localhost + 'contributingCompanies'562 }563 },564 saveDMDIIMember: function() {565 return {566 member: localhost + 'dmdiiMember/save'567 }568 },569 getDMDIIProject: function(id) {570 return {571 get: localhost + 'dmdiiProject/' + id,572 all: localhost + 'dmdiiprojects',573 delete: localhost + 'dmdiiProjects/' + id,574 active: localhost + 'dmdiiprojects/member/active',575 contributors: localhost + 'dmdiiproject/contributingcompanies',576 search: localhost + 'dmdiiprojects/search'577 }578 },579 getDMDIIEvents: function(id) {580 return {581 get: localhost + 'dmdiievent/' + id,582 all: localhost + 'dmdiievents'583 }584 },585 saveDMDIIProject: function() {586 return {587 project: localhost + 'dmdiiProject/save'588 }589 },590 dmdiiProjectUpdateUrl: function(id) {591 return {592 get: localhost + 'dmdiiProjectUpdate',593 save: localhost + 'dmdiiProjectUpdate',594 delete: localhost + 'dmdiiProjectUpdate/' + id595 }596 },597 dmdiiProjectEventUrl: function(id) {598 return {599 get: localhost + 'dmdiiProject/events',600 save: localhost + 'dmdiiProject/events',601 delete: localhost + 'dmdiiProject/events/' + id602 }603 },604 dmdiiProjectNewsUrl: function(id) {605 return {606 get: localhost + 'dmdiiProject/news',607 save: localhost + 'dmdiiProject/news',608 delete: localhost + 'dmdiiProject/news/' + id609 };610 },611 quicklinkUrl: function(id) {612 return {613 get: localhost + 'dmdiiquicklink',614 save: localhost + 'dmdiiquicklink',615 delete: localhost + 'dmdiiquicklink/' + id616 };617 },618 payment: function(){619 return {620 pay: localhost + 'payment',621 organizations: localhost + 'organizations/user'622 };623 },624 getDMDIIDocuments: function(id) {625 return {626 all: localhost + 'dmdiidocuments',627 single: localhost + 'dmdiidocument/' + id,628 project: localhost + 'dmdiidocuments/dmdiiProjectId',629 overview: localhost + 'staticdocument/1',630 status: localhost + 'staticdocument/2',631 projectDocument: localhost + 'dmdiidocument/filetype'632 };633 },634 saveDMDIIDocument: function() {635 return localhost + 'dmdiidocument';636 },637 deleteDMDIIDocument: function(id) {638 return localhost + 'dmdiidocument/' + id;639 },640 documentsUrl: function(id, user, internal, email, url) {641 return {642 getSingle: localhost + 'documents/' + id,643 getList: localhost + 'documents',644 getListIds: localhost + 'documents?ids=' + id,645 download: localhost + 'documents/' + id + '/download',646 save: localhost + 'documents',647 update: localhost + 'documents/' + id,648 delete: localhost + 'documents/' + id,649 versioned: localhost + 'documents/versions/' + id,650 s_versioned: localhost + 'documents/s_versions/' + id,651 // share: localhost + 'documents/'+id+'/user/'+userid652 share: localhost + 'documents/' + id + '/share?user=' + user + '&internal=' + internal + '&email=' + email,653 accept: localhost + 'documents/' + id + '/accept',654 shareWs: localhost + 'documents/' + id + '/shareWs?ws=' + user,655 // saveSr: localhost + 'documents/' + id + '/saveSr?url=' + user656 saveSr: localhost + 'documents/' + id + '/saveSr'657 }658 },659 directoriesUrl: function(id) {660 var endpoint = 'directories/';661 return {662 get: localhost + endpoint + id,663 list: localhost + endpoint,664 save: localhost + endpoint,665 update: localhost + endpoint + id,666 delete: localhost + endpoint + id,667 files: localhost + 'documents/' + endpoint + id,668 s_files: localhost + 'documents/' + 's_' + endpoint + id669 }670 },671 getApplicationTags: function() {672 return localhost + 'applicationTag'673 },674 getDmdiiDocumentTags: function() {675 return localhost + 'dmdiidocuments/getAllTags';676 },677 getDocumentTags: function() {678 return localhost + 'documents/tags';679 },680 createDocumentTag: function() {681 return localhost + 'dmdiidocuments/saveDocumentTag';682 },683 getNonDmdiiMembers: function() {684 return localhost + 'organization/nonMember';685 },686 // companies ------------------687 companyURL: function(id) {688 var name = 'companies';689 return {690 get: localhost + name + '/' + id,691 update: localhost + name + '/' + id,692 delete: localhost + name + '/' + id,693 create: localhost + name,694 all: localhost + name,695 short : localhost+name+'/short',696 reviews: localhost + name + '/' + id + '/company_reviews?reviewId=0',697 addReviews: localhost + 'company_reviews',698 get_review: localhost + 'company_reviews/' + id,699 update_review: localhost + 'company_reviews/' + id,700 getReply: localhost + 'company_reviews?reviewId=' + id,701 getHelpful: localhost + 'company_reviews_helpful',702 addHelpful: localhost + 'company_reviews_helpful',703 updateHelpful: localhost + 'company_reviews_helpful/' + id,704 getFlagged: localhost + 'company_reviews_flagged',705 addFlagged: localhost + 'company_reviews_flagged',706 history: localhost + name + '/' + id + '/company_history',707 profiles: localhost + name + '/' + id + '/profiles',708 get_removed_members: localhost + name + '/' + id + '/removed_company_members',709 remove_member: localhost + 'removed_company_members',710 remove_member_from_removed: localhost + 'removed_company_members/' + id,711 get_member_requests: localhost + name + '/' + id + '/companies_join_requests',712 approve_member: localhost + 'companies_join_requests/' + id,713 decline_member: localhost + 'companies_join_requests/' + id,714 add_contact_method: localhost + 'company_contact_methods',715 get_contact_methods: localhost + name + '/' + id + '/company_contact_methods',716 update_contact_method: localhost + 'company_contact_methods/' + id,717 delete_contact_method: localhost + 'company_contact_methods/' + id718 }719 },720 // ---------------------------721 updateAccount: function(id) {722 return localhost + 'accounts/' + id;723 },724 getAccount: function(id) {725 return localhost + 'accounts/' + id;726 },727 // servers ------------------728 serverURL: function(id) {729 var name = 'account_servers';730 return {731 get: localhost + name + '/' + id,732 update: localhost + name + '/' + id,733 delete: localhost + name + '/' + id,734 create: localhost + name,735 all: localhost + name736 }737 },738 getAccountServersUrl: function(id) {739 return localhost + 'accounts/' + id + '/account_servers';740 },741 getServerSecureUrl: function(id) {742 return localhost + 'accounts/' + id + '/servers';743 },744 // ---------------------------745 getServices: function(projectId) {746 if (projectId) {747 return localhost + 'projects/' + projectId + '/services';748 } else {749 return localhost + 'services';750 }751 },752 getComponents: function() {753 return localhost + 'components';754 },755 getMarketPopularServices: function() {756 return localhost + 'market/popular_services';757 },758 getMarketNewServices: function() {759 return localhost + 'market/new_services';760 },761 getMarketServices: function() {762 return localhost + 'market/new_services';763 },764 getMarketComponents: function() {765 return localhost + 'market/components';766 },767 getMarketPlaceServices: function() {768 return localhost + 'market/services';769 },770 getServicesTags: function() {771 return localhost + 'service_tags';772 },773 getDefaultServices: function() {774 return localhost + 'defaultServices';775 },776 getDefaultService: function(parentId) {777 return localhost + 'defaultServices/' + parentId;778 },779 userFavorites: function(contentId, contentType) {780 var name = 'userFavorites';781 return {782 get: localhost + name + ((contentType != null) ? '?contentType=' + contentType : ''),783 create: localhost + name + '?contentId=' + contentId + '&contentType=' + contentType,784 delete: localhost + name + '?contentId=' + contentId + '&contentType=' + contentType,785 };786 },787 /// profiles -----------------788 profiles: function(id) {789 var name = 'profiles';790 return {791 get: localhost + name + '/' + id,792 update: localhost + name + '/' + id,793 reviews: localhost + name + '/' + id + '/profile_reviews?reviewId=0',794 get_review: localhost + 'profile_reviews/' + id,795 addReviews: localhost + 'profile_reviews',796 update_review: localhost + 'profile_reviews/' + id,797 getReply: localhost + 'profile_reviews?reviewId=' + id,798 getHelpful: localhost + 'profile_reviews_helpful',799 addHelpful: localhost + 'profile_reviews_helpful',800 updateHelpful: localhost + 'profile_reviews_helpful/' + id,801 getFlagged: localhost + 'profile_reviews_flagged',802 addFlagged: localhost + 'profile_reviews_flagged',803 history: localhost + name + '/' + id + '/profile_history',804 all: localhost + name805 }806 },807 getRecentUpdates: function() {808 return localhost + 'recent_updates';809 },810 // ---------------------------811 /// components -----------------812 components: function(type, id) {813 var name = type;814 return {815 get: localhost + name + '/' + id,816 update: localhost + name + '/' + id,817 all: localhost + name,818 getReply: localhost + 'product_reviews?reviewId=' + id,819 get_review: localhost + 'product_reviews/' + id,820 update_review: localhost + 'product_reviews/' + id,821 reviews: localhost + 'product/' + id + '/product_reviews?productType=' + type + '&reviewId=0',822 addReviews: localhost + 'product_reviews',823 getHelpful: localhost + 'product_reviews_helpful',824 addHelpful: localhost + 'product_reviews_helpful',825 updateHelpful: localhost + 'product_reviews_helpful/' + id,826 getFlagged: localhost + 'product_reviews_flagged',827 addFlagged: localhost + 'product_reviews_flagged',828 get_included: localhost + 'included-services',829 remove_included: localhost + 'included-services/' + id,830 add_included: localhost + 'included-services',831 get_tags: localhost + 'service_tags',832 add_tags: localhost + 'service_tags',833 get_images: localhost + name + '/' + id + '/service_images',834 add_images: localhost + 'service_images',835 remove_images: localhost + 'service_images/' + id,836 remove_tags: localhost + 'service_tags/' + id,837 edit_specifications: localhost + 'specifications/' + id,838 get_array_specifications: localhost + 'array_specifications',839 add_array_specifications: localhost + 'array_specifications'840 }841 },842 // ---------------------------843 /// services -----------------844 services: function(id) {845 var name = 'services';846 return {847 get: localhost + name + '/' + id,848 getArray: localhost + name + "?id=" + id,849 add: localhost + name,850 get_for_project: localhost + 'projects/' + id + '/' + name,851 update: localhost + name + '/' + id,852 all: localhost + name,853 getReply: localhost + 'product_reviews?reviewId=' + id,854 reviews: localhost + 'product/' + id + '/product_reviews?reviewId=0',855 get_review: localhost + 'product_reviews/' + id,856 update_review: localhost + 'product_reviews/' + id,857 addReviews: localhost + 'product_reviews',858 getHelpful: localhost + 'product_reviews_helpful',859 addHelpful: localhost + 'product_reviews_helpful',860 updateHelpful: localhost + 'product_reviews_helpful/' + id,861 getFlagged: localhost + 'product_reviews_flagged',862 addFlagged: localhost + 'product_reviews_flagged',863 get_authors: localhost + 'services/' + id + '/service_authors',864 remove_authors: localhost + 'service_authors/' + id,865 add_authors: localhost + 'service_authors',866 get_tags: localhost + name + '/' + id + '/service_tags',867 add_tags: localhost + 'service_tags',868 remove_tags: localhost + 'service_tags/' + id,869 update_tag: localhost + 'service_tags/' + id,870 get_history: localhost + name + '/' + id + '/services_history',871 get_run_history: localhost + 'service_runs' + '?serviceId=' + id,872 get_servers: localhost + 'account_servers',873 add_servers: localhost + 'services_servers',874 get_array_specifications: localhost + 'array_specifications',875 add_array_specifications: localhost + 'array_specifications',876 get_specifications: localhost + name + '/' + id + '/specifications',877 add_specifications: localhost + 'service/' + id + '/specifications',878 update_specifications: localhost + '/specifications/' + id,879 get_statistics: localhost + name + '/' + id + '/services_statistic',880 add_interface: localhost + 'dome-interfaces',881 get_interface: localhost + name + '/' + id + '/dome-interfaces',882 update_interface: localhost + 'dome-interfaces/' + id,883 get_position_inputs: localhost + name + '/' + id + '/input-positions',884 update_position_inputs: localhost + 'input-positions/' + id,885 add_position_inputs: localhost + 'input-positions'886 }887 },888 // ---------------------------889 uploadServiceImageUrl: function() {890 return baseServer + '/uploadServiceImage';891 },892 getFavoriteProducts: function() {893 return localhost + 'favorite_products';894 },895 deactivateAccount: function(id) {896 return localhost + 'accounts' + (id ? '/' + id : '');897 },898 getDiscussions: function(projectId, dataTypeWidget) {899 if (!projectId && !dataTypeWidget) {900 return localhost + 'individual-discussions';901 } else {902 if (projectId) {903 if (dataTypeWidget) {904 switch (dataTypeWidget) {905 case 'following':906 return localhost + 'projects/' + projectId + '/following_discussions';907 default:908 return localhost + 'projects/' + projectId + '/individual-discussions';909 }910 } else {911 return localhost + 'projects/' + projectId + '/individual-discussion';912 }913 } else if (dataTypeWidget) {914 switch (dataTypeWidget) {915 case 'following':916 return localhost + 'following_discussions';917 case 'popular':918 return localhost + 'popular_discussions';919 case 'follow-people':920 return localhost + 'follow_people_discussions';921 default:922 return localhost + 'individual-discussion';923 }924 }925 }926 },927 deleteCompanyLogo: function(id) {928 return localhost + 'companies' + (id ? '/' + id : '');929 },930 saveChangedDiscussionComment: function(id) {931 return localhost + 'individual-discussion-comments' + (id ? '/' + id : '');932 },933 addDiscussionTag: function() {934 return localhost + 'individual-discussion-tags';935 },936 getLastDiscussionTagId: function() {937 return localhost + 'individual-discussion-tags';938 },939 getDiscussionTags: function(id) {940 return localhost + 'individual-discussion/' + id + '/individual-discussion-tags'941 },942 deleteDiscussionTag: function(id) {943 return localhost + 'individual-discussion-tags' + (id ? '/' + id : '');944 },945 deleteDiscussionComment: function(id) {946 return localhost + 'individual-discussion-comments' + (id ? '/' + id : '');947 },948 getDiscussionComments: function(id) {949 return localhost + 'individual-discussion/' + id + '/individual-discussion-comments?commentId=0';950 },951 ///952 getDiscussionsReply: function(id) {953 return localhost + 'individual-discussion-comments?commentId=' + id;954 },955 getDiscussionCommentsHelpful: function() {956 return localhost + 'individual-discussion-comments-helpful';957 },958 addDiscussionCommentsHelpful: function() {959 return localhost + 'individual-discussion-comments-helpful';960 },961 updateDiscussionCommentsHelpful: function(id) {962 return localhost + 'individual-discussion-comments-helpful/' + id;963 },964 getDiscussionCommentsFlagged: function() {965 return localhost + 'individual-discussion-comments-flagged';966 },967 addDiscussionCommentsFlagged: function() {968 return localhost + 'individual-discussion-comments-flagged';969 },970 ///971 getIndividualDiscussion: function(id) {972 return localhost + 'individual-discussion' + (id ? '/' + id : '');973 },974 getIndividualDiscussions: function() {975 return localhost + 'individual-discussion';976 },977 addCommentIndividualDiscussion: function() {978 return localhost + 'individual-discussion-comments'979 },980 getLastDiscussionCommentId: function() {981 return localhost + 'individual-discussion-comments'982 },983 getLastDiscussionId: function() {984 return localhost + 'individual-discussion'985 },986 addDiscussion: function() {987 return localhost + 'individual-discussion'988 },989 /*990 getCompanyImages : function(id){991 return localhost+'companies/'+id+'/company_images'992 },993 getCompanySkillsImages: function(id){994 return localhost+'companies/'+id+'/company_skill_images'995 },996 getCompanyVideos : function(id){997 return localhost+'companies/'+id+'/company_videos'998 },999 getCompanySkills : function(id){1000 return localhost+'companies/'+id+'/company_skills'1001 },1002 */1003 getCompanyMembers: function(id) {1004 return localhost + 'companies/' + id + '/company_members'1005 },1006 getCompanyKeyContacts: function(id) {1007 return localhost + 'companies/' + id + '/company_key_contacts'1008 },1009 addCompanySkill: function() {1010 return localhost + 'company_skills'1011 },1012 getLastCompanySkillId: function() {1013 return localhost + 'company_skills'1014 },1015 deleteCompanySkill: function(id) {1016 return localhost + 'company_skills/' + id;1017 },1018 getLastCompanyContactId: function() {1019 return localhost + 'company_key_contacts'1020 },1021 addCompanyContact: function() {1022 return localhost + 'company_key_contacts'1023 },1024 updateCompany: function(id) {1025 return localhost + 'companies/' + id;1026 },1027 updateCompanyProfile: function(id) {1028 return localhost + 'companies/' + id;1029 },1030 getLastCompanyVideoId: function() {1031 return localhost + 'company_videos';1032 },1033 addCompanyVideo: function() {1034 return localhost + 'company_videos';1035 },1036 deleteCompanyVideo: function(id) {1037 return localhost + 'company_videos/' + id;1038 },1039 deleteCompanyContact: function(id) {1040 return localhost + 'company_key_contacts/' + id;1041 },1042 updateCompanyImage: function(id) {1043 return localhost + 'company_images/' + id;1044 },1045 deleteCompanyImage: function(id) {1046 return localhost + 'company_images/' + id;1047 },1048 updateCompanySkillsImage: function(id) {1049 return localhost + 'company_skill_images/' + id;1050 },1051 deleteCompanySkillsImage: function(id) {1052 return localhost + 'company_skill_images/' + id;1053 },1054 updateCompanyVideo: function(id) {1055 return localhost + 'company_videos/' + id;1056 },1057 updateCompanyContact: function(id) {1058 return localhost + 'company_key_contacts/' + id;1059 },1060 getService: function(id) {1061 return localhost + 'services' + (id ? '/' + id : '');1062 },1063 getFavorites: function() {1064 return localhost + 'favorite_products';1065 },1066 getFavoriteService: function(id) {1067 return localhost + 'accounts/' + id + '/favorite_products';1068 },1069 getFavorite: function() {1070 return localhost + 'favorite_products';1071 },1072 addFavorite: function() {1073 return localhost + 'favorite_products';1074 },1075 deleteFavorite: function(id) {1076 return localhost + 'favorite_products/' + id;1077 },1078 getUserList: function() {1079 return localhost + 'users';1080 },1081 getUserUrl: function() {1082 return localhost + 'user';1083 },1084 userAccount: function(id) {1085 return {1086 get: localhost + 'user/' + id1087 }1088 },1089 getUserName: function(id) {1090 return localhost + 'user/' + id + '/userName';1091 },1092 getOnboardingBasicInfoUrl: function() {1093 return localhost + 'user-basic-information'1094 },1095 getUserAcceptTermsAndConditionsUrl: function() {1096 return localhost + 'user-accept-terms-and-conditions'1097 },1098 getAccountNotificationCategoryItems: function() {1099 return localhost + 'account-notification-category-items';1100 },1101 getAccountNotifications: function() {1102 return localhost + 'account-notification-categories';1103 },1104 getUserAccountNotifications: function(account_id) {1105 return localhost + 'accounts/' + account_id + '/account-notification-settings';1106 },1107 updateUserAccountNotification: function(id) {1108 return localhost + 'account-notification-settings/' + id;1109 },1110 markNotificationRead: function(id, notification_id) {1111 return localhost + 'users/' + id + '/notifications/' + notification_id + '?action=markNotificationRead';1112 },1113 markAllNotificationsRead: function(id) {1114 return localhost + 'users/' + id + '/notifications?action=markAllRead';1115 },1116 requestVerification: function() {1117 return localhost + 'notifications?action=requestVerification';1118 },1119 getNotificationsUser: function() {1120 return localhost + 'notifications-user';1121 },1122 getNotificationsStatisticUser: function() {1123 return localhost + 'notifications-user-statistic';1124 },1125 getNotificationsPm: function() {1126 return localhost + 'notifications-pm';1127 },1128 addNotificationsPm: function() {1129 return localhost + 'notifications-pm';1130 },1131 getNotificationsStatisticPm: function() {1132 return localhost + 'notifications-pm-statistic';1133 },1134 //RESOURCES1135 getAllResourceLabs: function() {1136 return localhost + 'resource/lab';1137 },1138 getResourceLab: function(id) {1139 return localhost + 'resource/lab/' + id;1140 },1141 getAllResourceBays: function() {1142 return localhost + 'resource/bay/';1143 },1144 getResourceBay: function(id) {1145 return localhost + 'resource/bay/' + id;1146 },1147 getAllBayMachines: function(id) {1148 return localhost + 'resource/machine/' + id;1149 },1150 getResourceProject: function(id) {1151 return localhost + 'resource/project/' + id;1152 },1153 getAllResourceProjects: function() {1154 return localhost + 'resource/project';1155 },1156 getAllCourses: function() {1157 return localhost + 'resource/course';1158 },1159 getCourse: function(id) {1160 return localhost + 'resource/course/' + id;1161 },1162 getAllJobs: function() {1163 return localhost + 'resource/job';1164 },1165 getJob: function(id) {1166 return localhost + 'resource/job/' + id;1167 },1168 getAllAssessments: function() {1169 return localhost + 'resource/assessment';1170 },1171 getAssessment: function(id) {1172 return localhost + 'resource/assessment/' + id;1173 },1174 //END RESOURCES1175 searchMarketplace: function(text) {1176 if ($window.apiUrl) {1177 return localhost + 'searchServices/' + text;1178 } else {1179 return localhost + 'searchServices';1180 }1181 },1182 searchMembers: function(text) {1183 console.log('data.factory.searchMembers: text=' + text);1184 return localhost + 'searchMembers/' + text;1185 },1186 markReadNotifications: function() {1187 return localhost + 'mark-read-notifications';1188 },1189 clearNotification: function(id) {1190 return localhost + 'clear-notification/' + id;1191 },1192 compare: function(id, type) {1193 // type - services, members1194 var name = 'compare_' + type;1195 return {1196 userCompares: localhost + 'profiles/' + id + '/' + name,1197 get: localhost + name + '/' + id,1198 delete: localhost + name + '/' + id,1199 add: localhost + name1200 }1201 },1202 getDateFormat: function() {1203 return 'YYYY-MM-DD';1204 },1205 getTimeFormat: function() {1206 return 'hh:mm:ss A';1207 },1208 getDateAndTimeFormat: function() {1209 return this.getDateFormat() + ' ' + this.getTimeFormat();1210 },1211 // TODO -- make this a REST endpoint1212 getDocAccessLevels: function() {1213 return {1214 'All Members': 'ALL_MEMBERS',1215 'Project Participants': 'PROJECT_PARTICIPANTS',1216 'Project Participants and Upper Tier Members': 'PROJECT_PARTICIPANTS_AND_UPPER_TIER_MEMBERS',1217 'Project Participants VIPS': 'PROJECT_PARTICIPANT_VIPS',1218 'Choose Organizations': 'ORG'1219 }1220 },1221 getMyVPC: function() {1222 return localhost + 'organizations/myVPC'1223 }1224 };...

Full Screen

Full Screen

StaticServer.js

Source:StaticServer.js Github

copy

Full Screen

1/*2 * Copyright (c) 2012 Adobe Systems Incorporated. All rights reserved.3 * 4 * Permission is hereby granted, free of charge, to any person obtaining a5 * copy of this software and associated documentation files (the "Software"), 6 * to deal in the Software without restriction, including without limitation 7 * the rights to use, copy, modify, merge, publish, distribute, sublicense, 8 * and/or sell copies of the Software, and to permit persons to whom the 9 * Software is furnished to do so, subject to the following conditions:10 * 11 * The above copyright notice and this permission notice shall be included in12 * all copies or substantial portions of the Software.13 * 14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR15 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE17 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 19 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 20 * DEALINGS IN THE SOFTWARE.21 * 22 */23/*jslint vars: true, plusplus: true, devel: true, nomen: true, indent: 4,24maxerr: 50, browser: true */25/*global $, define, brackets */26define(function (require, exports, module) {27 "use strict";28 var BaseServer = brackets.getModule("LiveDevelopment/Servers/BaseServer").BaseServer,29 FileUtils = brackets.getModule("file/FileUtils"),30 PreferencesManager = brackets.getModule("preferences/PreferencesManager");31 32 /**33 * @private34 * 35 * Prefences manager for this extension36 */37 var _prefs = PreferencesManager.getExtensionPrefs("staticserver");38 /**39 * @constructor40 * @extends {BaseServer}41 * Live preview server that uses a built-in HTTP server to serve static42 * and instrumented files.43 *44 * @param {!{baseUrl: string, root: string, pathResolver: function(string), nodeDomain: NodeDomain}} config45 * Configuration parameters for this server:46 * baseUrl - Optional base URL (populated by the current project)47 * pathResolver - Function to covert absolute native paths to project relative paths48 * root - Native path to the project root (and base URL)49 * nodeDomain - An initialized NodeDomain50 */51 function StaticServer(config) {52 this._nodeDomain = config.nodeDomain;53 this._onRequestFilter = this._onRequestFilter.bind(this);54 BaseServer.call(this, config);55 }56 57 StaticServer.prototype = Object.create(BaseServer.prototype);58 StaticServer.prototype.constructor = StaticServer;59 /**60 * Determines whether we can serve local file.61 * @param {string} localPath A local path to file being served.62 * @return {boolean} true for yes, otherwise false.63 */64 StaticServer.prototype.canServe = function (localPath) {65 if (!this._nodeDomain.ready()) {66 return false;67 }68 69 // If we can't transform the local path to a project relative path,70 // the path cannot be served71 if (localPath === this._pathResolver(localPath)) {72 return false;73 }74 // Url ending in "/" implies default file, which is usually index.html.75 // Return true to indicate that we can serve it.76 if (localPath.match(/\/$/)) {77 return true;78 }79 // FUTURE: do a MIME Type lookup on file extension80 return FileUtils.isStaticHtmlFileExt(localPath);81 };82 /**83 * @private84 * Update the list of paths that fire "request" events85 * @return {jQuery.Promise} Resolved by the StaticServer domain when the message is acknowledged.86 */87 StaticServer.prototype._updateRequestFilterPaths = function () {88 var paths = Object.keys(this._liveDocuments);89 return this._nodeDomain.exec("setRequestFilterPaths", this._root, paths);90 };91 /**92 * Gets the server details from the StaticServerDomain in node.93 * The domain itself handles starting a server if necessary (when94 * the staticServer.getServer command is called).95 *96 * @return {jQuery.Promise} A promise that resolves/rejects when 97 * the server is ready/failed.98 */99 StaticServer.prototype.readyToServe = function () {100 var self = this;101 var deferred = new $.Deferred();102 function sanitizePort(port) {103 port = parseInt(port, 10);104 port = (port && !isNaN(port) && port > 0 && port < 65536) ? port : 0;105 return port;106 }107 function onSuccess(address) {108 self._baseUrl = "http://" + address.address + ":" + address.port + "/";109 deferred.resolve();110 }111 function onFailure() {112 self._baseUrl = "";113 deferred.resolve();114 }115 var port = sanitizePort(_prefs.get("port"));116 this._nodeDomain.exec("getServer", self._root, port)117 .done(function (address) {118 // If the port returned wasn't what was requested, then the preference has119 // changed. Close the current server, and open a new one with the new port.120 if (address.port !== port && port > 0) {121 return self._nodeDomain.exec("closeServer", self._root)122 .done(function () {123 return self._nodeDomain.exec("getServer", self._root, port)124 .done(onSuccess)125 .fail(onFailure);126 })127 .fail(onFailure);128 }129 onSuccess(address);130 })131 .fail(onFailure);132 return deferred.promise();133 };134 /**135 * See BaseServer#add. StaticServer ignores documents that do not have136 * a setInstrumentationEnabled method. Updates request filters.137 */138 StaticServer.prototype.add = function (liveDocument) {139 if (liveDocument.setInstrumentationEnabled) {140 // enable instrumentation141 liveDocument.setInstrumentationEnabled(true);142 }143 144 BaseServer.prototype.add.call(this, liveDocument);145 146 // update the paths to watch147 this._updateRequestFilterPaths();148 };149 /**150 * See BaseServer#remove. Updates request filters.151 */152 StaticServer.prototype.remove = function (liveDocument) {153 BaseServer.prototype.remove.call(this, liveDocument);154 155 this._updateRequestFilterPaths();156 };157 /**158 * See BaseServer#clear. Updates request filters.159 */160 StaticServer.prototype.clear = function () {161 BaseServer.prototype.clear.call(this);162 163 this._updateRequestFilterPaths();164 };165 166 /**167 * @private168 * Send HTTP response data back to the StaticServerSomain169 */170 StaticServer.prototype._send = function (location, response) {171 this._nodeDomain.exec("writeFilteredResponse", location.root, location.pathname, response);172 };173 174 /**175 * @private176 * Event handler for StaticServerDomain requestFilter event177 * @param {jQuery.Event} event178 * @param {{hostname: string, pathname: string, port: number, root: string, id: number}} request179 */180 StaticServer.prototype._onRequestFilter = function (event, request) {181 var key = request.location.pathname,182 liveDocument = this._liveDocuments[key],183 response;184 185 // send instrumented response or null to fallback to static file186 if (liveDocument && liveDocument.getResponseData) {187 response = liveDocument.getResponseData();188 } else {189 response = {}; // let server fall back on loading file off disk190 }191 response.id = request.id;192 193 this._send(request.location, response);194 };195 196 /**197 * See BaseServer#start. Starts listenting to StaticServerDomain events.198 */199 StaticServer.prototype.start = function () {200 this._nodeDomain.on("requestFilter", this._onRequestFilter);201 };202 /**203 * See BaseServer#stop. Remove event handlers from StaticServerDomain.204 */205 StaticServer.prototype.stop = function () {206 this._nodeDomain.off("requestFilter", this._onRequestFilter);207 };208 module.exports = StaticServer;...

Full Screen

Full Screen

BaseServer.js

Source:BaseServer.js Github

copy

Full Screen

1/*2 * Copyright (c) 2013 Adobe Systems Incorporated. All rights reserved.3 * 4 * Permission is hereby granted, free of charge, to any person obtaining a5 * copy of this software and associated documentation files (the "Software"), 6 * to deal in the Software without restriction, including without limitation 7 * the rights to use, copy, modify, merge, publish, distribute, sublicense, 8 * and/or sell copies of the Software, and to permit persons to whom the 9 * Software is furnished to do so, subject to the following conditions:10 * 11 * The above copyright notice and this permission notice shall be included in12 * all copies or substantial portions of the Software.13 * 14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR15 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE17 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 19 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 20 * DEALINGS IN THE SOFTWARE.21 * 22 */23/*jslint vars: true, plusplus: true, devel: true, nomen: true, indent: 4, forin: true, maxerr: 50, regexp: true */24/*global define, $ */25define(function (require, exports, module) {26 "use strict";27 /**28 * Base class for live preview servers29 *30 * Configuration parameters for this server:31 * - baseUrl - Optional base URL (populated by the current project)32 * - pathResolver - Function to covert absolute native paths to project relative paths33 * - root - Native path to the project root (and base URL)34 *35 * @constructor36 * @param {!{baseUrl: string, root: string, pathResolver: function(string): string}} config37 */38 function BaseServer(config) {39 this._baseUrl = config.baseUrl;40 this._root = config.root; // ProjectManager.getProjectRoot().fullPath41 this._pathResolver = config.pathResolver; // ProjectManager.makeProjectRelativeIfPossible(doc.file.fullPath)42 this._liveDocuments = {};43 }44 /**45 * Returns a base url for current project. 46 *47 * @return {string}48 * Base url for current project.49 */50 BaseServer.prototype.getBaseUrl = function () {51 return this._baseUrl;52 };53 /**54 * @private55 * Augments the given Brackets document with information that's useful for live development56 * @param {Object} liveDocument57 */58 BaseServer.prototype._setDocInfo = function (liveDocument) {59 var parentUrl,60 matches,61 doc = liveDocument.doc;62 // FUTURE: some of these things should just be moved into core Document; others should63 // be in a LiveDevelopment-specific object attached to the doc.64 matches = /^(.*\/)(.+\.([^.]+))$/.exec(doc.file.fullPath);65 if (!matches) {66 return;67 }68 doc.extension = matches[3];69 parentUrl = this.pathToUrl(matches[1]);70 doc.url = parentUrl + encodeURI(matches[2]);71 // the root represents the document that should be displayed in the browser72 // for live development (the file for HTML files)73 // TODO: Issue #2033 Improve how default page is determined74 doc.root = { url: doc.url };75 // TODO: Better workflow of liveDocument.doc.url assignment76 // Force sync the browser after a URL is assigned77 if (doc.isDirty && liveDocument._updateBrowser) {78 liveDocument._updateBrowser();79 }80 };81 /**82 * Returns a URL for a given path83 * @param {string} path Absolute path to covert to a URL84 * @return {?string} Converts a path within the project root to a URL.85 * Returns null if the path is not a descendant of the project root.86 */87 BaseServer.prototype.pathToUrl = function (path) {88 var baseUrl = this.getBaseUrl(),89 relativePath = this._pathResolver(path);90 // See if base url has been specified and path is within project91 if (relativePath !== path) {92 // Map to server url. Base url is already encoded, so don't encode again.93 var encodedDocPath = encodeURI(path);94 var encodedProjectPath = encodeURI(this._root);95 return encodedDocPath.replace(encodedProjectPath, baseUrl);96 }97 return null;98 };99 /**100 * Convert a URL to a local full file path101 * @param {string} url102 * @return {?string} The absolute path for given URL or null if the path is103 * not a descendant of the project.104 */105 BaseServer.prototype.urlToPath = function (url) {106 var path,107 baseUrl = "";108 baseUrl = this.getBaseUrl();109 if (baseUrl !== "" && url.indexOf(baseUrl) === 0) {110 // Use base url to translate to local file path.111 // Need to use encoded project path because it's decoded below.112 path = url.replace(baseUrl, encodeURI(this._root));113 114 return decodeURI(path);115 }116 return null;117 };118 /**119 * Called by LiveDevelopment before to prepare the server before navigating120 * to the project's base URL. The provider returns a jQuery promise.121 * The Live Development launch process waits until the promise122 * is resolved or rejected. If the promise is rejected, an error window123 * is shown and Live Development does not start..124 *125 * @return {jQuery.Promise} Promise that may be asynchronously resolved126 * when the server is ready to handle HTTP requests.127 */128 BaseServer.prototype.readyToServe = function () {129 // Base implementation always resolves130 return $.Deferred().resolve().promise();131 };132 133 /**134 * Determines if this server can serve local file. LiveDevServerManager135 * calls this method when determining if a server can serve a file.136 * @param {string} localPath A local path to file being served.137 * @return {boolean} true When the file can be served, otherwise false.138 */139 BaseServer.prototype.canServe = function (localPath) {140 return true;141 };142 BaseServer.prototype._documentKey = function (absolutePath) {143 return "/" + encodeURI(this._pathResolver(absolutePath));144 };145 /**146 * Adds a live document to server147 * @param {Object} liveDocument148 */149 BaseServer.prototype.add = function (liveDocument) {150 if (!liveDocument) {151 return;152 }153 154 // use the project relative path as a key to lookup requests155 var key = this._documentKey(liveDocument.doc.file.fullPath);156 157 this._setDocInfo(liveDocument);158 this._liveDocuments[key] = liveDocument;159 };160 /**161 * Removes a live document from the server162 * @param {Object} liveDocument163 */164 BaseServer.prototype.remove = function (liveDocument) {165 if (!liveDocument) {166 return;167 }168 169 var key = this._liveDocuments[this._documentKey(liveDocument.doc.file.fullPath)];170 171 if (key) {172 delete this._liveDocuments[key];173 }174 };175 /**176 * Lookup a live document using it's full path key177 * @param {string} path Absolute path to covert to a URL178 * @param {?Object} liveDocument Returns a live document or undefined if a179 * document does not exist for the path.180 */181 BaseServer.prototype.get = function (path) {182 return this._liveDocuments[this._documentKey(path)];183 };184 /**185 * Clears all live documents currently attached to the server186 */187 BaseServer.prototype.clear = function () {188 this._liveDocuments = {};189 };190 /**191 * Start the server192 */193 BaseServer.prototype.start = function () {194 // do nothing195 };196 /**197 * Stop the server198 */199 BaseServer.prototype.stop = function () {200 // do nothing201 };202 exports.BaseServer = BaseServer;...

Full Screen

Full Screen

proxySetting.js

Source:proxySetting.js Github

copy

Full Screen

1'use strict'23const args = process.argv4 .slice(2)5 .map(arg => arg.split('='))6 .reduce((args, [value, key]) => {7 args[value] = key;8 return args;9 }, {});1011var baseServer = 'http://mifs.kr.mil';12var ipsServer = baseServer;13var scsServer = baseServer;14var iasServer = baseServer;15var issServer = baseServer;16var gdsServer = baseServer;17var cmmServer = baseServer;1819if (args.ipsServer != undefined) {20 ipsServer = args.ipsServer;21}22if (args.scsServer != undefined) {23 scsServer = args.scsServer;24}25if (args.iasServer != undefined) {26 iasServer = args.iasServer;27}28if (args.issServer != undefined) {29 issServer = args.issServer;30}31if (args.gdsServer != undefined) {32 gdsServer = args.gdsServer;33}34if (args.cmmServer != undefined) {35 cmmServer = args.cmmServer;36}373839const getIpsServer = () => ({40 target: ipsServer,41 changeOrigin: true,42 pathRewrite: { '^/ips': '' }43});4445const getScsServer = () => ({46 target: scsServer,47 changeOrigin: true,48 pathRewrite: { '^/scs': '' }49});5051const getIasServer = () => ({52 target: iasServer,53 changeOrigin: true,54 pathRewrite: { '^/ias': '' }55});5657const getIssServer = () => ({58 target: issServer,59 changeOrigin: true,60 pathRewrite: { '^/iss': '' }61});6263const getGdsServer = () => ({64 target: gdsServer,65 changeOrigin: true,66 pathRewrite: { '^/gds': '' }67});6869const getCmmServer = () => ({70 target: cmmServer,71 changeOrigin: true,72 pathRewrite: { '^/cmm': '' }73});7475module.exports = {76 '/ips': getIpsServer(),77 '/scs': getScsServer(),78 '/ias': getIasServer(),79 '/iss': getIssServer(),80 '/gds': getGdsServer(),81 '/cmm': getCmmServer(),82}8384 ...

Full Screen

Full Screen

StudentServer.js

Source:StudentServer.js Github

copy

Full Screen

1import {baseServer} from '@/tools/servers'2export class StudentServer {3 static addStudent(requestDTO) {4 let httpMethod = 'POST'5 let body = baseServer.getArgs(this.addStudent, arguments, httpMethod)6 return baseServer.connection(httpMethod, '/student/addStudent', body)7 }8 static delStudent(uid) {9 let httpMethod = 'GET'10 let body = baseServer.getArgs(this.delStudent, arguments, httpMethod)11 return baseServer.connection(httpMethod, '/student/delStudentById', body)12 }13 static batchDeletion(requestDTO) {14 let httpMethod = 'POST'15 let body = baseServer.getArgs(this.batchDeletion, arguments, httpMethod)16 return baseServer.connection(httpMethod, '/student/batchDeletion', body)17 }18 static updateStudent(requestDTO) {19 let httpMethod = 'POST'20 let body = baseServer.getArgs(this.updateStudent, arguments, httpMethod)21 return baseServer.connection(httpMethod, '/student/updateStudent', body)22 }23 static getStudentListData(requestDTO) {24 let httpMethod = 'POST'25 let body = baseServer.getArgs(this.getStudentListData, arguments, httpMethod)26 return baseServer.connection(httpMethod, '/student/getStudentListData', body)27 }28 static getStudentById(uid) {29 let httpMethod = 'GET'30 let body = baseServer.getArgs(this.getStudentById, arguments, httpMethod)31 return baseServer.connection(httpMethod, '/student/getStudentById', body)32 }...

Full Screen

Full Screen

PermissionServer.js

Source:PermissionServer.js Github

copy

Full Screen

1import {baseServer} from '@/tools/servers'2export class PermissionServer {3 static addPermission(requestDTO) {4 let httpMethod = 'POST'5 let body = baseServer.getArgs(this.addPermission, arguments, httpMethod)6 return baseServer.connection(httpMethod, '/permission/addPermission', body)7 }8 static getPermissionListData(requestDTO) {9 let httpMethod = 'POST'10 let body = baseServer.getArgs(this.getPermissionListData, arguments, httpMethod)11 return baseServer.connection(httpMethod, '/permission/getPermissionListData', body)12 }13 static getPermissionWithLineById(uid) {14 let httpMethod = 'GET'15 let body = baseServer.getArgs(this.getPermissionWithLineById, arguments, httpMethod)16 return baseServer.connection(httpMethod, '/permission/getPermissionWithLineById', body)17 }18 static getPermissionURLs() {19 let httpMethod = 'GET'20 let body = baseServer.getArgs(this.getPermissionURLs, arguments, httpMethod)21 return baseServer.connection(httpMethod, '/permission/getPermissionURLs', body)22 }...

Full Screen

Full Screen

AccountServer.js

Source:AccountServer.js Github

copy

Full Screen

1import {baseServer} from '@/tools/servers'2export class AccountServer {3 static login(requestDTO) {4 let httpMethod = 'POST'5 let body = baseServer.getArgs(this.login, arguments, httpMethod)6 return baseServer.connection(httpMethod, '/account/userLogin', body)7 }8 static logout() {9 let httpMethod = 'GET'10 let body = baseServer.getArgs(this.login, arguments, httpMethod)11 return baseServer.connection(httpMethod, '/account/userLogout', body)12 }13 static studentRegister(requestDTO) {14 let httpMethod = 'POST'15 let body = baseServer.getArgs(this.login, arguments, httpMethod)16 return baseServer.connection(httpMethod, '/account/studentRegister', body)17 }18 static teacherRegister(requestDTO) {19 let httpMethod = 'POST'20 let body = baseServer.getArgs(this.login, arguments, httpMethod)21 return baseServer.connection(httpMethod, '/account/teacherRegister', body)22 }...

Full Screen

Full Screen

baseserver_8py.js

Source:baseserver_8py.js Github

copy

Full Screen

1var baseserver_8py =2[3 [ "BaseServer", "classgevent_1_1baseserver_1_1_base_server.html", "classgevent_1_1baseserver_1_1_base_server" ],4 [ "_extract_family", "baseserver_8py.html#a27774b95f455108a66266a75e0f8d8e9", null ],5 [ "_handle_and_close_when_done", "baseserver_8py.html#a08a7d906be95efa57ca9b153131a8c33", null ],6 [ "_parse_address", "baseserver_8py.html#a6a23d29fcc0ce1ec72123863f0a0030e", null ],7 [ "parse_address", "baseserver_8py.html#a0efe82b9b2362f2ad7bd41f0b222b1f1", null ],8 [ "__all__", "baseserver_8py.html#ad528a75fa489d49047c3f6c0c9a31481", null ]...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1var mb = require('mountebank');2mb.create({3}, function (error) {4 if (error) {5 console.log(error);6 }7});8mb.post('/imposters', {9 stubs: [{10 predicates: [{11 equals: {12 }13 }],14 responses: [{15 is: {16 }17 }]18 }]19}, function (error, response) {20 if (error) {21 console.log(error);22 }23});24mb.get('/imposters', function (error, response) {25 if (error) {26 console.log(error);27 }28 console.log(response.body);29});30mb.del('/imposters/3000', function (error, response) {31 if (error) {32 console.log(error);33 }34});35mb.del('/imposters', function (error, response) {36 if (error) {37 console.log(error);38 }39});40mb.get('/imposters', function (error, response) {41 if (error) {42 console.log(error);43 }44 console.log(response.body);45});46mb.del('/imposters', function (error, response) {47 if (error) {48 console.log(error);49 }50});51mb.get('/imposters', function (error, response) {52 if (error) {53 console.log(error);54 }55 console.log(response.body);56});57mb.del('/imposters', function (error, response) {58 if (error) {59 console.log(error);60 }61});62mb.get('/imposters', function (error, response) {63 if (error) {64 console.log(error);

Full Screen

Using AI Code Generation

copy

Full Screen

1var mb = require('mountebank');2mb.create({3}).then(function (server) {4 console.log('Server started');5 server.close();6}).catch(function (error) {7 console.log('Error starting server', error);8});9var mb = require('mountebank');10mb.create({11}).then(function (server) {12 console.log('Server started');13 server.close();14}).catch(function (error) {15 console.log('Error starting server', error);16});17{18 {19 {20 "is": {21 }22 }23 }24}25{

Full Screen

Using AI Code Generation

copy

Full Screen

1var baseServer = require('mountebank').baseServer;2baseServer.create({3});4var imposterServer = require('mountebank').imposterServer;5imposterServer.create({6 {7 {8 equals: {9 }10 }11 {12 is: {13 headers: {14 },15 }16 }17 }18});19var imposterServer = require('mountebank').imposterServer;20imposterServer.create({21 {22 {23 equals: {24 }25 }26 {27 is: {28 headers: {29 },30 }31 }32 }33});34var imposterServer = require('mountebank').imposterServer;35imposterServer.create({36 {37 {38 equals: {39 }40 }41 {42 is: {43 headers: {44 },45 }46 }47 }48});49var imposterServer = require('mountebank').imposterServer;50imposterServer.create({

Full Screen

Using AI Code Generation

copy

Full Screen

1var baseServer = require('mountebank').baseServer;2var server = baseServer.create('localhost', 2525);3server.addStub({4 { equals: { method: 'POST', path: '/test' } }5 { is: { statusCode: 200, body: 'OK' } }6});7server.start();8var mb = require('mountebank');9mb.create({10 {11 { equals: { method: 'POST', path: '/test' } }12 { is: { statusCode: 200, body: 'OK' } }13 }14});15var mb = require('mountebank');16mb.create({17 {18 { equals: { method: 'POST', path: '/test' } }19 { is: { statusCode: 200, body: 'OK' } }20 }21});22var mb = require('mountebank');23mb.create({24 {25 { equals: { method: 'POST', path: '/test' } }26 { is: { statusCode: 200, body: 'OK' } }27 }28});29var mb = require('mountebank');30mb.create({31 {32 { equals: { method: 'POST', path: '/test' } }33 { is: { statusCode: 200, body: 'OK' } }34 }35});36var mb = require('mountebank');37mb.create({

Full Screen

Using AI Code Generation

copy

Full Screen

1var mb = require('mountebank');2var mb = require('mountebank');3var port = 2525;4var options = {5};6mb.start(options, function (error) {7 console.log("mountebank server started at port " + port);8});9var mb = require('mountebank');10var port = 2525;11var options = {12};13mb.start(options, function (error) {14 console.log("mountebank server started at port " + port);15});16var mb = require('mountebank');17var port = 2525;18var options = {19};20mb.start(options, function (error) {21 console.log("mountebank server started at port " + port);22});23var mb = require('mountebank');24var port = 2525;25var options = {26};27mb.start(options, function (error) {28 console.log("mountebank server started at port " + port);29});30var mb = require('mountebank');31var port = 2525;32var options = {33};34mb.start(options, function (error) {35 console.log("mountebank server started at port " + port);36});37var mb = require('mountebank');38var port = 2525;

Full Screen

Using AI Code Generation

copy

Full Screen

1var baseServer = require('mountebank').baseServer;2baseServer.create({ port: 2525, allowInjection: true, debug: true }, function () {3 console.log('Mountebank started');4});5var baseServer = require('mountebank').baseServer;6baseServer.create({ port: 2525, allowInjection: true, debug: true }, function () {7 console.log('Mountebank started');8});9var baseServer = require('mountebank').baseServer;10baseServer.create({ port: 2525, allowInjection: true, debug: true }, function () {11 console.log('Mountebank started');12});13var baseServer = require('mountebank').baseServer;14baseServer.create({ port: 2525, allowInjection: true, debug: true }, function () {15 console.log('Mountebank started');16});17var baseServer = require('mountebank').baseServer;18baseServer.create({ port: 2525, allowInjection: true, debug: true }, function () {19 console.log('Mountebank started');20});21var baseServer = require('mountebank').baseServer;22baseServer.create({ port: 2525, allowInjection: true, debug: true }, function () {23 console.log('Mountebank started');24});25var baseServer = require('mountebank').baseServer;26baseServer.create({ port: 2525, allowInjection: true, debug: true }, function () {27 console.log('Mountebank started');28});29var baseServer = require('mountebank').baseServer;30baseServer.create({ port: 2525, allowInjection: true, debug: true }, function () {31 console.log('Mountebank started');32});

Full Screen

Using AI Code Generation

copy

Full Screen

1var mb = require('mountebank');2mb.create({port:2525, allowInjection:true}, function (error) {3 if (error) {4 console.log('Error while creating mountebank server: ', error);5 } else {6 console.log('Mountebank server created successfully');7 }8});9var mb = require('mountebank');10mb.start({port:2525, allowInjection:true}, function (error) {11 if (error) {12 console.log('Error while creating mountebank server: ', error);13 } else {14 console.log('Mountebank server created successfully');15 }16});17var mb = require('mountebank');18mb.create({port:2525, allowInjection:true}, function (error) {19 if (error) {20 console.log('Error while creating mountebank server: ', error);21 } else {22 console.log('Mountebank server created successfully');23 var imposter = {24 stubs: [{25 predicates: [{26 equals: {27 }28 }],29 responses: [{30 is: {31 headers: {32 },33 body: JSON.stringify({

Full Screen

Using AI Code Generation

copy

Full Screen

1const baseServer = require('mountebank/src/models/baseServer').baseServer;2const server = baseServer.create('http', 2525);3server.start();4const mb = require('mountebank');5mb.start({ port: 2525, ipWhitelist: ['*'] }, () => {6 console.log('mountebank started');7});8const mb = require('mountebank');9mb.start({ port: 2525, ipWhitelist: ['*'] }, () => {10 console.log('mountebank started');11});12const mb = require('mountebank');13mb.start({ port: 2525, ipWhitelist: ['*'] }, () => {14 console.log('mountebank started');15});16const mb = require('mountebank');17mb.start({ port: 2525, ipWhitelist: ['*'] }, () => {18 console.log('mountebank started');19});20const mb = require('mountebank');21mb.start({ port: 2525, ipWhitelist: ['*'] }, () => {22 console.log('mountebank started');23});24const mb = require('mountebank');25mb.start({ port: 2525, ipWhitelist: ['*'] }, () => {26 console.log('mountebank started');27});28const mb = require('mountebank');29mb.start({ port: 2525, ipWhitelist: ['*'] }, () => {30 console.log('mountebank started');31});32const mb = require('mountebank');33mb.start({ port: 2525, ipWhitelist: ['*'] }, () => {34 console.log('mountebank started');35});36const mb = require('mountebank');37mb.start({ port: 2525, ipWhitelist: ['*'] }, () => {38 console.log('mountebank started');39});

Full Screen

Using AI Code Generation

copy

Full Screen

1const mb = require('mountebank');2const baseServer = mb.create();3const server = require('http').createServer();4const mb = require('mountebank').create(server, { allowInjection: true });5const server = require('https').createServer({6 key: fs.readFileSync('path/to/key.pem'),7 cert: fs.readFileSync('path/to/cert.pem')8});9const mb = require('mountebank').create(server, { allowInjection: true });10const server = require('https').createServer({11 key: fs.readFileSync('path/to/key.pem'),12 cert: fs.readFileSync('path/to/cert.pem'),13 ca: fs.readFileSync('path/to/ca.pem'),14});15const mb = require('mountebank').create(server, { allowInjection: true });16const server = require('https').createServer({17 key: fs.readFileSync('path/to/key.pem'),18 cert: fs.readFileSync('path/to/cert.pem'),19 ca: fs.readFileSync('path/to/ca.pem'),20 SNICallback: (servername, cb) => {21 if (servername === 'valid.example.com') {22 cb(null, tls.createSecureContext({23 key: fs.readFileSync('path/to/key.pem'),24 cert: fs.readFileSync('path/to/cert.pem'),25 ca: fs.readFileSync('path/to/ca.pem')26 }));27 } else {28 cb(new Error('No credentials for this server'));29 }30 }31});32const mb = require('mountebank').create(server, { allowInjection: true });33const server = require('https').createServer({34 key: fs.readFileSync('path/to/key.pem'),35 cert: fs.readFileSync('path/to/cert.pem'),36 ca: fs.readFileSync('path/to/ca.pem'),37 SNICallback: (servername, cb) => {38 if (servername === 'valid.example.com') {39 cb(null,

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run mountebank automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful