From 5aa131808f62f11fa3e51eae3dc1c43c1e399516 Mon Sep 17 00:00:00 2001 From: sundowndev Date: Mon, 3 Sep 2018 15:37:19 +0200 Subject: [PATCH] Remove unused classes --- src/ApiClient.js | 70 --------------------------------------------- src/JsonResponse.js | 19 ------------ 2 files changed, 89 deletions(-) delete mode 100644 src/ApiClient.js delete mode 100644 src/JsonResponse.js diff --git a/src/ApiClient.js b/src/ApiClient.js deleted file mode 100644 index ae8e389..0000000 --- a/src/ApiClient.js +++ /dev/null @@ -1,70 +0,0 @@ -"use strict"; - -const request = require('request'); -const async = require('async'); - -export default function ApiClient() { - this.ApiUrl = ''; -} - -ApiClient.prototype.setApiUrl = function (url) { - ApiClient.ApiUrl = url; -}; - -ApiClient.prototype.sendRequest = function (method, resource, data, callback) { - async.parallel([ - function () { - request.get({ - "headers": {"content-type": "application/json"}, - "url": ApiClient.ApiUrl + resource, - "data": data - }, (error, response, body) => { - if(error) { console.log(err); callback(true); return; } - let obj = JSON.parse(body); - callback(false, obj); - }); - } - ]); -}; - -/** - * Find all posts - */ -ApiClient.prototype.findAllPosts = function () { - console.log(this.sendRequest('GET', '/posts', [])); - - this.sendRequest('GET', '/posts', [], function (result) { - return result; - }); -}; - -/** - * Find posts by user id - */ -ApiClient.prototype.findPostsByUser = function (userId) { - let posts = this.sendRequest('GET', '/posts', []); - - let postsOfUser = []; - - posts.forEach(function (p) { - if (p.userId === userId) { - postsOfUser.push(p); - } - }); - - return postsOfUser; -}; - -/** - * Find user by id - */ -ApiClient.prototype.findUserById = function (userId) { - return this.sendRequest('GET', '/users/'+userId, []); -}; - -/** - * Find comments by user id - */ -ApiClient.prototype.findCommentsByUserId = function () { - return this.sendRequest('GET', '/comments', []); -}; \ No newline at end of file diff --git a/src/JsonResponse.js b/src/JsonResponse.js deleted file mode 100644 index f0fb536..0000000 --- a/src/JsonResponse.js +++ /dev/null @@ -1,19 +0,0 @@ -"use strict"; - -export default function JsonResponse() { - this.httpCode = 200; - this.headers = {'Content-Type': 'application/json'}; -} - -JsonResponse.prototype.init = function (app, res) { - // Enable json prettify - app.set('json spaces', 2); - - // Set response headers - res.setHeader('Accept', 'application/json'); - res.setHeader('Content-Type', 'application/json'); -}; - -JsonResponse.prototype.send = function (res, code, response) { - return res.json(response); -};