Best JavaScript code snippet using cypress
AffordableClient.js
Source:AffordableClient.js
1"use strict";2var __importDefault = (this && this.__importDefault) || function (mod) {3 return (mod && mod.__esModule) ? mod : { "default": mod };4};5Object.defineProperty(exports, "__esModule", { value: true });6exports.AffordableHttpError = exports.AffordableClient = void 0;7const axios_1 = __importDefault(require("axios"));8const jsonwebtoken_1 = __importDefault(require("jsonwebtoken"));9const universal_cookie_1 = __importDefault(require("universal-cookie"));10const util_1 = require("./util");11var AUTH_EP = util_1.AffordableClientConstants.AUTH_EP;12var PROFILE_EP = util_1.AffordableClientConstants.PROFILE_EP;13var SESSION_TOKEN_COOKIE_KEY = util_1.AffordableClientConstants.SESSION_TOKEN_COOKIE_KEY;14var GRANT_EP = util_1.AffordableClientConstants.GRANT_EP;15var ORGANIZATION_EP = util_1.AffordableClientConstants.ORGANIZATION_EP;16var TRANSACTION = util_1.AffordableClientConstants.TRANSACTION;17var APPLICATION = util_1.AffordableClientConstants.APPLICATION;18var STRIPE = util_1.AffordableClientConstants.STRIPE;19var FILE = util_1.AffordableClientConstants.FILE;20var ACTIVITY_EP = util_1.AffordableClientConstants.ACTIVITY_EP;21const dotenv_1 = require("dotenv");22dotenv_1.config();23axios_1.default.defaults.withCredentials = true;24class BalanceResponse {25}26;27class AffordableClient {28 constructor() {29 this.cookies = new universal_cookie_1.default;30 }31 //For tlcoaesting purposes32 getUserId() {33 return this.myUserId;34 }35 getBaseURL() {36 return this.baseURL ? this.baseURL : process.env.REACT_APP_AF_BACKEND_URL || window.REACT_APP_AF_BACKEND_URL;37 }38 setBaseURL(url) {39 this.baseURL = url;40 }41 getSessionToken() {42 return this.sessionToken ? this.sessionToken : this.cookies.get(SESSION_TOKEN_COOKIE_KEY);43 }44 setSessionToken(token) {45 this.sessionToken = token;46 this.cookies.set(SESSION_TOKEN_COOKIE_KEY, token, { maxAge: 60 * 60 * 8 } // 8 hours47 );48 // Get the UserInfo out of the token49 const decoded = jsonwebtoken_1.default.decode(token);50 this.myUserId = JSON.parse(decoded.sub).id;51 }52 getHeaders() {53 return this.getSessionToken() ? {54 "Content-Type": "application/json",55 "Authorization": "Bearer " + this.getSessionToken()56 } : {57 "Content-Type": "application/json"58 };59 }60 doGet(endpoint, params) {61 var _a;62 return axios_1.default.get(endpoint, {63 params: params,64 headers: (_a = params === null || params === void 0 ? void 0 : params.headers) !== null && _a !== void 0 ? _a : this.getHeaders()65 }).then((response) => {66 return response.data;67 }).catch((error) => {68 return null;69 //throw new AffordableHttpError(error)70 });71 }72 doDelete(endpoint, params) {73 var _a;74 return axios_1.default.delete(endpoint, {75 params: params,76 headers: (_a = params === null || params === void 0 ? void 0 : params.headers) !== null && _a !== void 0 ? _a : this.getHeaders()77 }).then((response) => {78 return response.data;79 }).catch((error) => {80 throw new AffordableHttpError(error);81 });82 }83 doPost(endpoint, body, axiosParams) {84 var _a;85 return axios_1.default.post(endpoint, body, Object.assign(Object.assign({}, axiosParams), { headers: (_a = axiosParams === null || axiosParams === void 0 ? void 0 : axiosParams.headers) !== null && _a !== void 0 ? _a : this.getHeaders() })).then((response) => {86 return response.data;87 }).catch((error) => {88 throw new AffordableHttpError(error);89 });90 }91 doPut(endpoint, body, axiosParams) {92 return axios_1.default.put(endpoint, body, Object.assign(Object.assign({}, axiosParams), { headers: this.getHeaders() })).then((response) => {93 return response.data;94 }).catch((error) => {95 throw new AffordableHttpError(error);96 });97 }98 getMyUserInfo() {99 return this.getUserInfo(this.myUserId);100 }101 /**102 * Create a user account in Affordable103 * @param user104 */105 registerUser(user) {106 return this.doPost(this.getBaseURL() + AUTH_EP, user, {107 headers: { "Content-Type": "application/json" }108 })109 .then((response) => {110 this.setSessionToken(response.token);111 return response;112 });113 }114 getEmails(user) {115 return this.doPost(this.getBaseURL() + PROFILE_EP + "/get-emails", { username: user }).then((response) => {116 return response;117 });118 }119 twoFactor(token, imageid, secret) {120 return this.doPost(this.getBaseURL() + AUTH_EP + "/two-factor", {121 token: token,122 imageid: imageid,123 secret: secret124 }).then((response) => {125 return response;126 });127 }128 addTwoFactor(deviceName, username, email, randomString, timeStamp, secret) {129 return this.doPost(this.getBaseURL() + PROFILE_EP + "/add-two-factor", {130 DeviceName: deviceName,131 Username: username,132 Email: email,133 RandomString: randomString,134 TimeStamp: timeStamp,135 Secret: secret136 }).then((response) => {137 return response;138 });139 }140 removeTwoFactor(username, email) {141 return this.doPost(this.getBaseURL() + PROFILE_EP + "/remove-two-factor", {142 Username: username,143 Email: email144 }).then((response) => {145 return response;146 });147 }148 checkTwoFactorByAgainstUsername(username, token, googleAuthOpt) {149 console.log("GOOG: ", googleAuthOpt);150 return this.doPost(this.getBaseURL() + AUTH_EP + "/two-factor/username", {151 username: username,152 token: token,153 GoogleAuth: googleAuthOpt154 }).then((response) => {155 return response;156 });157 }158 getBalance(username, usertype) {159 return this.doPost(this.getBaseURL() + TRANSACTION + '/balance', {160 username: username,161 usertype: usertype162 }).then((response) => {163 return response;164 });165 }166 exchangeTokens(token, account, username) {167 return this.doPost(this.getBaseURL() + STRIPE + '/exchangeTokens', {168 public_token: token,169 account_id: account,170 username: username171 }).then((response) => {172 return response;173 });174 }175 stripeSaveCard(username, tokenId, cardType, cardName) {176 return this.doPost(this.getBaseURL() + STRIPE + '/saveCard', {177 username: username,178 tokenId: tokenId,179 cardType: cardType,180 cardName: cardName181 }).then((response) => {182 return response;183 });184 }185 stripeGetSavedPaymentMethod(username, paymentType) {186 return this.doPost(this.getBaseURL() + STRIPE + '/getSavedPaymentMethod', {187 username: username,188 paymentType: paymentType189 }).then((response) => {190 return response;191 });192 }193 getApplications(status) {194 return this.doPost(this.getBaseURL() + APPLICATION + '/getApps', { status: status195 }).then((response) => {196 return response;197 });198 }199 fileUpload(data) {200 return this.doPost(this.getBaseURL() + FILE + '/upload', data).then((response) => {201 return response;202 });203 }204 fileDownload(data) {205 return this.doPost(this.getBaseURL() + FILE + '/download', data, { responseType: 'blob' }).then((response) => {206 console.log(response);207 return response;208 });209 }210 getAdminAwarded() {211 return this.doPost(this.getBaseURL() + TRANSACTION + '/adminAwarded', {}).then((response) => {212 return response;213 });214 }215 addApplication(username, covid, monthly, amount, fullName, story, file1, file2, file3, share) {216 let body = {217 username: username,218 covid: covid,219 monthly: monthly,220 amount: amount,221 fullName: fullName,222 story: story,223 file0: file1,224 file1: file2,225 file2: file3,226 share: share227 };228 return this.doPost(this.getBaseURL() + APPLICATION + '/addApp', body);229 }230 getDonations(username) {231 return this.doPost(this.getBaseURL() + TRANSACTION + '/donations', { username: username232 }).then((response) => {233 return response;234 });235 }236 getAwarded(username) {237 return this.doPost(this.getBaseURL() + TRANSACTION + '/awarded', { username: username238 }).then((response) => {239 return response;240 });241 }242 getDeposit(username, card) {243 if (card) {244 return this.doPost(this.getBaseURL() + TRANSACTION + '/depositCard', { username: username245 }).then((response) => {246 return response;247 });248 }249 else {250 return this.doPost(this.getBaseURL() + TRANSACTION + '/depositBank', { username: username251 }).then((response) => {252 return response;253 });254 }255 }256 getWithdraw(username, usertype, card) {257 if (card) {258 return this.doPost(this.getBaseURL() + TRANSACTION + '/withdrawCard', { username: username, usertype: usertype259 }).then((response) => {260 return response;261 });262 }263 else {264 return this.doPost(this.getBaseURL() + TRANSACTION + '/withdrawBank', { username: username, usertype: usertype265 }).then((response) => {266 return response;267 });268 }269 }270 getPaymentMethod(username, card, connected) {271 if (card) {272 return this.doPost(this.getBaseURL() + TRANSACTION + '/cards', { username: username273 }).then((response) => {274 return response;275 });276 }277 else if (connected) {278 return this.doPost(this.getBaseURL() + TRANSACTION + '/connectedBanks', { username: username279 }).then((response) => {280 return response;281 });282 }283 else {284 return this.doPost(this.getBaseURL() + TRANSACTION + '/banks', { username: username285 }).then((response) => {286 return response;287 });288 }289 }290 removePaymentMethod(username, type, name, usertype) {291 if (type === 'Bank') {292 return this.doPost(this.getBaseURL() + STRIPE + '/removeBank', { username: username, nickname: name, usertype: usertype293 }).then((response) => {294 return response;295 });296 }297 else {298 return this.doPost(this.getBaseURL() + STRIPE + '/removeCard', { username: username, type: type, name: name299 }).then((response) => {300 return response;301 });302 }303 }304 awardHUG(HUGID, username, amount, email) {305 return this.doPost(this.getBaseURL() + STRIPE + '/transferFundFromHUGToRecipient', {306 HUGID: HUGID,307 recipientID: username,308 amount: amount,309 email: email310 }).then((response) => {311 return response;312 });313 }314 rejectApplicant(HUGID, username, email) {315 return this.doPost(this.getBaseURL() + STRIPE + '/rejectRecipient', {316 HUGID: HUGID,317 username: username,318 email: email319 }).then((response) => {320 return response;321 }).catch((error) => {322 console.log("502 by Rejection");323 return { sucess: "Updated Awarded status" };324 });325 }326 getStripeAccountID(username, usertype) {327 return this.doPost(this.getBaseURL() + STRIPE + '/getCustomAccountID', { username: username, usertype: usertype328 }).then((response) => {329 return response;330 });331 }332 getConnectedRequirements(username, usertype, accountID) {333 return this.doPost(this.getBaseURL() + STRIPE + '/checkConnectRequirements', { username: username, usertype: usertype, accountID: accountID334 }).then((response) => {335 return response;336 });337 }338 getStripeAccountBalance(username, usertype, accountID) {339 return this.doPost(this.getBaseURL() + STRIPE + '/getAccountBalance', { username: username, usertype: usertype, accountID: accountID340 }).then((response) => {341 return response;342 });343 }344 onboardingInfoReq(username, usertype, accountID, url) {345 return this.doPost(this.getBaseURL() + STRIPE + '/onboardingInfoRequest', { username: username, usertype: usertype, accountID: accountID,346 successURL: url, failureURL: url347 }).then((response) => {348 return response;349 });350 }351 donateToHug(username, HUGName, amount) {352 return this.doPost(this.getBaseURL() + STRIPE + '/transferFundFromDonorToHUG', { username: username, HUGName: HUGName, amount: amount353 }).then((response) => {354 return response;355 });356 }357 stripeDeposit(username, type, method, beforetax, afterTax, stripeFee, fee) {358 return this.doPost(this.getBaseURL() + STRIPE + '/deposit', {359 username: username,360 paymentType: type,361 paymentMethod: method,362 amountToCharge: beforetax,363 amountToDeposit: afterTax,364 stripeFee: stripeFee,365 managementFee: fee366 }).then((response) => {367 return response;368 });369 }370 getTransactionStatus(username, chargeID, type) {371 return this.doPost(this.getBaseURL() + TRANSACTION + '/depositStatus', { username: username, chargeID: chargeID372 }).then((response) => {373 return response;374 });375 }376 getCustomBank(data) {377 return this.doPost(this.getBaseURL() + STRIPE + '/getCustomBank', data).then((response) => {378 return response;379 });380 }381 stripeTransfer(data) {382 return this.doPost(this.getBaseURL() + STRIPE + '/transfer', data).then((response) => {383 return response;384 });385 }386 stripePayout(data, update) {387 if (update) {388 return this.doPost(this.getBaseURL() + STRIPE + '/payoutUpdateTable', data).then((response) => {389 return response;390 });391 }392 else {393 return this.doPost(this.getBaseURL() + STRIPE + '/payout', data).then((response) => {394 return response;395 });396 }397 }398 attachBankToCustomer(data, account) {399 if (account === true) {400 return this.doPost(this.getBaseURL() + STRIPE + '/attachBankToCustomAccount', data).then((response) => {401 return response;402 });403 }404 else {405 return this.doPost(this.getBaseURL() + STRIPE + '/attachBankToCustomer', data).then((response) => {406 return response;407 });408 }409 }410 addBankToCustomTable(data) {411 return this.doPost(this.getBaseURL() + STRIPE + '/addBankToCustomTable', data).then((response) => {412 return response;413 });414 }415 login(username, password) {416 return this.doPost(this.getBaseURL() + AUTH_EP + "/login", {417 username: username,418 password: password419 }, {420 headers: { "Content-Type": "application/json" }421 })422 .then((response) => {423 console.log(response);424 if (typeof response.userInfo !== "undefined") { // Check if return type is LoginResponse425 this.setSessionToken(response.token);426 return response;427 }428 else {429 return response;430 }431 });432 }433 /**434 * Retrieve a user's UserInfo435 * @param userId: the user's unique id436 */437 getUserInfo(userId) {438 return this.doGet(this.getBaseURL() + PROFILE_EP + `/${userId}/userInfo`);439 }440 /**441 * Changes a user's password in Affordable442 * @param oldPassword443 * @param newPassword444 */445 changePassword(oldPassword, newPassword) {446 return this.doPost(this.getBaseURL() + AUTH_EP + "/change-password", {447 oldPassword: oldPassword,448 newPassword: newPassword449 });450 }451 /**452 * Sends an email to the user providing their username and453 * gives a link allowing them to change their password454 * @param email455 */456 forgotUserNameOrPassword(email) {457 return this.doPost(this.getBaseURL() + AUTH_EP + "/forgot-password", {458 email: email459 });460 }461 /**462 * Resets the user's password from the email sent to them463 * @param email464 */465 resetPassword(password, code) {466 return this.doPost(this.getBaseURL() + AUTH_EP + "/reset-password", {467 password: password,468 code: code469 });470 }471 /**472 * Creates a user profile in Affordable473 * @param profile474 */475 createProfile(profile) {476 return this.doPost(this.getBaseURL() + PROFILE_EP, { profile: profile });477 }478 /**479 * Gets whether a user has verified their email in Affordable480 * @param userId481 */482 getEmailVer() {483 return this.doGet(this.getBaseURL() + AUTH_EP + "/get-verification");484 }485 /**486 * Gets a user profile in Affordable487 * @param userId488 */489 getProfile(userId) {490 return this.doGet(this.getBaseURL() + PROFILE_EP, { userId: userId });491 }492 /**493 * Deletes a user profile in Affordable494 * @param profile495 */496 deleteProfile(userId) {497 return this.doDelete(this.getBaseURL() + PROFILE_EP, { userId: userId });498 }499 /**500 * Gets the primary email address of a user in Affordable501 * @param profile502 */503 getPrimaryEmail(username) {504 return axios_1.default.get(this.getBaseURL() + PROFILE_EP + "/get-primary-email", {505 params: { username: username },506 headers: { "Content-Type": "application/json" }507 })508 .then((response) => response.data)509 .catch((error) => {510 throw new AffordableHttpError(error);511 });512 }513 /**514 * Updates the primary email address of a user in Affordable515 * @param516 */517 updatePrimaryEmail(newEmail) {518 return this.doPost(this.getBaseURL() + AUTH_EP + "/email/update", {519 email: newEmail520 });521 }522 /**523 * Create an organization524 * @param organization525 * @returns the organization526 */527 createOrganization(organization) {528 return this.doPost(this.getBaseURL() + ORGANIZATION_EP, organization);529 }530 /**531 * Update an organization532 * @param organization533 * @returns the organization534 */535 updateOrganization(organization) {536 return this.doPost(this.getBaseURL() + ORGANIZATION_EP + `/${organization.id}`, organization);537 }538 /**539 * Get an organization in Affordable540 * @param organizationId541 */542 getOrganization(organizationId) {543 return this.doGet(this.getBaseURL() + ORGANIZATION_EP + `/${organizationId}`);544 }545 /**546 * Get the API key for an organization in Affordable547 * @param organizationId548 */549 getApiKey(organizationId) {550 return this.doGet(this.getBaseURL() + ORGANIZATION_EP + `/${organizationId}/apiKey`);551 }552 /**553 * Get the API key for an organization in Affordable554 * @param profile555 */556 getOrganizationsForUser(userId) {557 return this.doGet(this.getBaseURL() + PROFILE_EP + `/${userId}/organizations`);558 }559 /**560 * Add a user to an organization561 * @param request562 */563 addUserToOrganization(request) {564 return this.doPost(this.getBaseURL() + ORGANIZATION_EP + `/${request.organizationId}/members`, request);565 }566 /**567 * Remove a user from an organization568 * @param organizationId569 * @param userId570 */571 removeMemberFromOrganization(organizationId, userId) {572 return this.doDelete(this.getBaseURL() + ORGANIZATION_EP + `/${organizationId}/members/${userId}`);573 }574 /**575 * Create a Health Utilizing Grant576 * @param grant577 */578 createGrant(grant) {579 return this.doPost(this.getBaseURL() + GRANT_EP, grant);580 }581 /**582 * Update a Health Utilizing Grant583 * @param grant584 */585 updateGrant(grant) {586 return this.doPut(this.getBaseURL() + GRANT_EP + `/${grant.id}`, grant);587 }588 /**589 * Get a Health Utilizing Grant590 * @param id591 */592 getGrant(id) {593 return this.doGet(this.getBaseURL() + GRANT_EP + `/${id}`);594 }595 /**596 * Delete a Health Utilizing Grant597 * @param id598 */599 deleteGrant(id) {600 return this.doDelete(this.getBaseURL() + GRANT_EP + `/${id}`);601 }602 /**603 * Get the list of grants that the user is eligible for604 */605 getEligibleGrants() {606 return this.doGet(this.getBaseURL() + GRANT_EP);607 }608 /**609 * Get the list of applicants for a grant that the user has permission to manage610 */611 getGrantApplicants(id) {612 return this.doGet(this.getBaseURL() + GRANT_EP + `/${id}/applicants`);613 }614 /**615 * Apply to a grant, if you are an eligible recipient.616 */617 applyToGrant(id) {618 return this.doPut(this.getBaseURL() + GRANT_EP + `/${id}/apply`, {});619 }620 /**621 * Award a grant to a user that has applied for a grant, if you belong to the organization that manages the grant.622 * @param userId623 * @param grantId624 */625 awardGrantToUser(userId, grantId) {626 return this.doPut(this.getBaseURL() + GRANT_EP + `/${grantId}/award/${userId}`, {});627 }628 addActivity(request) {629 return this.doPost(this.getBaseURL() + ACTIVITY_EP + "/add-activity", request).then((response) => {630 return response;631 });632 }633 deleteEmail(request) {634 return this.doPost(this.getBaseURL() + PROFILE_EP + "/delete-email", request).then((response) => {635 return response;636 });637 }638 checkEmail(request) {639 return this.doPost(this.getBaseURL() + AUTH_EP + "/email", request).then((response) => {640 return response;641 });642 }643 /**644 *645 * rest of this class is newly created API routes for AUTUMN 2020646 *647 */648 stripeCustomer(id, name, email) {649 return this.doPost(this.getBaseURL() + STRIPE + '/customer', {650 id: id,651 name: name,652 email: email,653 }).then((response) => {654 return response;655 });656 }657 stripeAddBank(id) {658 return this.doPost(this.getBaseURL() + STRIPE + '/addBank', {659 id: id660 }).then((response) => {661 console.log("ENTERING ADD BANK");662 return response;663 });664 }665}666exports.AffordableClient = AffordableClient;667class AffordableHttpError extends Error {668 constructor(error) {669 super(error.message + ": " + error.response.data.error);670 this.responseStatus = error.response.status;671 // Set the prototype explicitly.672 Object.setPrototypeOf(this, AffordableHttpError.prototype);673 }674}...
api.js
Source:api.js
1export default {2 // NO 23 PROXY_ADD: getBaseUrl + '/kf/add/proxy/', //æ°å¢ä»£ç OK åæ°å注åæ¥å£ï¼åªæ¯ä¸ç¨éªè¯ç 4 PROXY_SEARCH: getBaseUrl + '/proxy/list/', //代çå表 OK 代çåå表5 PROXY_MODIFY: getBaseUrl + '/kf/add/proxy/', //代çä¿®æ¹--缺6 PROXY_INFO: getBaseUrl + '/kf/add/proxy/', //代çè´¦æ·ä¿¡æ¯--缺7 PROXY_ORDER: getBaseUrl + '/proxy/order/list/', //代ççå½å¤©è®¢å OK åæ°åä¼å订åå表æ¥å£ å页æ¥æ¾åå·ä¿¡æ¯8 PROXY_MEMBER: getBaseUrl + '/proxy/member/list/', //代ççä¸å±ä¼å OK åæ°æ 9 PROXY_SUMM_DAY: getBaseUrl + '/proxy/summ/day/', // 代çåæ¥ç»è®¡ OK åæ°å管çåæ¥ç»è®¡10 PROXY_SUMM_MONTH: getBaseUrl + '/proxy/summ/month/', // 代çåæç»è®¡ OK åæ°å管çåæç»è®¡11 PROXY_ADDRESS: getBaseUrl + '/portal/add/send/org/', // æ°å¢å货人 OK12 PROXY_MODIFY_ADDRESS: getBaseUrl + '/portal/update/send/org/', // ä¿®æ¹å货人 OK13 PROXY_CHARGE: getBaseUrl + '/kf/check/charge/', //å
å¼è½®è¯¢è¯é³æ示14 URL_KF_PROXY_DAY: getBaseUrl + '/kf/bi/proxy/day/',15 URL_KF_PROXY_MONTH: getBaseUrl + '/kf/bi/proxy/month/',16 // 注åæ¥å£æ·»å 代çIDå段17 //NO 118 // ç»å½æ³¨åæ¥å£19 URL_LOGIN: getBaseUrl + '/portal/sign/in/', //ç»å½20 URL_REGISTER: getBaseUrl + '/portal/sign/up/', // 注å21 URL_GET_CHECK: getBaseUrl + '/portal/fetch/img/', // è·åéªè¯ç 22 URL_QUIT_LOGIN: getBaseUrl + '/portal/log/out/', // éåºç»å½23 URL_UP_userRecharge: getBaseUrl + '/portal/charge/commit/', //å
å¼æ交24 URL_GET_QRCODE: getBaseUrl + '/getQRCode', //å
å¼äºç»´ç URL25 // èµéæç»æ¥å£26 URL_GET_MONEY_DETAIL: getBaseUrl + '/portal/flow/list/', //å页æ¥è¯¢èµéæç»27 // è´ä¹°åå·æ¥å£28 URL_GET_userRecharge_TIPS: getBaseUrl + '/getuserRechargeTips', // è´ä¹°åå·æç¨29 URL_ALL_ADDRESS: getBaseUrl + '/getAllAddress', // è·åç¨æ·å°å30 URL_ALL_EXPRESS_TYPES: getBaseUrl + '/getAllExpressTypes', // è·åææå¿«éä¿¡æ¯31 // URL_SET_DEFAULT_ADDRESS: getBaseUrl + '/setDefaultAddress', // 设置é»è®¤å°å32 URL_SET_DEFAULT_EXPRESS: getBaseUrl + '/portal/set/default/express/', // 设置é»è®¤å¿«é33 URL_POST_userRecharge: getBaseUrl + '/portal/place/order/', // è´ä¹°åå· order_id: "123"//æåå¿«éåå·34 // åå·æ¥è¯¢35 URL_GET_EXPRESS_MESSAGE: getBaseUrl + '/portal/order/list/', // å页æ¥æ¾åå·ä¿¡æ¯36 URL_EXCEL_SEARCH_DOWNLOAD: getBaseUrl + '/portal/export/orders/', // 导åºç¨æ·æ¥è¯¢ææç»æ37 URL_DOWNLOAD_EXPRESS_MESSAGE: getBaseUrl + '/downloadExpressMessage', // å页æ¥æ¾åå·ä¿¡æ¯38 // è´¢å¡ç®¡ç39 URL_FINANCE_CHECK_SEARCH: getBaseUrl + '/financeCheckSearch', // è´¢å¡å页æ¥è¯¢å¾
å®¡æ ¸40 URL_FINANCE_CHECK: getBaseUrl + '/financeCheck', // è´¢å¡éé¢å®¡æ ¸41 URL_FINANCE_CHECK_HISTORY: getBaseUrl + '/financeCheckHistory', // è´¢å¡å®¡æ ¸è®°å½42 URL_FINANCE_DETAIL_HISTORY: getBaseUrl + '/financeDetailHistory', // è´¢å¡æ¶è´¹è®°å½43 // ç³»ç»ç®¡ç44 URL_SYSTOM_ADD_MONEY: getBaseUrl + '/systomAddMoney', // æ·»å ç³»ç»å
å¼éé¢45 URL_SYSTOM_DEL_MONEY: getBaseUrl + '/systomPutMoney', // å é¤ç³»ç»å
å¼éé¢46 URL_SYSTOM_PUT_MONEY: getBaseUrl + '/systomDelMoney', // ä¿®æ¹ç³»ç»å
å¼éé¢47 URL_UPLOAD_FILES: getBaseUrl + '/systomUploadFiles', // ä¸ä¼ æ件æ¥å£48 // å¿«éç¨é49 URL_GET_EXPRESS_TYPES: getBaseUrl + '/systomGetExpressTypes', // è·åææå¿«éç¨é50 URL_ADD_EXPRESS_TYPES: getBaseUrl + '/systomAddExpressTypes', // æ°å¢å¿«éç¨é51 URL_PUT_EXPRESS_TYPES: getBaseUrl + '/systomPutExpressTypes', // ä¿®æ¹å¿«éç¨é52 URL_DEL_EXPRESS_TYPES: getBaseUrl + '/systomDelExpressTypes', // å é¤å¿«éç¨é53 // é¢åå
¬å¸ä¿¡æ¯54 URL_GET_EXPRESS_ORDER: getBaseUrl + '/portal/code/info/', // æ ¹æ®å¿«éå
¬å¸ç 表55 URL_ADD_EXPRESS_ORDER: getBaseUrl + '/systomAddExpressOrder', // æ°å¢å¿«éå
¬å¸56 URL_PUT_EXPRESS_ORDER: getBaseUrl + '/systomPutExpressOrder', // ä¿®æ¹å¿«éå
¬å¸57 // URL_DEL_EXPRESS_ORDER: getBaseUrl + '/systomDelExpressOrder' // å é¤å¿«éå
¬å¸é¢å58 // æ·»å é¢å59 URL_ADD_EXPRESS_ORDER_NUM: getBaseUrl + '/systomAddExpressOrderNum', // æ°å¢é¢å60 // vip61 URL_GET_VIP: getBaseUrl + '/systomGetVip', // VIPå页æ¥è¯¢62 URL_GET_VIP_TYPE: getBaseUrl + '/systomGetVipType', // VIPåç±»63 URL_GET_VIP_ADD_TYPE: getBaseUrl + '/systomGetVipAddType', // æ·»å VIPåç±»64 URL_GET_VIP_CHANGE: getBaseUrl + '/systomGetVipChange', // VIP设置65 // QQ66 URL_GET_QQ: getBaseUrl + '/systomGetQQ', // è·å客ææ°æ®67 URL_SET_QQ: getBaseUrl + '/systomSetQQ', // 设置客æ设置68 //åè´§69 URL_GET_DELIVER_STATUS: getBaseUrl + '/systomGetQQ', // è·ååè´§ç¶æ70 URL_PUT_DELIVER_STATUS: getBaseUrl + '/systomGetQQ', // æ¹éä¿®æ¹åè´§ç¶æ71 // å
å¼72 URL_GET_RECHARGE_STATUS: getBaseUrl + '/systomGetQQ', // è·åå
å¼å¾
å®¡æ ¸å页æ¥è¯¢73 URL_GET_USER_ADDRESS: getBaseUrl + '/portal/address/list/', // ç¨æ·å°å74 URL_DELETE_USER_ADDRESS: getBaseUrl + '/portal/address/delete/', // å é¤åè´§å°å åæ°åªä¼ 个 id75 URL_SET_DEFAULT_ADDRESS: getBaseUrl + '/portal/set/default/address/', // 设置é»è®¤åè´§å°åå页æ¥è¯¢76 URL_GET_USER_INFO: getBaseUrl + '/portal/user/info/',77 // /portal/user/info/ // ç¨æ·ä¿¡æ¯78 URL_PUT_ORDER_CHECK: getBaseUrl + '/kf/order/verify/', // åè´§79 URL_PUT_ORDER_REBACK_CHECK: getBaseUrl + '/kf/order/send/', // å货失败åå表ä¸åè´§80 URL_PUT_ORDER_CHECK_RESEND: getBaseUrl + '/kf/order/resend/', // éæ°åè´§81 URL_PUT_ORDER_RESEND_DETAIL_EXPORT: getBaseUrl + '/kf/order/resendDetailExport/', // éæ°å货详æ
导åº82 URL_PUT_RECHARGE_CHECK: getBaseUrl + '/kf/charge/verify/', // å
å¼å®¡æ ¸83 URL_GET_CHARGE_FINANCE_LIST: getBaseUrl + '/kf/charge/list/', // è´¢å¡çå
å¼è®°å½84 URL_GET_ORDER_FINANCE_LIST: getBaseUrl + '/kf/order/list/', // è´¢å¡çæ¶è´¹è®°å½85 URL_GET_ORDER_FINANCE: getBaseUrl + '/kf/order/get/', // å个财å¡çæ¶è´¹è®°å½86 URL_EXCEL_KF_SEARCH_DOWNLOAD: getBaseUrl + '/kf/export/orders/', // 导åºç®¡çåæ¥è¯¢ææç»æ87 URL_EXCEL_USER_FINANCE: getBaseUrl + '/portal/export/flows/', // ç¨æ·å¯¼åºèµéæç»88 // /portal/code/info/è·åææå¿«éç å¼89 // /portal/address/list/ è·åç¨æ·ææå°å90 // /kf/express/save/ ç»´æ¤å¿«éå
¬å¸91 // org.corp = body.get('corp', '')ç±»å92 // org.corp_name = body.get('corpName', '')93 // org.express_type = body.get('expressType', '')94 // org.express_name = body.get('expressName', '')å
¬å¸95 // å
¬å¸å端åï¼ç 表ä»æ¥å£è·åUSER_MODIFY_PASSWORDã96 URL_KF_FIND_USER: getBaseUrl + '/kf/user/list/ ', // ä¼åå表97 URL_KF_UPLOAD_USER: getBaseUrl + '/kf/update/user/ ', // ä¿®æ¹ç¨æ·ä¿¡æ¯98 URL_USER_MODIFY_PASSWORD: getBaseUrl + '/portal/change/password/', //ä¿®æ¹å¯ç 99 URL_SYSTOEM_RESET_PASSWORD: getBaseUrl + '/kf/reset/password/', //éç½®å¯ç 100 URL_EXCEL_EXPRESS_LIST: getBaseUrl + '/kf/express/list/', //å¿«éå表101 URL_EXCEL_COMP_MODIFY: getBaseUrl + '/kf/express/save/', // ç»´æ¤å¿«éå
¬å¸102 URL_EXCEL_COMP_DELETE: getBaseUrl + '/kf/express/delete/', // å é¤å¿«éå
¬å¸103 // URL_EXCEL_MODEL: getBaseUrl + '/data/excel_template.xlsx', //Excel模æ¿104 URL_KF_LIST: getBaseUrl + '/kf/kf/list/', // 客æå表105 URL_KF_MODIFY: getBaseUrl + '/kf/update/kf/', // ä¿®æ¹å®¢æä¿¡æ¯106 URL_KF_PUBLIC_LIST: getBaseUrl + '/kf/notice/list/', // å
¬åå表107 URL_KF_ADD_PUBLIC: getBaseUrl + '/kf/notice/add/', // æ°å¢å
¬å108 URL_KF_MODIFY_PUBLIC: getBaseUrl + '/kf/notice/update/', // ä¿®æ¹å
¬å109 URL_KF_DELETE_PUBLIC: getBaseUrl + '/kf/notice/delete/', // å é¤å
¬å110 URL_KF_ALL_DAY: getBaseUrl + '/kf/bi/all/day/', // æ¥ç»è®¡111 URL_KF_ALL_MONTH: getBaseUrl + '/kf/bi/all/month/', // æç»è®¡112 URL_KF_ALL_USER: getBaseUrl + '/kf/bi/user/day/', // ç¨æ·ç»è®¡113 URL_KF_UPDATE_HISTORY: getBaseUrl + '/kf/update/history/', // ç¨æ·ä¿®æ¹è®°å½114 URL_EXCEL_ZFB_PAY: getBaseUrl + '/portal/charge/pay/', // æ¯ä»å®ä»æ¬¾115 URL_EXCEL_ZFB_PAY_SUCCESS: getBaseUrl + '/portal/charge/check_pay/', // æ¯ä»å®ä»æ¬¾æååè°116 URL_EXCEL_UPLEAD: getBaseUrl + '/portal/upload/orders/', // æ¹éä¸åä¸ä¼ EXCEL117 URL_EXCEL_MODEL: getBaseUrl + '/data/place_orders.xlsx', //æ¹éä¸åExcel模æ¿118 URL_GET_CHAARGE_LIST: getBaseUrl + '/portal/charge/list/' // ç¨æ·å
å¼è®°å½119}120// URL_GET_MENU: getBaseUrl + '/getMenu', // è·åèå121// å
å¼æ¥å£122// URL_GET_userRecharge: getBaseUrl + '/getuserRecharge', // è·åå
å¼å
¨é¨éé¢ ,confit...
authController.js
Source:authController.js
...16module.exports = {17 index : (req,res)=>{18 res.status(200).json({19 register : {20 endpoint : getBaseUrl(req) + '/register',21 method : 'POST',22 columns : {23 email : 'string',24 pass : 'string'25 }26 },27 login : {28 endpoint : getBaseUrl(req) + '/login',29 method : 'POST', 30 columns : {31 email : 'string',32 pass : 'string'33 }34 },35 movies : {36 all : {37 endpoint : getBaseUrl(req) + '/movies/',38 method : 'GET'39 },40 one : {41 endpoint : getBaseUrl(req) + '/movies/{id}',42 method : 'GET'43 },44 create : {45 endpoint : getBaseUrl(req) + '/movies/create',46 method : 'POST',47 columns : {48 title : 'string(500)',49 rating : 'decimal(3,1) UNSIGNED',50 awards : 'integer UNSIGNED (opcional)',51 release_date : 'datetime',52 length : 'integer UNSIGNED (opcional)',53 genre_id : 'integer (opcional)'54 }55 },56 update : {57 endpoint : getBaseUrl(req) + '/movies/update/{id}',58 method : 'PUT'59 },60 delete : {61 endpoint : getBaseUrl(req) + '/movies/delete/{id}',62 method : 'DELETE'63 },64 65 },66 genres : {67 all : {68 endpoint : getBaseUrl(req) + '/genres',69 method : 'GET'70 },71 one : {72 endpoint : getBaseUrl(req) + '/genres/{id}',73 method : 'GET'74 },75 create : {76 endpoint : getBaseUrl(req) + '/genres/create',77 method : 'POST',78 columns : {79 name : 'string(100)',80 ranking : 'INTEGER(10) UNSIGNED UNIQUE',81 active : 'integer UNSIGNED (opcional)'82 }83 },84 update : {85 endpoint : getBaseUrl(req) + '/genres/update/{id}',86 method : 'PUT'87 },88 delete : {89 endpoint : getBaseUrl(req) + '/genres/delete/{id}',90 method : 'DELETE'91 },92 }93 })94 },95 register : (req,res) => {96 const {email, pass} = req.body;97 98 verifyData(email,pass,res)99 db.Users.findOne({100 where : {101 email102 }103 })...
ApiEndpoints.js
Source:ApiEndpoints.js
...15const SEARCH = "/search";16const COLLECTION = "/collection";17const BLOGS = "/blog";18const MEDIA = "/library";19function getBaseUrl() {20 if (process.env.SERVER) {21 return config.dockerBaseUrl;22 } else if (process.env.CLIENT) {23 if (Platform.is.android) {24 return config.androidBaseUrl;25 } else {26 return config.baseUrl;27 }28 }29}30export default {31 PLACES: getBaseUrl() + PLACE + API_V1 + "/places",32 COUNTRIES: getBaseUrl() + PLACE + API_V1 + COUNTRIES,33 ADMINISTRATIVE_AREAS: getBaseUrl() + PLACE + API_V1 + ADMINISTRATIVE_AREAS,34 LOCALITIES: getBaseUrl() + PLACE + API_V1 + LOCALITIES,35 SUB_LOCALITIES1: getBaseUrl() + PLACE + API_V1 + SUB_LOCALITIES1,36 SUB_LOCALITIES2: getBaseUrl() + PLACE + API_V1 + SUB_LOCALITIES2,37 PLACE_IDS: getBaseUrl() + PLACE + API_V1 + "/ip",38 BLOGS: getBaseUrl() + BLOGS + API_V1 + "/blogs",39 BLOG_COMMENTS: getBaseUrl() + BLOGS + API_V1 + "/comments",40 BLOG_LIKES: getBaseUrl() + BLOGS + API_V1 + "/likes",41 BLOG_IMAGES: getBaseUrl() + BLOGS + API_V1 + "/images",42 BLOG_VIDEOS: getBaseUrl() + BLOGS + API_V1 + "/videos",43 LOCATIONS: API_V1 + "/locations",44 FORM_DATA: API_V1 + "/form-data",45 CATEGORIES: API_V1 + "/categories",46 USERS: getBaseUrl() + USER + API_V1 + "/users",47 USERS_COLLECTION: getBaseUrl() + USER + API_V1 + "/user-collection",48 LIKES: "/likes",49 COMMENTS: "/comments",50 EP_IMAGES: "/ep-images",51 REVIEWS: getBaseUrl() + REVIEWS + API_V1 + "/reviews",52 REVIEW_COMMENTS: getBaseUrl() + REVIEWS + API_V1 + "/comments",53 REVIEW_LIKES: getBaseUrl() + REVIEWS + API_V1 + "/likes",54 REVIEW_IMAGES: getBaseUrl() + REVIEWS + API_V1 + "/images",55 REVIEW_VIDEOS: getBaseUrl() + REVIEWS + API_V1 + "/videos",56 BLOGS: getBaseUrl() + BLOGS + API_V1 + "/blogs",57 BLOG_COMMENTS: getBaseUrl() + BLOGS + API_V1 + "/comments",58 BLOG_LIKES: getBaseUrl() + BLOGS + API_V1 + "/likes",59 BLOG_IMAGES: getBaseUrl() + BLOGS + API_V1 + "/images",60 BLOG_VIDEOS: getBaseUrl() + BLOGS + API_V1 + "/videos",61 REVERSE_GEOCODE: getBaseUrl() + LOCATIONS + API_V1 + "/reverse-geocode",62 AUTOCOMPLETE_RESULTS:63 getBaseUrl() + LOCATIONS + API_V1 + "/autocomplete-results",64 PLACE_DETAILS: getBaseUrl() + LOCATIONS + API_V1 + "/place-details",65 SIGN_IN: getBaseUrl() + AUTH + API_V1 + "/sign-in",66 LOGOUT: getBaseUrl() + AUTH + API_V1 + "/logout",67 MEDICAL_EXPERTISE: getBaseUrl() + PROFILE + API_V1 + "/medical-expertise",68 YOGA_EXPERTISE: getBaseUrl() + PROFILE + API_V1 + "/yoga-expertise",69 YOGA_CERTIFICATE: getBaseUrl() + PROFILE + API_V1 + "/yoga-certificate",70 BASIC_INFO: getBaseUrl() + PROFILE + API_V1 + "/basic-info",71 BASIC_INFO_COLLECTION:72 getBaseUrl() + PROFILE + API_V1 + "/basic-info-collection",73 INTERESTS: getBaseUrl() + PROFILE + API_V1 + "/interests",74 VIDEOS: getBaseUrl() + PROFILE + API_V1 + "/videos",75 IMAGES: getBaseUrl() + PROFILE + API_V1 + "/images",76 USER_MEDICAL_EXPERTISE:77 getBaseUrl() + PROFILE + API_V1 + "/user-medical-expertise",78 USER_YOGA_EXPERTISE: getBaseUrl() + PROFILE + API_V1 + "/user-yoga-expertise",79 USER_YOGA_CERTIFICATE:80 getBaseUrl() + PROFILE + API_V1 + "/user-yoga-certificate",81 SEARCH_USER_INFO: getBaseUrl() + SEARCH + API_V1 + "/user-info",82 SEARCH_IMAGE_INFO: getBaseUrl() + SEARCH + API_V1 + "/image-info",83 SEARCH_VIDEO_INFO: getBaseUrl() + SEARCH + API_V1 + "/video-info",84 SEARCH_BLOG_INFO: getBaseUrl() + SEARCH + API_V1 + "/blog-info",85 SEARCH_COLLECTION_INFO: getBaseUrl() + SEARCH + API_V1 + "/collection-info",86 SEARCH_FEED: getBaseUrl() + SEARCH + API_V1 + "/feed",87 SEARCH_COLLECTION_IMAGE_INFO:88 getBaseUrl() + SEARCH + API_V1 + "/collection/image-info",89 SEARCH_COLLECTION_VIDEO_INFO:90 getBaseUrl() + SEARCH + API_V1 + "/collection/video-info",91 SEARCH_COLLECTION_BLOG_INFO:92 getBaseUrl() + SEARCH + API_V1 + "/collection/blog-info",93 PLACES_MANAGED: "/places-managed",94 USER_COVER: "/cover-pic",95 USER_PROFILE: "/profile-pic",96 FEED_LOCATION_WISE: "/api/open/feeds",97 COLLECTIONS: getBaseUrl() + COLLECTION + API_V1 + "/collections",98 COLLECTION_IMAGES: getBaseUrl() + COLLECTION + API_V1 + "/collection-images",99 COLLECTION_BLOGS: getBaseUrl() + COLLECTION + API_V1 + "/collection-blogs",100 COLLECTION_VIDEOS: getBaseUrl() + COLLECTION + API_V1 + "/collection-videos",101 MEDIA_UPLOAD: getBaseUrl() + MEDIA + API_V1 + "/media-upload",102 MEDIA_UPLOAD_URL_PUBLIC:103 getBaseUrl() + MEDIA + API_V1 + "/media-upload/url/public",104 MEDIA_UPLOAD_URL: getBaseUrl() + MEDIA + API_V1 + "/media-upload/url"...
AffordableAdminClient.js
Source:AffordableAdminClient.js
1"use strict";2Object.defineProperty(exports, "__esModule", { value: true });3exports.AffordableAdminClient = void 0;4const AffordableClient_1 = require("./AffordableClient");5const ADMIN_ROUTE = "/admin";6class AffordableAdminClient extends AffordableClient_1.AffordableClient {7 constructor() {8 super();9 }10 getAdmins(admin) {11 return this.doGet(this.getBaseURL() + ADMIN_ROUTE + "/getAdmins", admin);12 }13 getAdminRegistrationRequests() {14 return this.doGet(this.getBaseURL() + ADMIN_ROUTE + "/registrationRequests");15 }16 acceptAdminRegistration(adminRequest) {17 return this.doPost(this.getBaseURL() + ADMIN_ROUTE + "/acceptRequest", adminRequest);18 }19 rejectAdminRegistration(adminRequest) {20 return this.doPost(this.getBaseURL() + ADMIN_ROUTE + "/rejectRequest", adminRequest);21 }22 revokeAdminAccess(request) {23 return this.doPost(this.getBaseURL() + ADMIN_ROUTE + "/revokeAccess", request);24 }25 getPrivileges(admin) {26 return this.doGet(this.getBaseURL() + ADMIN_ROUTE + "/getPrivileges", admin);27 }28 getAllAdminPrivileges() {29 return this.doGet(this.getBaseURL() + ADMIN_ROUTE + "/getAllPrivileges");30 }31 setPrivileges(adminId, privileges) {32 let updateRequest = {33 adminId: adminId,34 privileges: privileges35 };36 return this.doPost(this.getBaseURL() + ADMIN_ROUTE + "/setPrivileges", updateRequest);37 }38 resetAuthInfoNonAdmin(user) {39 this.doPost(this.getBaseURL() + ADMIN_ROUTE + "/resetAuthNonAdmin", user);40 }41 resetAuthInfoAdmin(admin) {42 this.doPost(this.getBaseURL() + ADMIN_ROUTE + "/resetAuthNonAdmin", admin);43 }44 verifyEmailAddressForUser(userInfo) {45 return this.doGet(this.getBaseURL() + ADMIN_ROUTE + "/verifyEmail", { username: userInfo.username });46 }47 checkPrivilege(adminId, privilege) {48 return new Promise((resolve) => {49 resolve(true);50 // this.getUserInfo(adminId).then((res: UserInfo) => {51 // if (res.userType == "admin") {52 // this.getPrivileges({ userId: adminId }).then((res: AdminPrivileges) => {53 // let canView: boolean = res[privilege];54 // console.log("can view: ", canView);55 // resolve(canView);56 // });57 // } else {58 // resolve(true);59 // }60 // });61 });62 }63 getAllUsers(admin) {64 console.log("admin: ", admin);65 return this.doGet(this.getBaseURL() + ADMIN_ROUTE + "/allUsers", admin);66 }67 recordAuditTrails(username, action) {68 return this.doPost(this.getBaseURL() + ADMIN_ROUTE + "/recordTrail", { username: username, action: action });69 }70 getAllAuditTrails(admin) {71 return this.doGet(this.getBaseURL() + ADMIN_ROUTE + "/allTrails", admin);72 }73 sendUserEmail(emailRequest) {74 return this.doPost(this.getBaseURL() + ADMIN_ROUTE + "/sendEmail", emailRequest);75 }76 activateDeactivateUser(userRequest) {77 return this.doPost(this.getBaseURL() + ADMIN_ROUTE + "/activateDeactivateUser", userRequest);78 }79}...
service.js
Source:service.js
1import request from '../utils/request';2import {getBaseUrl} from '../utils/getBaseUrl';3async function login(username, password){4 return request.post(5 `${getBaseUrl()}/api/login`,6 {7 username,8 password9 }10 )11}12async function register(username, password){13 return request.post(14 `${getBaseUrl()}/api/register`,15 {username, password}16 )17}18async function forgotPassword(username){19 return request.post(20 `${getBaseUrl()}/api/forgot-password`,21 {username}22 )23}24async function confirmForgotPassword(username, confirmationCode, password){25 return request.post(26 `${getBaseUrl()}/api/forgot-password/confirm`,27 {username, confirmationCode, password}28 )29}30async function changePassword(previousPassword, proposedPassword){31 return request.post(`${getBaseUrl()}/api/change-password`, {previousPassword, proposedPassword}, true);32}33async function deleteAccount(){34 return request.delete(`${getBaseUrl()}/api/delete-account`, true);35}36async function retrieveChecklists(){37 return request.get(`${getBaseUrl()}/api/user/checklist`, true);38}39async function addChecklist(title){40 return request.post(`${getBaseUrl()}/api/user/checklist`, {title}, true);41}42async function updateChecklist(item){43 const {Id, Pinned, Title} = item;44 return request.put(`${getBaseUrl()}/api/user/checklist/${Id}`, {pinned:Pinned, title:Title}, true);45}46async function deleteChecklist(id){47 return request.delete(`${getBaseUrl()}/api/user/checklist/${id}`, true);48}49async function retrieveChecklistItems(){50 return request.get(`${getBaseUrl()}/api/user/checklist/item`, true);51}52async function addChecklistItem(name, checklistId){53 return request.post(`${getBaseUrl()}/api/user/checklist/${checklistId}/item`, {name}, true);54}55async function updateChecklistItem(itemId, body){56 return request.put(`${getBaseUrl()}/api/user/checklist/item/${itemId}`, body, true);57}58async function deleteChecklistItem(itemId){59 return request.delete(`${getBaseUrl()}/api/user/checklist/item/${itemId}`, true);60}61async function retrieveAccountConfig(){62 return request.get(`${getBaseUrl()}/api/user/account`, true);63}64async function updateAccountConfig(config){65 return request.put(`${getBaseUrl()}/api/user/account`, config, true);66}67async function syncChecklistWithItems(checklist, items){68 return request.post(`${getBaseUrl()}/api/user/checklist/sync`, {checklist, items}, true);69}70export {71 login,72 register,73 changePassword,74 deleteAccount,75 forgotPassword,76 confirmForgotPassword,77 retrieveChecklists,78 addChecklist,79 updateChecklist,80 deleteChecklist,81 retrieveChecklistItems,82 addChecklistItem,...
RestService.js
Source:RestService.js
...12 service.alterContextPath=function(cpat){13 alteredContextPath= 'http://' + window.parent.url.host + ':' + window.parent.url.port+"/"+cpat+ '/restful-services/';14 }1516 function getBaseUrl(endP_path) {17 endP_path == undefined ? endP_path = path : true;18 return alteredContextPath==null? ENDPOINT_URI + endP_path + "/" : alteredContextPath + endP_path + "/"19 20 }21 ;2223 service.get = function(endP_path, req_Path, item) {24 25 item == undefined ? item = "" : item = "?" + encodeURIComponent(item).replace(/'/g,"%27").replace(/"/g,"%22").replace(/%3D/g,"=").replace(/%26/g,"&");26 console.log("GET: "+getBaseUrl(endP_path) + "" + req_Path + "" + item);27 return $http.get(getBaseUrl(endP_path) + "" + req_Path + "" +item);28 };29 service.get_item = function(endP_path, req_Path, item){30 console.log("GET2");31 console.log(item);32 return $http.get(getBaseUrl(endP_path) + "" + req_Path + "", item);33 }34 service.remove = function(endP_path, req_Path, item) {35 item == undefined ? item = "" : item = "?" + item;36 console.log("REMOVE: "+getBaseUrl(endP_path) + "" + req_Path + "" + item);37 return $http.post(getBaseUrl(endP_path) + "" + req_Path + "" + item);38 };3940 service.post = function(endP_path, req_Path, item, conf) {41 console.log("POST: "+getBaseUrl(endP_path) + "" + req_Path);42 console.log(item);43 return $http.post(getBaseUrl(endP_path) + "" + req_Path, item, conf);44 };45 46 service.put = function(endP_path, req_Path, item, conf) {47 console.log("PUT: "+getBaseUrl(endP_path) + "" + req_Path);48 console.log(item);49 return $http.put(getBaseUrl(endP_path) + "" + req_Path, item, conf);50 };51 52 service.delete = function(endP_path, req_Path) {53 console.log("PUT: "+getBaseUrl(endP_path) + "" + req_Path);54 console.log(item);55 return $http.delete(getBaseUrl(endP_path) + "" + req_Path);56 };5758 // prendo i nodi di un glossario5960 service.getGlossNode = function(glossID, nodeID) {61 console.log(getBaseUrl() + "listContents?GLOSSARY_ID=" + glossID62 + "&PARENT_ID=" + nodeID)63 return $http.get(getBaseUrl() + "listContents?GLOSSARY_ID=" + glossID64 + "&PARENT_ID=" + nodeID);65 };66
...
url.js
Source:url.js
1export const getBaseUrl = () => {2 return "/api";3};4export const URLS = {5 NEWS: () => `${getBaseUrl()}/news`,6 NEW: (id) => `${getBaseUrl()}/news/${id}`,7 IMAGES: () => `${getBaseUrl()}/pictures`,8 IMAGE: (id) => `${getBaseUrl()}/pictures/${id}`,9 PRODUCTS: () => `${getBaseUrl()}/products`,10 PRODUCT: (id) => `${getBaseUrl()}/products/${id}`,11 BANNERS: () => `${getBaseUrl()}/banners`,12 BANNER: (id) => `${getBaseUrl()}/banners/${id}`,13 CUSTOMERS: () => `${getBaseUrl()}/customers`,14 CUSTOMER: (id) => `${getBaseUrl()}/customers/${id}`,15 ORDERS: () => `${getBaseUrl()}/orders`,16 ORDER: (id) => `${getBaseUrl()}/orders/${id}`,17 BLOGS: () => `${getBaseUrl()}/news`,18 BLOG: (id) => `${getBaseUrl()}/news/${id}`,19 ORDER_ITEMS: () => `${getBaseUrl()}/order_items`,20 ORDER_ITEM: (id) => `${getBaseUrl()}/order_items/${id}`,21 CATEGORIES: () => `${getBaseUrl()}/categories`,22 CATEGORY: (id) => `${getBaseUrl()}/categories/${id}`,23 CATEGORY_PRODUCTS: (id) => `${getBaseUrl()}/categories/${id}/products`,24 INFORMATIONS: () => `${getBaseUrl()}/informations`,25 INFORMATION: (id) => `${getBaseUrl()}/informations/${id}`,26 LOGIN: () => `${getBaseUrl()}/login`,27 28 LOGOUT: () => `${getBaseUrl()}/logout`,29 CATEGORY_PRODUCTS: (id) => `${getBaseUrl()}/categories/${id}/products`,...
Using AI Code Generation
1describe('My First Test', () => {2 it('Does not do much!', () => {3 cy.visit(Cypress.config('baseUrl'));4 });5});6{7}8describe('My First Test', () => {9 it('Does not do much!', () => {10 cy.visit(Cypress.config('baseUrl'));11 });12});13{14}15describe('My First Test', () => {16 it('Does not do much!', () => {17 cy.visit(Cypress.config('baseUrl'));18 });19});20{21}22describe('My First Test', () => {23 it('Does not do much!', () => {24 cy.visit(Cypress.config('baseUrl'));25 });26});27{28}29describe('My First Test', () => {30 it('Does not do much!', () => {31 cy.visit(Cypress.config('baseUrl'));32 });33});34{35}36describe('My First Test', () => {37 it('Does not do much!', () => {38 cy.visit(Cypress.config('baseUrl'));39 });40});41{42}43describe('My First Test', () => {44 it('Does not do much!', () => {45 cy.visit(Cypress.config('baseUrl'));46 });47});48{49}
Using AI Code Generation
1describe('getBaseUrl', () => {2 it('should get the base url', () => {3 cy.visit('/')4 cy.getBaseUrl().then((baseUrl) => {5 })6 })7})
Using AI Code Generation
1describe('My First Test', function() {2 it('Gets, types and asserts', function() {3 cy.visit(Cypress.env('baseUrl'));4 cy.get('.search-input').type('Cypress.io');5 cy.get('.search-input').should('have.value', 'Cypress.io');6 });7});8{9}10{11}12describe('My First Test', function() {13 it('Gets, types and asserts', function() {14 cy.get('.search-input').type('Cypress.io');15 cy.get('.search-input').should('have.value', 'Cypress.io');16 });17});18{19}
Using AI Code Generation
1describe('My First Test', function () {2 it('Does not do much!', function () {3 cy.get('input[title="Search"]').type("Cypress")4 cy.get('input[value="Google Search"]').click()5 })6})
Using AI Code Generation
1describe('My First Test', function() {2 it('Does not do much!', function() {3 cy.visit(Cypress.env('baseUrl'));4 cy.get('.navbar-brand').should('contain', 'Conduit');5 });6});
Using AI Code Generation
1describe('Test', () => {2 it('test', () => {3 cy.visit('/');4 });5});6describe('Test', () => {7 it('test', () => {8 cy.visit('/');9 });10});11describe('Test', () => {12 it('test', () => {13 cy.visit('/');14 });15});16describe('Test', () => {17 it('test', () => {18 cy.visit('/');19 });20});21describe('Test', () => {22 it('test', () => {23 cy.visit('/');24 });25});26describe('Test', () => {27 it('test', () => {28 cy.visit('/');29 });30});31describe('Test', () => {32 it('test', () => {33 cy.visit('/');34 });35});36describe('Test', () => {37 it('test', () => {38 cy.visit('/');39 });40});41describe('Test', () => {42 it('test', () => {43 cy.visit('/');44 });45});46describe('Test', () => {47 it('test', () => {48 cy.visit('/');49 });50});51describe('Test', () => {
Using AI Code Generation
1describe('Test', () => {2 it('Test', () => {3 cy.getBaseUrl().then((baseUrl) => {4 console.log('baseUrl', baseUrl);5 });6 });7});8describe('Test', () => {9 it('Test', () => {10 cy.getBaseUrl().then((baseUrl) => {11 cy.visit(baseUrl);12 });13 });14});15describe('Test', () => {16 it('Test', () => {17 cy.getBaseUrl().then((baseUrl) => {18 cy.request({19 }).then((response) => {20 console.log('response', response);21 });22 });23 });24});25describe('Test', () => {26 it('Test', () => {27 cy.getBaseUrl().then((baseUrl) => {28 cy.request({29 }).then((response) => {30 console.log('response', response);31 });32 });33 });34});35describe('Test', () => {36 it('Test', () => {37 cy.getBaseUrl().then((baseUrl) => {38 cy.request({39 }).then((response) => {40 console.log('response', response);41 });42 });43 });44});45describe('Test', () => {46 it('Test', () => {47 cy.getBaseUrl().then((baseUrl) => {48 cy.request({
Cypress is a renowned Javascript-based open-source, easy-to-use end-to-end testing framework primarily used for testing web applications. Cypress is a relatively new player in the automation testing space and has been gaining much traction lately, as evidenced by the number of Forks (2.7K) and Stars (42.1K) for the project. LambdaTest’s Cypress Tutorial covers step-by-step guides that will help you learn from the basics till you run automation tests on LambdaTest.
You can elevate your expertise with end-to-end testing using the Cypress automation framework and stay one step ahead in your career by earning a Cypress certification. Check out our Cypress 101 Certification.
Watch this 3 hours of complete tutorial to learn the basics of Cypress and various Cypress commands with the Cypress testing at LambdaTest.
Get 100 minutes of automation test minutes FREE!!