From ca415e58dede74db7490765246f46b1f799d52b1 Mon Sep 17 00:00:00 2001 From: Roman Timashev Date: Wed, 24 Feb 2016 19:10:42 +0300 Subject: [PATCH] API service update --- src/client/api/API.js | 13 +++++++++++++ src/client/api/api.js | 16 ---------------- src/client/app.js | 4 ++-- src/client/services/api.js | 5 +++++ 4 files changed, 20 insertions(+), 18 deletions(-) create mode 100644 src/client/api/API.js delete mode 100644 src/client/api/api.js create mode 100644 src/client/services/api.js diff --git a/src/client/api/API.js b/src/client/api/API.js new file mode 100644 index 00000000..b2cc07af --- /dev/null +++ b/src/client/api/API.js @@ -0,0 +1,13 @@ +import APIFeed from './APIFeed'; +import APIGallery from './APIGallery'; +import APIDocument from './APIDocument'; +import APICollective from './APICollective'; + +export default class API { + constructor(request) { + this.news = new APIFeed(request); + this.gallery = new APIGallery(request); + this.document = new APIDocument(request); + this.collective = new APICollective(request); + } +} \ No newline at end of file diff --git a/src/client/api/api.js b/src/client/api/api.js deleted file mode 100644 index 39b19d60..00000000 --- a/src/client/api/api.js +++ /dev/null @@ -1,16 +0,0 @@ -import APIFeed from './APIFeed'; -import APIGallery from './APIGallery'; -import APIDocument from './APIDocument'; -import APICollective from './APICollective'; - -export default function (app) { - app.factory('api', function ($http) { - let api = {}; - api.news = new APIFeed($http); - api.gallery = new APIGallery($http); - api.document = new APIDocument($http); - api.collective = new APICollective($http); - - return api; - }); -}; \ No newline at end of file diff --git a/src/client/app.js b/src/client/app.js index 51b3fe89..35dd0a15 100644 --- a/src/client/app.js +++ b/src/client/app.js @@ -32,7 +32,7 @@ import Strip from './filters/Strip'; import UppercaseFirst from './filters/UppercaseFirst'; import IOService from './services/io'; import MenuService from './services/menu'; -import api from './api/api'; +import API from './services/api'; let app = angular.module('hudozka', [ 'hudozhka.data', @@ -104,7 +104,7 @@ app.run(($location, $rootScope, $http) => { }); [ - api, + API, IOService, MenuService, RemoveHashtags, diff --git a/src/client/services/api.js b/src/client/services/api.js new file mode 100644 index 00000000..59dc5a8a --- /dev/null +++ b/src/client/services/api.js @@ -0,0 +1,5 @@ +import API from '../api/API'; + +export default function (app) { + app.factory('api', $http => new API($http)); +}; \ No newline at end of file