How to use getRequest method in Cypress

Best JavaScript code snippet using cypress

Api.js

Source:Api.js Github

copy

Full Screen

...114 });115 },116 // 로그아웃117 getLogout: async() => {118 return await getRequest('/auth/logout');119 },120 // 아이디 중복 확인121 getDoubleCheckId: async(loginId) => {122 return await getRequest('/auth/doubleId', { loginId });123 },124 // 이메일 인증 번호 전송125 getEmail: async(email) => {126 return await getRequest('/auth/email', { email });127 },128 // 비밀번호 재설정 이메일 인증 전송129 getResetPasswordEmail: async(email) => {130 return await getRequest('/auth/email/password', { email });131 },132 // 이메일 인증 번호 확인133 postEmail: async(emailId, authStr) => {134 return await postJsonReqest('/auth/email', { emailId, authStr });135 },136 // 비밀번호 재설정137 postPassword: async(loginId, changePassword) => {138 return await postJsonReqest('/auth/password', { loginId, changePassword });139 },140 // User--------------------------------------------------------------------------141 // 회원가입142 postUser: async(user_data) => {143 return await postJsonReqest('/user', user_data);144 },145 // 회원정보 수정146 postUpdateUser: async(147 userId,148 user_image,149 user_introduction,150 user_github,151 user_blog,152 user_position153 ) => {154 return await postJsonReqest(`/user/${userId}`, {155 user_image,156 user_introduction,157 user_github,158 user_blog,159 user_position160 });161 },162 // 회원정보 조회163 getReaduser: async(userId) => {164 return await getRequest(`/user/${userId}`);165 },166 // 사용자 LoginId검색167 getUserLoginId: async(loginId) => {168 return await getRequest('/user/search/loginId', { loginId });169 },170 // 교수님 리스트 조회171 getProfessors: async() => {172 return await getRequest('/user/professors');173 },174 // 사용자 참가 프로젝트 리스트 조회175 getProjectInUser: async(userId, pageNum, pageCount) => {176 return await getRequest(`/user/${userId}/projects`, { pageNum, pageCount });177 },178 // 내가 작성한 팀원모집글 조회179 getUserRecruitment: async(userId, pageNum, pageCount) => {180 return await getRequest(`/user/${userId}/recruitment`, {181 pageNum,182 pageCount183 });184 },185 // 회원 탈퇴186 deleteUser: async(userId) => {187 return await deleteJsonReqest(`/user/${userId}`);188 },189 // Projects--------------------------------------------------------------------------------190 // 프로젝트 생성191 postProject: async(project) => {192 return await postJsonReqest('/project', project);193 },194 // 프로젝트 수정195 postUpdateProject: async(projectId, project) => {196 return await postJsonReqest(`/project/${projectId}`, project);197 },198 // 프로젝트 상세조회199 getProject: async(projectId) => {200 return await getRequest(`/project/${projectId}`);201 },202 // 프로젝트 전체조회203 getAllProject: async(pageNum, pageCount) => {204 return await getRequest('/project', { pageNum, pageCount });205 },206 // 전체 프로젝트 개수 조회207 getAllProjectCount: async() => {208 return await getRequest('/project-count');209 },210 // 프로젝트 조회수 증가211 getHit: async(projectId) => {212 return await getRequest(`/project/${projectId}/hit`);213 },214 // 프로젝트 전체 기술스택 리스트 조회215 getStacks: async() => {216 const stack = await getRequest('/project/tags');217 return await getRequest('/project/tags');218 },219 // 프로젝트 카테고리 리스트 조회220 getCategorys: async() => {221 return await getRequest('/project/categorys');222 },223 // 프로젝트 과목년도 리스트 조회224 getYears: async() => {225 return await getRequest('/project/subject-years');226 },227 // 프로젝트 과목리스트 조회228 getSubjects: async() => {229 return await getRequest('/project/subjects');230 },231 // 프로젝트 정렬 메뉴 조회232 getMenus: () => {233 return ['최신순', '좋아요순', '조회순'];234 },235 // 프로젝트 태그 검색236 getProjectTags: async(tagId) => {237 return await getRequest(`/project/search/tag?tagId=${tagId}`);238 },239 // 카테고리별 프로젝트 조회240 getProjectInCategory: async(categoryId, pageNum, pageCount) => {241 const response = await getRequest('/project/search/category', {242 categoryId,243 pageNum,244 pageCount245 });246 return response.data;247 },248 // 프로젝트 검색249 postProjectSearch: async(pageNum, pageCount, project) => {250 return await postJsonReqest(251 `/project/search/?pageNum=${pageNum}&pageCount=${pageCount}`,252 project253 );254 },255 // 프로젝트 삭제256 deleteProject: async(projectId) => {257 return await deleteJsonReqest(`/project/${projectId}`);258 },259 // Follow------------------------------------------------------------------------------------260 // 팔로우261 getFollow: async(targetId) => {262 return await getRequest('/user/follow', { targetId });263 },264 // 팔로우 취소265 getUnfollow: async(targetId) => {266 return await getRequest('/user/unfollow', { targetId });267 },268 // 팔로워 리스트 조회269 getFollowerList: async(userId) => {270 return await getRequest(`/user/${userId}/followers`);271 },272 // 팔로잉 리스트 조회273 getFollowingList: async(userId) => {274 return await getRequest(`/user/${userId}/followings`);275 },276 // likes------------------------------------------------------------------------------------277 // 프로젝트 좋아요 여부 확인278 getProjectIsLike: async(projectId) => {279 return await getRequest('/project/isLike', { projectId });280 },281 // 프로젝트 좋아요282 getProjectLike: async(projectId) => {283 return await getRequest('/project/like', { projectId });284 },285 // 프로젝트 좋아요 취소286 getProjectUnlike: async(projectId) => {287 return await getRequest('/project/unlike', { projectId });288 },289 // 사용자의 좋아요한 프로젝트 리스트 조회290 getLikedProject: async(userId, pageNum, pageCount) => {291 return await getRequest(`/user/${userId}/like-projects`, {292 pageNum,293 pageCount294 });295 },296 // Posts------------------------------------------------------------------------------------297 // 게시글 생성298 getCreatePosting: async(projectId, post_title, post_content) => {299 return await postJsonReqest(`/project/${projectId}/post`, {300 post_title,301 post_content302 });303 },304 // 게시글 수정305 postUpdatePosting: async(projectId, postId, postObject) => {306 return await postJsonReqest(307 `/project/${projectId}/post/${postId}`,308 postObject309 );310 },311 // 게시글 삭제 -> 아직 구현 X312 deletePosting: async(projectId, postId) => {313 return await deleteJsonReqest(`/project/${projectId}/post/${postId}`);314 },315 // 게시글 조회316 getReadPosting: async(projectId, postId) => {317 return await getRequest(`/project/${projectId}/post/${postId}`);318 },319 // 게시글 목록 조회320 getPostingList: async(projectId) => {321 return await getRequest(`/project/${projectId}/post-list`);322 },323 // Comments-----------------------------------------------------------------------------------324 // 프로젝트에 댓글 / 대댓글 등록325 postComment: async(326 projectId,327 comment_content,328 comment_depth,329 comment_parent330 ) => {331 return await postJsonReqest(`/project/${projectId}/comment`, {332 comment_content,333 comment_depth,334 comment_parent335 });336 },337 // 프로젝트에 댓글 / 대댓글 수정338 postUpdateComment: async(projectId, commentId, comment_content) => {339 return await postJsonReqest(`/project/${projectId}/comment/${commentId}`, {340 comment_content341 });342 },343 // 프로젝트에 댓글 / 대댓글 삭제344 deleteComment: async(projectId, commentId) => {345 return await deleteJsonReqest(`/project/${projectId}/comment/${commentId}`);346 },347 // 프로젝트의 댓글 / 대댓글 조회348 getReadComment: async(projectId) => {349 return await getRequest(`/project/${projectId}/comment/`);350 },351 // Files--------------------------------------------------------------------------------------352 getReadFile: async(fileData) => {353 return await postFormReqest(`/file/upload`, fileData);354 },355 getReadFilePDF: async(fileData) => {356 return await postFormReqest(`/file/uploadPDF`, fileData);357 },358 // Recruitment--------------------------------------------------------------------------------359 postTeam: async(Team) => {360 return await postJsonReqest('/recruitment', Team);361 },362 getAllTeam: async(pageNum, pageCount) => {363 const response = await getRequest('/recruitment', { pageNum, pageCount });364 return response.data;365 },366 getTeam: async(Teamid) => {367 return await getRequest(`/recruitment/${Teamid}`);368 },369 getTeamEnd: async(Teamid) => {370 return await getRequest(`/recruitment/${Teamid}/end`);371 },372 getTeamApplication: async(Teamid) => {373 return await getRequest(`/recruitment/${Teamid}/application`);374 },375 postTeamUpdate: async(Teamid, Team) => {376 return await postJsonReqest(`/recruitment/${Teamid}`, Team);377 },378 deleteTeam: async(Teamid) => {379 return await deleteJsonReqest(`/recruitment/${Teamid}`);380 },381 getSearch: async(pageNum, pageCount, keyword, subject) => {382 const response = await getRequest(383 `/recruitment/search?pageNum=${pageNum}&pageCount=${pageCount}&keyword=${keyword}&subject=${subject}`384 );385 return response.data;386 },387 getTeamcancelApplication: async(Teamid) => {388 return await deleteJsonReqest(`/recruitment/${Teamid}/application`);389 },390 getTeamList: async(Teamid) => {391 return await getRequest(`/recruitment/${Teamid}/application-list`);392 },393 getisApplication: async(Teamid) => {394 return await getRequest(`/recruitment/${Teamid}/isApplication`);395 },396 getOK: async(Teamid, array) => {397 return await getRequest(`/recruitment/${Teamid}/accept?userId=${array}`);398 },399 getRefuse: async(Teamid, array) => {400 return await getRequest(`/recruitment/${Teamid}/refuse?userId=${array}`);401 }402 // Notification———————————————————————————————————————403};...

Full Screen

Full Screen

PostModel.js

Source:PostModel.js Github

copy

Full Screen

1const sql = require("./ConnectMySQL");2require('dotenv').config();3const { GetUUID, GetProfileById } = require('./AuthModel');4const { CreateContentPromise, GetContentByPostPromise } = require('./ContentModel');5const { CreateImagePromise, GetImageByPostPromise, GetImageByIDPromise } = require('./ImageModel');6const { GetVoteByPostPromise } = require('./VoteModel');7const { GetCommentByPostPromise } = require('./CommentModel');8const GetPostPromise = async (getRequest) => {9 return new Promise((resolve, reject) => {10 sql.query(11 `SELECT tb_post.postID, tb_post.userID, tb_post.postCreatedAt12 FROM tb_post13 ORDER BY tb_post.postCreatedAt DESC `,14 [getRequest.start, getRequest.limit],15 (err, data) => {16 if (err) {17 reject(new Error("Failed to get post"));18 } else {19 data.forEach(item => {20 item.postCreatedAt = item.postCreatedAt.toString();21 });22 resolve(data);23 }24 }25 );26 })27};28module.exports.Get = async (getRequest, result) => {29 try {30 const postResponse = await GetPostPromise(getRequest);31 for (let i = 0; i < postResponse.length; i++) {32 const item = postResponse[i];33 const [contentResponse, imageResponse, userResponse, voteResponse] = await Promise.all([34 GetContentByPostPromise({ postID: item.postID }),35 GetImageByPostPromise({ postID: item.postID }),36 GetProfileById({ userID: item.userID }),37 GetVoteByPostPromise({ postID: item.postID }),38 ]);39 item.voteAVG = voteResponse.reduce((acc, item) => { return (acc + item.voteValue) }, 0) / voteResponse.length || 0;40 item.content = contentResponse;41 item.vote = voteResponse;42 item.user = userResponse;43 item.image = imageResponse;44 }45 result(null, postResponse);46 } catch (error) {47 result(error, null);48 }49};50const GetPostByUserPromise = async (getRequest) => {51 return new Promise((resolve, reject) => {52 sql.query(53 `SELECT tb_post.postID, tb_post.userID, tb_post.postCreatedAt54 FROM tb_post55 WHERE tb_post.userID = ?56 ORDER BY tb_post.postCreatedAt DESC `,57 [getRequest.userID, getRequest.start, getRequest.limit],58 (err, data) => {59 if (err) {60 reject(new Error("Failed to get post"));61 } else {62 data.forEach(item => {63 item.postCreatedAt = item.postCreatedAt.toString();64 });65 resolve(data);66 }67 }68 );69 })70};71module.exports.GetByUser = async (getRequest, result) => {72 try {73 const postResponse = await GetPostByUserPromise(getRequest);74 for (let i = 0; i < postResponse.length; i++) {75 const item = postResponse[i];76 const [contentResponse, imageResponse, userResponse, voteResponse] = await Promise.all([77 GetContentByPostPromise({ postID: item.postID }),78 GetImageByPostPromise({ postID: item.postID }),79 GetProfileById({ userID: item.userID }),80 GetVoteByPostPromise({ postID: item.postID }),81 ]);82 item.voteAVG = voteResponse.reduce((acc, item) => { return (acc + item.voteValue) }, 0) / voteResponse.length || 0;83 item.content = contentResponse;84 item.vote = voteResponse;85 item.user = userResponse;86 item.image = imageResponse;87 }88 result(null, postResponse);89 } catch (error) {90 result(error, null);91 }92};93const GetPostByIDPromise = async (getRequest) => {94 return new Promise((resolve, reject) => {95 sql.query(96 `SELECT tb_post.postID, tb_post.userID, tb_post.postCreatedAt97 FROM tb_post98 WHERE tb_post.postID = ?`,99 [getRequest.postID],100 (err, data) => {101 if (err) {102 reject(new Error("Failed to get post"));103 } else {104 data.forEach(item => {105 item.postCreatedAt = item.postCreatedAt.toString();106 });107 resolve(data);108 }109 }110 );111 })112};113module.exports.GetByID = async (getRequest, result) => {114 try {115 const postResponse = await GetPostByIDPromise(getRequest);116 for (let i = 0; i < postResponse.length; i++) {117 const item = postResponse[i];118 const [contentResponse, imageResponse, userResponse, voteResponse] = await Promise.all([119 GetContentByPostPromise({ postID: item.postID }),120 GetImageByPostPromise({ postID: item.postID }),121 GetProfileById({ userID: item.userID }),122 GetVoteByPostPromise({ postID: item.postID }),123 ]);124 item.voteAVG = voteResponse.reduce((acc, item) => { return (acc + item.voteValue) }, 0) / voteResponse.length;125 item.content = contentResponse;126 item.vote = voteResponse;127 item.user = userResponse;128 item.image = imageResponse;129 }130 result(null, postResponse);131 } catch (error) {132 result(error, null);133 }134};135const CreatePostPromise = async (getRequest) => {136 return new Promise((resolve, reject) => {137 sql.query(138 `INSERT INTO tb_post (tb_post.postID, tb_post.userID, tb_post.postCreatedAt) VALUES (?, ?, ?)`,139 [getRequest.uuid, getRequest.userID, getRequest.postCreatedAt],140 (err, data) => {141 if (err) {142 reject(new Error("Failed to upload post"));143 } else if (data) {144 resolve({ postID: getRequest.uuid, ...data });145 }146 }147 );148 })149}150module.exports.Create = async (getRequest, result) => {151 try {152 console.log("tạo", getRequest);153 const uuid = await GetUUID();154 if (!getRequest.postCreatedAt) {155 getRequest.postCreatedAt = new Date();156 }157 const postResponse = await CreatePostPromise({ ...getRequest, uuid });158 if (getRequest.contentText && getRequest.filepath) {159 console.log("đủ ảnh, chữ");160 const [contentResponse, imageResponse] = await Promise.all([161 CreateContentPromise({ ...getRequest, postID: postResponse.postID }),162 CreateImagePromise({ ...getRequest, postID: postResponse.postID }),163 ]);164 result(null, { postResponse, contentResponse });165 } else {166 if (getRequest.contentText) {167 console.log("chỉ chữ");168 const contentResponse = await CreateContentPromise({ ...getRequest, postID: postResponse.postID });169 result(null, { postResponse, contentResponse });170 }171 if (getRequest.filepath) {172 console.log("chỉ ảnh")173 const imageResponse = await CreateImagePromise({ ...getRequest, postID: postResponse.postID });174 result(null, { postResponse, imageResponse });175 }176 }177 } catch (error) {178 result(error, null);179 }180};181module.exports.DeleteByID = async (getRequest, result) => {182 sql.query(183 `DELETE FROM tb_post WHERE tb_post.postID = ?`,184 [getRequest.postID],185 (err, data) => {186 if (err) {187 result(err, null)188 } else {189 result(null, { ...data });190 }191 }192 );...

Full Screen

Full Screen

champion-model.js

Source:champion-model.js Github

copy

Full Screen

1var api_key = 'b9f2effe-c90e-4633-b36b-5716684ccbac' //should these lines have semi-colons? -tcj2var FREE_CHAMPS_URL= 'https://na.api.pvp.net/api/lol/na/v1.2/champion?freeToPlay=true&api_key=' + api_key //should these lines have semi-colons? -tcj3var CHALLENGER_URL = 'https://na.api.pvp.net/api/lol/na/v2.5/league/challenger?type=RANKED_SOLO_5x5&api_key=' + api_key //should these lines have semi-colons? -tcj4var MH_URL_1 = 'https://na.api.pvp.net/api/lol/na/v2.2/matchhistory/'5var MH_URL_2 = '?api_key=' + api_key //should these lines have semi-colons? -tcj6var ITEM_URL_1 = 'https://global.api.pvp.net/api/lol/static-data/na/v1.2/item/'7var ITEM_URL_2 = '?itemData=image&api_key=' + api_key8var CHAMP_URL_1 = 'https://global.api.pvp.net/api/lol/static-data/na/v1.2/champion/'9var CHAMP_URL_2 = '?api_key=' + api_key10var VERSION_URL = 'https://global.api.pvp.net/api/lol/static-data/na/v1.2/versions?api_key=' + api_key11var STATUS_OK = 200;12var XMLHttpRequest = require('xhr2')13var fs = require('fs')14exports.freeChamps = function(callback) {15 var getRequest = new XMLHttpRequest();16 getRequest.addEventListener('load', function(event){17 if (getRequest.status != STATUS_OK){18 callback(getRequest.responseText);19 }20 else{21 var JSONPosts = getRequest.responseText;22 var parsedPosts = JSON.parse(JSONPosts);23 return callback(null, parsedPosts);24 }25 });26 getRequest.open('GET', FREE_CHAMPS_URL);27 getRequest.send();28},29exports.challengers = function(callback,champs, champItems) {30 var getRequest = new XMLHttpRequest();31 getRequest.addEventListener('load', function(event, champs, champItems){32 if (getRequest.status != STATUS_OK){33 console.log(getRequest)34 callback(getRequest.responseText);35 }36 else{37 var JSONPosts = getRequest.responseText;38 var parsedPosts = JSON.parse(JSONPosts);39 return callback(null, parsedPosts, champs, champItems);40 }41 });42 getRequest.open('GET', CHALLENGER_URL);43 getRequest.send();44},45exports.matchHistory = function(callback, summonerID) {46 var getRequest = new XMLHttpRequest();47 getRequest.addEventListener('load', function(event){48 if (getRequest.status != STATUS_OK){49 callback(getRequest.responseText);50 }51 else{52 var JSONPosts = getRequest.responseText;53 var parsedPosts = JSON.parse(JSONPosts);54 return callback(null, parsedPosts);55 }56 });57 getRequest.open('GET', MH_URL_1 + summonerID + MH_URL_2);58 getRequest.send();59},60exports.getItem = function(callback, itemID){61 var getRequest = new XMLHttpRequest();62 getRequest.addEventListener('load', function(event){63 if (getRequest.status != STATUS_OK){64 callback(getRequest.responseText);65 }66 else{67 var JSONPosts = getRequest.responseText;68 var parsedPosts = JSON.parse(JSONPosts);69 return callback(null, parsedPosts);70 }71 });72 getRequest.open('GET', ITEM_URL_1 + itemID + ITEM_URL_2);73 getRequest.send();74},75exports.getChamp = function(callback, champID){76 var getRequest = new XMLHttpRequest();77 getRequest.addEventListener('load', function(event){78 if (getRequest.status != STATUS_OK){79 callback(getRequest.responseText);80 }81 else{82 var JSONPosts = getRequest.responseText;83 var parsedPosts = JSON.parse(JSONPosts);84 return callback(null, parsedPosts);85 }86 });87 getRequest.open('GET', CHAMP_URL_1 + champID + CHAMP_URL_2);88 getRequest.send();89},90exports.version = function(callback) {91 var getRequest = new XMLHttpRequest();92 getRequest.addEventListener('load', function(event){93 if (getRequest.status != STATUS_OK){94 callback(getRequest.responseText);95 }96 else{97 var JSONPosts = getRequest.responseText;98 var parsedPosts = JSON.parse(JSONPosts);99 return callback(null, parsedPosts);100 }101 });102 getRequest.open('GET', VERSION_URL);103 getRequest.send();104},105exports.postFatJSON = function(fatJSON) {106 fatJSON = JSON.stringify(fatJSON)107 fs.writeFile('FatJSON.json', fatJSON)...

Full Screen

Full Screen

CommentModel.js

Source:CommentModel.js Github

copy

Full Screen

1const sql = require("./ConnectMySQL");2const { GetUUID } = require('./AuthModel');3module.exports.GetByID = async (getRequest, result) => {4 sql.query(5 `SELECT tb_comment.commentID, tb_comment.postID, tb_comment.commentText, tb_comment.commentCreatedAt, tb_comment.commentParentID, tb_comment.userID6 FROM tb_comment7 WHERE tb_comment.commentID = ?`,8 [getRequest.commentID],9 (err, data) => {10 if (err) {11 result(err, null);12 } else {13 result(null, data);14 }15 }16 );17};18module.exports.GetByPost = async (getRequest, result) => {19 sql.query(20 `SELECT tb_comment.*, tb_profile.userFirstname, tb_profile.userLastname, tb_image.imageSource21 FROM tb_comment, tb_profile, tb_image22 WHERE tb_comment.userID = tb_profile.userID AND tb_profile.imageID = tb_image.imageID AND tb_comment.postID = ?23 ORDER BY tb_comment.commentCreatedAt ASC`,24 [getRequest.postID],25 (err, data) => {26 if (err) {27 result(err, null)28 } else {29 const dataResponse = [];30 data.forEach(comment => {31 comment.imageSource = process.env.BASE_URL + comment.imageSource;32 if (comment.commentID == comment.commentParentID) {33 comment.replys = [];34 dataResponse.push(comment);35 } else {36 dataResponse.find(item => item.commentID == comment.commentParentID).replys.push(comment);37 }38 })39 result(null, dataResponse);40 }41 }42 );43};44module.exports.GetCommentByPostPromise = async (getRequest) => {45 return new Promise((resolve, reject) => {46 sql.query(47 `SELECT tb_comment.commentID, tb_comment.postID, tb_comment.commentText, tb_comment.commentCreatedAt, tb_comment.commentParentID, tb_comment.userID48 FROM tb_comment49 WHERE tb_comment.postID = ?50 ORDER BY tb_comment.commentCreatedAt ASC`,51 [getRequest.postID],52 (err, data) => {53 if (err) {54 reject(err)55 } else {56 resolve(data);57 }58 }59 );60 })61};62module.exports.Create = async (getRequest, result) => {63 const uuid = await GetUUID();64 if (getRequest.commentParentID == null) {65 getRequest.commentParentID = uuid;66 }67 if (getRequest.commentCreatedAt == null) {68 getRequest.commentCreatedAt = new Date();69 }70 sql.query(71 `INSERT INTO tb_comment (tb_comment.commentID, tb_comment.commentText, tb_comment.commentCreatedAt, tb_comment.postID, tb_comment.commentParentID, tb_comment.userID) VALUES (?, ?, ?, ?, ?, ?)`,72 [uuid, getRequest.commentText, getRequest.commentCreatedAt, getRequest.postID, getRequest.commentParentID, getRequest.userID],73 (err, data) => {74 if (err) {75 result(err, null)76 } else {77 result(null, { commentID: uuid, ...data });78 }79 }80 );81};82module.exports.UpdateByID = async (getRequest, result) => {83 sql.query(84 `UPDATE tb_comment 85 SET tb_comment.commentText = ?86 WHERE tb_comment.commentID = ?`,87 [getRequest.commentText, getRequest.commentID],88 (err, data) => {89 if (err) {90 result(err, null)91 } else {92 result(null, { ...data });93 }94 }95 );96};97module.exports.DeleteByID = async (getRequest, result) => {98 sql.query(99 `DELETE FROM tb_comment WHERE tb_comment.commentID = ?`,100 [getRequest.commentID],101 (err, data) => {102 if (err) {103 result(err, null)104 } else {105 result(null, { ...data });106 }107 }108 );...

Full Screen

Full Screen

ImageModel.js

Source:ImageModel.js Github

copy

Full Screen

1const sql = require("./ConnectMySQL");2const { GetUUID } = require('./AuthModel');3const upload = require('../multer');4module.exports.GetByID = async (getRequest, result) => {5 sql.query(6 `SELECT tb_image.imageID, tb_image.imageSource, tb_image.postID 7 FROM tb_image8 WHERE tb_image.imageID = ?`,9 [getRequest.imageID],10 (err, data) => {11 if (err) {12 result(err, null)13 } else {14 result(null, data);15 }16 }17 );18};19module.exports.GetByPost = async (getRequest, result) => {20 sql.query(21 `SELECT tb_image.imageID, tb_image.imageSource, tb_image.postID 22 FROM tb_image23 WHERE tb_image.imageID = ?`,24 [getRequest.postID],25 (err, data) => {26 if (err) {27 result(err, null)28 } else {29 result(null, data);30 }31 }32 );33};34module.exports.Create = async (getRequest, result) => {35 const uuid = await GetUUID();36 sql.query(37 `INSERT INTO tb_image (tb_image.imageID, tb_image.imageSource, tb_image.postID) VALUES (?, ?, ?)`,38 [uuid, getRequest.imageSource, getRequest.postID],39 (err, data) => {40 if (err) {41 result(err, null)42 } else {43 result(null, { imageID: uuid, ...data });44 }45 }46 );47};48module.exports.UpdateByID = async (getRequest, result) => {49 sql.query(50 `UPDATE tb_image51 SET tb_image.imageSource = ?52 WHERE tb_image.imageID = ?`,53 [getRequest.imageSource, getRequest.imageID],54 (err, data) => {55 if (err) {56 result(err, null)57 } else {58 result(null, { ...data });59 }60 }61 );62};63module.exports.DeleteByID = async (getRequest, result) => {64 sql.query(65 `DELETE FROM tb_image66 WHERE tb_image.imageID = ?`,67 [getRequest.imageID],68 (err, data) => {69 if (err) {70 result(err, null)71 } else {72 result(null, { ...data });73 }74 }75 );76};77module.exports.CreateImagePromise = async (getRequest) => {78 const uuid = await GetUUID();79 return new Promise((resolve, reject) => {80 sql.query(81 `INSERT INTO tb_image (tb_image.imageID, tb_image.imageSource, tb_image.postID) VALUES (?, ?, ?)`,82 [uuid, getRequest.filepath, getRequest.postID],83 (err, data) => {84 if (err) {85 reject(new Error("Error upload image"));86 } else {87 resolve({ imageID: uuid, ...data });88 }89 }90 );91 })92};93module.exports.GetImageByPostPromise = async (getRequest) => {94 return new Promise((resolve, reject) => {95 sql.query(96 `SELECT tb_image.imageID, tb_image.imageSource97 FROM tb_image98 WHERE tb_image.postID = ?`,99 [getRequest.postID],100 (err, data) => {101 if (err) {102 reject(new Error("Error get image"));103 } else {104 data.forEach(image => {105 image.imageSource = process.env.BASE_URL + image.imageSource;106 })107 resolve(data);108 }109 }110 );111 })112};113module.exports.GetImageByIDPromise = async (getRequest) => {114 return new Promise((resolve, reject) => {115 sql.query(116 `SELECT tb_image.imageID, tb_image.imageSource117 FROM tb_image118 WHERE tb_image.imageID = ?`,119 [getRequest.imageID],120 (err, data) => {121 if (err) {122 reject(new Error("Error get image"));123 } else {124 resolve(data);125 }126 }127 );128 })...

Full Screen

Full Screen

VoteModel.js

Source:VoteModel.js Github

copy

Full Screen

1const sql = require("./ConnectMySQL");2const { GetUUID } = require('./AuthModel');3module.exports.GetByID = async (getRequest, result) => {4 sql.query(5 `SELECT tb_vote.voteID, tb_vote.voteValue, tb_vote.voteCreatedAt, tb_vote.postID, tb_vote.userID 6 FROM tb_vote7 WHERE tb_vote.voteID = ?`,8 [getRequest.voteID],9 (err, data) => {10 if (err) {11 result(err, null)12 } else {13 result(null, data);14 }15 }16 );17};18module.exports.GetByPost = async (getRequest, result) => {19 sql.query(20 `SELECT tb_vote.voteID, tb_vote.voteValue, tb_vote.voteCreatedAt, tb_vote.postID, tb_vote.userID 21 FROM tb_vote22 WHERE tb_vote.postID = ?23 ORDER BY tb_vote.voteCreatedAt DESC`,24 [getRequest.postID],25 (err, data) => {26 if (err) {27 result(err, null)28 } else {29 result(null, data);30 }31 }32 );33};34module.exports.GetVoteByPostPromise = async (getRequest, result) => {35 return new Promise((resolve, reject) => {36 sql.query(37 `SELECT tb_vote.voteID, tb_vote.voteValue, tb_vote.voteCreatedAt, tb_vote.postID, tb_vote.userID, tb_profile.userFirstname, tb_profile.userLastname 38 FROM tb_vote, tb_profile39 WHERE tb_vote.userID = tb_profile.userID AND tb_vote.postID = ?40 ORDER BY tb_vote.voteCreatedAt DESC`,41 [getRequest.postID],42 (err, data) => {43 if (err) {44 reject(err)45 } else {46 resolve(data);47 }48 }49 );50 })51};52module.exports.GetVoteByPostAndUserPromise = async (getRequest) => {53 return new Promise((resolve, reject) => {54 sql.query(55 `SELECT tb_vote.voteID, tb_vote.voteValue, tb_vote.voteCreatedAt, tb_vote.postID, tb_vote.userID 56 FROM tb_vote57 WHERE tb_vote.postID = ? AND tb_vote.userID = ?58 ORDER BY tb_vote.voteCreatedAt DESC`,59 [getRequest.postID, getRequest.userID],60 (err, data) => {61 if (err) {62 reject(err)63 } else {64 resolve(data);65 }66 }67 );68 })69};70module.exports.Create = async (getRequest, result) => {71 const uuid = await GetUUID();72 if (!getRequest.voteCreatedAt) {73 getRequest.voteCreatedAt = new Date().toISOString().slice(0, 19).replace('T', ' ');74 }75 sql.query(76 `INSERT INTO tb_vote (tb_vote.voteID, tb_vote.voteValue, tb_vote.voteCreatedAt, tb_vote.postID, tb_vote.userID ) VALUES (?, ?, ?, ?, ?)`,77 [uuid, getRequest.voteValue, getRequest.voteCreatedAt, getRequest.postID, getRequest.userID],78 (err, data) => {79 if (err) {80 result(err, null)81 } else {82 result(null, { voteID: uuid, ...data });83 }84 }85 );86};87module.exports.UpdateByID = async (getRequest, result) => {88 sql.query(89 `UPDATE tb_vote 90 SET tb_vote.voteValue = ?91 WHERE tb_vote.voteID = ?`,92 [getRequest.voteValue, getRequest.voteID],93 (err, data) => {94 if (err) {95 result(err, null)96 } else {97 result(null, { ...data });98 }99 }100 );101};102module.exports.DeleteByID = async (getRequest, result) => {103 sql.query(104 `DELETE FROM tb_vote WHERE tb_vote.voteID = ?`,105 [getRequest.voteID],106 (err, data) => {107 if (err) {108 result(err, null)109 } else {110 result(null, { ...data });111 }112 }113 );...

Full Screen

Full Screen

xpCGIVariables.jss

Source:xpCGIVariables.jss Github

copy

Full Screen

...20 function _get(name) {21 22 switch (name.toUpperCase()) {23 24 case "AUTH_TYPE": return facesContext.getExternalContext().getRequest().getAuthType();25 case "CONTENT_LENGTH": return facesContext.getExternalContext().getRequest().getContentLength();26 case "CONTENT_TYPE": return facesContext.getExternalContext().getRequest().getContentType();27 case "CONTEXT_PATH": return facesContext.getExternalContext().getRequest().getContextPath();28 case "GATEWAY_INTERFACE": return "CGI/1.1";29 case "HTTPS": return facesContext.getExternalContext().getRequest().isSecure() ? "ON" : "OFF";30 case "PATH_INFO": return facesContext.getExternalContext().getRequest().getPathInfo();31 case "PATH_TRANSLATED": return facesContext.getExternalContext().getRequest().getPathTranslated();32 case "QUERY_STRING": return facesContext.getExternalContext().getRequest().getQueryString();33 case "REMOTE_ADDR": return facesContext.getExternalContext().getRequest().getRemoteAddr();34 case "REMOTE_HOST": return facesContext.getExternalContext().getRequest().getRemoteHost();35 case "REMOTE_USER": return facesContext.getExternalContext().getRequest().getRemoteUser();36 case "REQUEST_METHOD": return facesContext.getExternalContext().getRequest().getMethod();37 case "REQUEST_SCHEME": return facesContext.getExternalContext().getRequest().getScheme();38 case "REQUEST_URI": return facesContext.getExternalContext().getRequest().getRequestURI();39 case "SCRIPT_NAME": return facesContext.getExternalContext().getRequest().getServletPath();40 case "SERVER_NAME": return facesContext.getExternalContext().getRequest().getServerName();41 case "SERVER_PORT": return facesContext.getExternalContext().getRequest().getServerPort();42 case "SERVER_PROTOCOL": return facesContext.getExternalContext().getRequest().getProtocol();43 case "SERVER_SOFTWARE": return facesContext.getExternalContext().getContext().getServerInfo();44 45 // these are not really CGI variables, but useful, so lets just add them for convenience46 case "HTTP_ACCEPT": return facesContext.getExternalContext().getRequest().getHeader("Accept");47 case "HTTP_ACCEPT_ENCODING": return facesContext.getExternalContext().getRequest().getHeader("Accept-Encoding");48 case "HTTP_ACCEPT_LANGUAGE": return facesContext.getExternalContext().getRequest().getHeader("Accept-Language");49 case "HTTP_CONNECTION": return facesContext.getExternalContext().getRequest().getHeader("Connection");50 case "HTTP_COOKIE": return facesContext.getExternalContext().getRequest().getHeader("Cookie");51 case "HTTP_HOST": return facesContext.getExternalContext().getRequest().getHeader("Host");52 case "HTTP_REFERER": return facesContext.getExternalContext().getRequest().getHeader("Referer");53 case "HTTP_USER_AGENT": return facesContext.getExternalContext().getRequest().getHeader("User-Agent");54 }55 }56 57 // ==========================================58 // expose the public interface of this module59 // ==========================================60 return {61 get: _get62 }...

Full Screen

Full Screen

ContentModel.js

Source:ContentModel.js Github

copy

Full Screen

1const sql = require("./ConnectMySQL");2const { GetUUID } = require('./AuthModel');3module.exports.GetByID = async (getRequest, result) => {4 sql.query(5 `SELECT tb_content.contentID, tb_content.contentText, tb_content.postID 6 FROM tb_content7 WHERE tb_content.contentID = ?`,8 [getRequest.contentID],9 (err, data) => {10 if (err) {11 result(err, null)12 } else {13 result(null, data);14 }15 }16 );17};18module.exports.GetByPost = async (getRequest, result) => {19 sql.query(20 `SELECT tb_content.contentID, tb_content.contentText, tb_content.postID 21 FROM tb_content22 WHERE tb_content.postID = ?`,23 [getRequest.postID],24 (err, data) => {25 if (err) {26 result(err, null)27 } else {28 data.forEach(item => {29 item.imageSource = process.env.BASE_URL + item.imageSource;30 })31 result(null, data);32 }33 }34 );35};36module.exports.Create = async (getRequest, result) => {37 const uuid = await GetUUID();38 sql.query(39 `INSERT INTO tb_content (tb_content.contentID, tb_content.contentText, tb_content.postID) VALUES (?, ?, ?)`,40 [uuid, getRequest.contentText, getRequest.postID],41 (err, data) => {42 if (err) {43 result(err, null)44 } else {45 result(null, { imageID: uuid, ...data });46 }47 }48 );49};50module.exports.UpdateByID = async (getRequest, result) => {51 sql.query(52 `UPDATE tb_content 53 SET tb_content.contentText = ?54 WHERE tb_content.contentID = ?`,55 [getRequest.contentText, getRequest.contentID],56 (err, data) => {57 if (err) {58 result(err, null)59 } else {60 result(null, { ...data });61 }62 }63 );64};65module.exports.DeleteByID = async (getRequest, result) => {66 sql.query(67 `DELETE FROM tb_content WHERE tb_content.contentID = ?`,68 [getRequest.contentID],69 (err, data) => {70 if (err) {71 result(err, null)72 } else {73 result(null, { ...data });74 }75 }76 );77};78module.exports.CreateContentPromise = async (getRequest) => {79 const uuid = await GetUUID();80 return new Promise((resolve, reject) => {81 sql.query(82 `INSERT INTO tb_content (tb_content.contentID, tb_content.contentText, tb_content.postID) VALUES (?, ?, ?)`,83 [uuid, getRequest.contentText, getRequest.postID],84 (err, data) => {85 if (err) {86 reject(new Error("Failed to upload content"));87 } else {88 resolve({ contentID: uuid, ...data });89 }90 }91 );92 })93};94module.exports.GetContentByPostPromise = async (getRequest) => {95 return new Promise((resolve, reject) => {96 sql.query(97 `SELECT tb_content.contentID, tb_content.contentText98 FROM tb_content99 WHERE tb_content.postID = ?`,100 [getRequest.postID],101 (err, data) => {102 if (err) {103 reject(new Error("Failed to get content"));104 } else {105 resolve(data);106 }107 }108 );109 })...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1describe('My First Test', function() {2 it('Gets, types and asserts', function() {3 cy.contains('type').click()4 cy.url().should('include', '/commands/actions')5 cy.get('.action-email')6 .type('

Full Screen

Using AI Code Generation

copy

Full Screen

1describe('My First Test', function() {2 it('Visits the Kitchen Sink', function() {3 cy.contains('type').click()4 cy.url().should('include', '/commands/actions')5 cy.get('.action-email')6 .type('

Full Screen

Using AI Code Generation

copy

Full Screen

1describe('My First Test', () => {2 it('Visits the Kitchen Sink', () => {3 cy.contains('type').click()4 cy.url().should('include', '/commands/actions')5 cy.get('.action-email')6 .type('

Full Screen

Using AI Code Generation

copy

Full Screen

1describe('My First Test', function() {2 it('Does not do much!', function() {3 .its('body')4 .should('include', {5 })6 })7})8describe('My First Test', function() {9 it('Does not do much!', function() {10 })11 .its('body')12 .should('include', { title: 'foo' })13 })14})15describe('My First Test', function() {16 it('Does not do much!', function() {17 })18 .its('body')19 .should('include', { title: 'foo' })20 })21})22describe('My First Test', function() {23 it('Does not do much!', function() {24 .its('body')25 .should('include', {})26 })27})28describe('My First Test', function() {29 it('Does not do much!', function() {

Full Screen

Using AI Code Generation

copy

Full Screen

1describe('My First Test', function() {2 it('Does not do much!', function() {3 })4})5Cypress.Commands.add('login', (email, password) => { 6 cy.request({7 body: {8 user: {9 }10 }11 }).its('body').then((body) => {12 window.localStorage.setItem('jwt', body.user.token)13 })14})15describe('Login', function() {16 it('should login with valid credentials', function() {17 cy.login('

Full Screen

Using AI Code Generation

copy

Full Screen

1describe('My First Test', function() {2 it('Does not do much!', function() {3 })4})5{6}7{8}9{10}11{12}13{14}15{16}17{18}19{

Full Screen

Using AI Code Generation

copy

Full Screen

1describe('My First Test', function() {2 it('Gets, logs and asserts', function() {3 .its('body')4 .should('include', { id: 1 })5 })6})7describe('My First Test', function() {8 it('Gets, logs and asserts', function() {9 .its('body')10 .should('include', { id: 1 })11 .then((response) => {12 console.log(response)13 })14 })15})16describe('My First Test', function() {17 it('Gets, logs and asserts', function() {18 .its('body')19 .should('include', { id: 1 })20 .then((response) => {21 expect(response).to.have.property('title', 'sunt aut facere repellat provident occaecati excepturi optio reprehenderit')22 })23 })24})25describe('My First Test', function() {26 it('Gets, logs and asserts', function() {27 .its('body')28 .should('include', { id: 1 })29 .then((response) => {30 expect(response).to.have.property('title', 'sunt aut facere repellat provident occaecati excepturi optio reprehenderit')31 expect(response).to.have.property('body', 'quia et suscipit\nsuscipit recusandae consequuntur expedita et cum\nreprehenderit molestiae ut ut quas totam\nnostrum rerum est autem sunt rem eveniet architecto

Full Screen

Using AI Code Generation

copy

Full Screen

1describe('Test GET request', function() {2 it('Get request', function() {3 expect(response.status).to.eq(200)4 cy.log(JSON.stringify(response.body))5 })6 })7})8describe('Test GET request', function() {9 it('Get request', function() {10 expect(response.status).to.eq(200)11 cy.log(JSON.stringify(response.body))12 })13 })14})15describe('Test GET request', function() {16 it('Get request', function() {17 expect(response.status).to.eq(200)18 cy.log(JSON.stringify(response.body))19 })20 })21})22describe('Test GET request', function() {23 it('Get request', function() {24 expect(response.status).to.eq(200)25 cy.log(JSON.stringify(response.body))26 })27 })28})29describe('Test GET request', function() {30 it('Get request', function() {31 expect(response.status).to.eq(200)32 cy.log(JSON.stringify(response.body))33 })34 })35})

Full Screen

Cypress Tutorial

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.

Chapters:

  1. What is Cypress? -
  2. Why Cypress? - Learn why Cypress might be a good choice for testing your web applications.
  3. Features of Cypress Testing - Learn about features that make Cypress a powerful and flexible tool for testing web applications.
  4. Cypress Drawbacks - Although Cypress has many strengths, it has a few limitations that you should be aware of.
  5. Cypress Architecture - Learn more about Cypress architecture and how it is designed to be run directly in the browser, i.e., it does not have any additional servers.
  6. Browsers Supported by Cypress - Cypress is built on top of the Electron browser, supporting all modern web browsers. Learn browsers that support Cypress.
  7. Selenium vs Cypress: A Detailed Comparison - Compare and explore some key differences in terms of their design and features.
  8. Cypress Learning: Best Practices - Take a deep dive into some of the best practices you should use to avoid anti-patterns in your automation tests.
  9. How To Run Cypress Tests on LambdaTest? - Set up a LambdaTest account, and now you are all set to learn how to run Cypress tests.

Certification

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.

YouTube

Watch this 3 hours of complete tutorial to learn the basics of Cypress and various Cypress commands with the Cypress testing at LambdaTest.

Run Cypress 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