Instagram Microservice Update

This commit is contained in:
tmshv committed 2016-03-25 17:06:18 +03:00
1 parent ec52ee2c2a
commit bb97677d39
10 files changed
+38 -24

No files matched your search

+6 -6
View File
@@ -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
+3 -1
View File
@@ -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",
+1 -1
View File
@@ -11,7 +11,7 @@ export default class App extends React.Component{
<h1>Панель управления инстаграмом художки</h1>
<p>Чтобы управлять, вы должны быть <a href="https://instagram.com/hudozka">hudozka</a></p>
<a href="/auth" onClick={this.handleClick.bind(this)}>Войти</a>
<a href="auth" onClick={this.handleClick.bind(this)}>Войти</a>
</div>
)
}
+10 -4
View File
@@ -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';
+2
View File
@@ -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) {
-1
View File
@@ -25,7 +25,6 @@ function main(){
}
await clearSubscriptions();
await updateSubscription(updateSubscriptionCallbackUrl);
repeat(updateSubscriptionDelay)(() => {
updateSubscription(updateSubscriptionCallbackUrl);
+5 -5
View File
@@ -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) => {
+4 -2
View File
@@ -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));
@@ -3,6 +3,7 @@
<head>
<meta charset="UTF-8">
<title>Instagram Control</title>
<base href="<%= htmlWebpackPlugin.options.baseHref %>">
</head>
<body>
<div class="app-container"></div>
+6 -4
View File
@@ -6,6 +6,8 @@ const isProduction = env === 'production';
// import autoprefixer from 'autoprefixer';
import {baseHref} from './src/config';
module.exports = {
entry: './src/app.js',
watch: !isProduction,
@@ -29,10 +31,10 @@ module.exports = {
plugins: [
// new webpack.HotModuleReplacementPlugin(),
new HTML({
filename: 'main.html',
title: 'Instagram',
template: 'src/templates/index.html',
inject: 'body'
filename: 'index.html',
template: 'src/templates/index.ejs',
inject: 'body',
baseHref: baseHref
})
],
module: {