diff --git a/services/Instagram/install.sh b/services/Instagram/install.sh index a65c7432..ded4d1aa 100755 --- a/services/Instagram/install.sh +++ b/services/Instagram/install.sh @@ -9,9 +9,9 @@ gunzip -c ${build_file} | tar xopf - npm install --production --loglevel error #starting www -if forever restart src/index.js; then - echo Instagram Microservice restarted -else - forever start src/index.js - echo Instagram Microservice started -fi +#if forever restart ${script}; then +# echo Instagram Microservice restarted +#else +# forever start ${script} +# echo Instagram Microservice started +#fi diff --git a/services/Instagram/package.json b/services/Instagram/package.json index 7c51acd9..7b2548e7 100644 --- a/services/Instagram/package.json +++ b/services/Instagram/package.json @@ -3,6 +3,7 @@ "version": "0.0.0", "private": true, "scripts": { + "devwebpack": "NODE_ENV=development webpack", "webpack": "webpack", "start": "babel-node src/index.js", "build": "babel src -d out" @@ -18,11 +19,12 @@ "koa-bodyparser": "^3.0.0", "koa-compose": "^3.1.0", "koa-convert": "^1.2.0", + "koa-logger": "^2.0.0", "koa-mount": "^2.0.0", "koa-route": "^3.0.0", "koa-session-mongo": "^1.1.0", "koa-session-store": "^1.1.1", - "koa-static": "^2.0.0", + "koa-static": "^3.0.0", "mongodb": "^2.1.10", "mz": "^2.3.1", "react": "^0.14.7", diff --git a/services/Instagram/src/components/App.js b/services/Instagram/src/components/App.js index 88c472e6..8a690a83 100644 --- a/services/Instagram/src/components/App.js +++ b/services/Instagram/src/components/App.js @@ -11,7 +11,7 @@ export default class App extends React.Component{
Чтобы управлять, вы должны быть hudozka
- Войти + Войти ) } diff --git a/services/Instagram/src/config.js b/services/Instagram/src/config.js index 9cb0b435..b47e7e77 100644 --- a/services/Instagram/src/config.js +++ b/services/Instagram/src/config.js @@ -12,13 +12,19 @@ let privateData = JSON.parse( readFileSync(privatePath, 'utf-8') ); +export const staticPath = path.join( + __dirname, + '../build' +); + export const port = isProduction ? 18000 : 3000; -// export const pathPrefix = isProduction ? '/service/instagram' : ''; -export const pathPrefix = ''; +export const pathPrefix = isProduction ? '/service/instagram' : ''; +export const baseHref = isProduction ? '/service/instagram/' : '/'; +// export const pathPrefix = ''; export const indexPath = path.join( __dirname, - './templates/index.html' - // '../build/main.html' + // './templates/index.html' + '../build/main.html' ); // export const indexPath = '../build/main.html'; diff --git a/services/Instagram/src/core/update.js b/services/Instagram/src/core/update.js index 5a999e85..29a38e92 100644 --- a/services/Instagram/src/core/update.js +++ b/services/Instagram/src/core/update.js @@ -34,6 +34,8 @@ export async function updateSubscription(callbackUrl) { let data = await instagram.subscriptions.list(); let activeSubscriptions = data.result; + console.log(`Active subscriptions ${activeSubscriptions}`); + let objectSubscriptions = activeSubscriptions.filter(i => i.object === 'user' && !i.object_id && i.callback_url === callbackUrl) if (!objectSubscriptions.length) { diff --git a/services/Instagram/src/index.js b/services/Instagram/src/index.js index 19c188f7..f2768860 100644 --- a/services/Instagram/src/index.js +++ b/services/Instagram/src/index.js @@ -25,7 +25,6 @@ function main(){ } await clearSubscriptions(); - await updateSubscription(updateSubscriptionCallbackUrl); repeat(updateSubscriptionDelay)(() => { updateSubscription(updateSubscriptionCallbackUrl); diff --git a/services/Instagram/src/routers/index.js b/services/Instagram/src/routers/index.js index 35e40692..221ba4a8 100644 --- a/services/Instagram/src/routers/index.js +++ b/services/Instagram/src/routers/index.js @@ -1,7 +1,7 @@ import fs from 'mz/fs'; import compose from 'koa-compose'; import route from 'koa-route'; -import {indexPath, pathPrefix as root} from '../config'; +import {indexPath, pathPrefix} from '../config'; import main from './main'; import {auth, authCallback, authOut} from './auth'; @@ -18,7 +18,7 @@ export function statelessRouters() { export function routers() { return compose([ - main(), + // main(), auth(), authCallback(), authOut(), @@ -29,10 +29,10 @@ export function routers() { ]); } -export const url = path => `${root}${path}`; +export const url = (path, root=pathPrefix) => `${root}${path}`; // export const url = path => path; -export const get = (path, fn) => route['get'](url(path), fn); -export const post = (path, fn) => route['post'](url(path), fn); +export const get = (path, fn) => route['get'](url(path, ''), fn); +export const post = (path, fn) => route['post'](url(path, ''), fn); export function index(fn){ return async (ctx) => { diff --git a/services/Instagram/src/server.js b/services/Instagram/src/server.js index b673877f..22148ce8 100644 --- a/services/Instagram/src/server.js +++ b/services/Instagram/src/server.js @@ -1,6 +1,7 @@ import Koa from 'koa'; import mount from 'koa-mount'; import serve from 'koa-static'; +import logger from 'koa-logger'; import convert from 'koa-convert'; import sessionStore from 'koa-session-store'; import store from 'koa-session-mongo'; @@ -9,14 +10,15 @@ import bodyParser from 'koa-bodyparser'; import {db} from './core/db'; import instagram from './middlewares/instagram'; import {routers, statelessRouters} from './routers'; -import {pathPrefix, sessionSecret, sessionExpirationTime} from './config'; +import {pathPrefix, staticPath, sessionSecret, sessionExpirationTime} from './config'; export default function(){ const app = new Koa(); app.proxy = true; app.keys = [sessionSecret]; - app.use(convert(serve('../build'))); + app.use(logger()); + app.use(serve(staticPath)); app.use(bodyParser()); app.use(statelessRouters()); app.use(session('sid', sessionExpirationTime)); diff --git a/services/Instagram/src/templates/index.html b/services/Instagram/src/templates/index.ejs similarity index 74% rename from services/Instagram/src/templates/index.html rename to services/Instagram/src/templates/index.ejs index 9e190052..9b803ece 100644 --- a/services/Instagram/src/templates/index.html +++ b/services/Instagram/src/templates/index.ejs @@ -3,6 +3,7 @@