Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
31 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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' | ||
} | ||
}; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,9 @@ | ||
interface CountResult { | ||
users: number, | ||
registries: number, | ||
models: number | ||
users: number; | ||
registries: number; | ||
models: number; | ||
} | ||
|
||
export { | ||
CountResult | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters