Skip to content

Commit

Permalink
fix build problems
Browse files Browse the repository at this point in the history
  • Loading branch information
xzyaoi committed Nov 21, 2018
1 parent 965e3a7 commit ab5bd5b
Show file tree
Hide file tree
Showing 8 changed files with 31 additions and 33 deletions.
2 changes: 0 additions & 2 deletions discovery/Dockerfile
Expand Up @@ -9,7 +9,5 @@ RUN npm install
COPY . /usr/src/app
RUN npm run build

COPY ./dist /usr/src/app/dist

EXPOSE 3000
CMD ["npm", "start"]
Empty file.
4 changes: 2 additions & 2 deletions discovery/src/controller/system.ts
@@ -1,7 +1,7 @@
import { BaseContext, Context } from 'koa';
import { config } from '../config';

import { getCount, updateCount } from '../parse'
import { getCount, updateCount } from '../parse';

export default class SystemController {
public static async getSystemStatus(ctx: BaseContext) {
Expand All @@ -20,7 +20,7 @@ export default class SystemController {
};
}
public static async getStatInfo (ctx: Context) {
const body = ctx.request.query
const body = ctx.request.query;
ctx.status = 200;
ctx.body = {
'code': 200,
Expand Down
10 changes: 5 additions & 5 deletions discovery/src/controller/user.ts
@@ -1,18 +1,18 @@
import { Context } from 'koa';
import * as passport from 'passport'
import * as passport from 'passport';
export default class UserController {
/**
* Create Session, a.k.a Log In
* @param ctx
* @param ctx
*/
public static async createSession(ctx: Context) {
passport.authenticate('cognito', {
successRedirect: '/',
failureRedirect: '/login'
})
failureRedirect: '/login'
});
ctx.status = 200;
ctx.body = {
'status': 'ok'
}
};
}
}
8 changes: 4 additions & 4 deletions discovery/src/parse/entity.ts
@@ -1,9 +1,9 @@
interface CountResult {
users: number,
registries: number,
models: number
users: number;
registries: number;
models: number;
}

export {
CountResult
}
};
30 changes: 15 additions & 15 deletions discovery/src/parse/index.ts
@@ -1,39 +1,39 @@
var Parse = require('parse/node').Parse;
const Parse = require('parse/node').Parse;

import { CountResult } from './entity'
import { CountResult } from './entity';

function initParse() {
Parse.initialize(process.env.PARSE_ID, process.env.PARSE_TOKEN, process.env.PARSE_MASTER_KEY);
(Parse as any).serverURL = process.env.PARSE_URL
(Parse as any).serverURL = process.env.PARSE_URL;
}

async function updateCount(users: number, registries: number, models: number) {
const Meta = Parse.Object.extend("Meta");
let meta = new Meta();
meta.set("user", users);
meta.set("registry", registries);
meta.set("model", models);
const results: any[] = await meta.save()
return results
const Meta = Parse.Object.extend('Meta');
const meta = new Meta();
meta.set('user', users);
meta.set('registry', registries);
meta.set('model', models);
const results: any[] = await meta.save();
return results;
}

async function getCount(limit: number) {
const Meta = Parse.Object.extend("Meta");
const Meta = Parse.Object.extend('Meta');
const query = new Parse.Query(Meta);
query.descending("createdAt");
query.descending('createdAt');
query.limit(limit);
const results: any[] = await query.find();
let result: CountResult[];
const result: CountResult[] = [];
for (let i = 0; i < results.length; i++) {
result[i].models = results[i]['models'];
result[i].registries = results[i]['registries'];
result[i].users = results[i]['users'];
}
return result
return result;
}

export {
initParse,
updateCount,
getCount
}
};
6 changes: 3 additions & 3 deletions discovery/src/plugin/auth.ts
@@ -1,6 +1,6 @@
import passport from 'passport';
import * as passport from 'passport';
import { config } from '../config';
var CognitoStrategy = require('passport-cognito')
const CognitoStrategy = require('passport-cognito');

passport.use(new CognitoStrategy({
userPoolId: config.cognitoPoolId,
Expand All @@ -9,7 +9,7 @@ passport.use(new CognitoStrategy({
},
function (accessToken: string, idToken: string, refreshToken: string, user: any, cb: any) {
process.nextTick(function() {
cb(null, user);
cb(undefined, user);
});
}
));
4 changes: 2 additions & 2 deletions discovery/src/server.ts
Expand Up @@ -6,7 +6,7 @@ import * as winston from 'winston';
import * as passport from 'koa-passport';
import * as session from 'koa-session';

import { initParse } from './parse'
import { initParse } from './parse';
import { config } from './config';
import { router } from './routes';
import { logger } from './logging';
Expand All @@ -18,7 +18,7 @@ export const app = new Koa();
/**
* Initialize Parse independently
*/
initParse()
initParse();
/**
* Passport Settings
*/
Expand Down

0 comments on commit ab5bd5b

Please sign in to comment.