Skip to content

Commit

Permalink
add import package functions
Browse files Browse the repository at this point in the history
  • Loading branch information
xzyaoi committed Nov 5, 2018
1 parent 04aed0b commit 76bbf8f
Show file tree
Hide file tree
Showing 10 changed files with 43 additions and 2 deletions.
5 changes: 5 additions & 0 deletions discovery/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions discovery/package.json
Expand Up @@ -20,6 +20,7 @@
"@types/koa-router": "^7.0.32",
"@types/koa__cors": "^2.2.3",
"aws-sdk": "^2.348.0",
"guid-typescript": "^1.0.9",
"koa": "^2.6.1",
"koa-bodyparser": "^4.2.1",
"koa-helmet": "^4.0.0",
Expand Down
1 change: 1 addition & 0 deletions discovery/src/controller/index.ts
@@ -1 +1,2 @@
export { default as system } from './system';
export { default as package } from './package';
12 changes: 12 additions & 0 deletions discovery/src/controller/package.ts
@@ -0,0 +1,12 @@
import { BaseContext } from 'koa';
import { Package } from '../dynamo/model'

export default class PackageController {
public static async importPackage (ctx: BaseContext) {
const toImportPackage : Package = new Package();
console.log(ctx.body)
toImportPackage.isSymbol = true;
toImportPackage.linkedTo = ctx.body.linkedTo;
console.log(toImportPackage)
}
}
15 changes: 14 additions & 1 deletion discovery/src/dynamo/action.ts
@@ -1,3 +1,16 @@
import mapper from './dynamo'
import { Package } from './model'
import { Guid } from 'guid-typescript';
/**
* Following will be object manipulations
*/
*/
function putPackage (isSymbol: boolean, linkedTo: string) {
const toPutPackage = Object.assign(new Package, {
id: Guid.create(),
isSymbol: isSymbol,
linkedTo: linkedTo
})
mapper.put(toPutPackage).then(objectSaved => {
console.log(objectSaved)
})
}
2 changes: 2 additions & 0 deletions discovery/src/dynamo/dynamo.ts
Expand Up @@ -9,3 +9,5 @@ import DynamoDB = require('aws-sdk/clients/dynamodb');
const mapper = new DataMapper({
client: new DynamoDB({region: 'us-east-1'})
})

export default mapper
4 changes: 4 additions & 0 deletions discovery/src/dynamo/model.ts
Expand Up @@ -22,3 +22,7 @@ class Package {
@attribute()
linkedTo: string;
}

export {
Package
}
1 change: 1 addition & 0 deletions discovery/src/routes.ts
Expand Up @@ -5,5 +5,6 @@ import controller = require('./controller');
const router = new Router();

router.get('/system/status', controller.system.getSystemStatus);
router.post('/packages', controller.package.importPackage)

export { router };
3 changes: 2 additions & 1 deletion discovery/tsconfig.json
Expand Up @@ -5,7 +5,8 @@
"noImplicitAny": true,
"outDir": "./dist",
"sourceMap": true,
"experimentalDecorators": true
"experimentalDecorators": true,
"emitDecoratorMetadata": true
},
"include": [
"./src/**/*"
Expand Down
1 change: 1 addition & 0 deletions setup.py
Expand Up @@ -23,6 +23,7 @@
"Intended Audience :: Science/Research",
"Topic :: Scientific/Engineering",
"Topic :: Scientific/Engineering :: Image Recognition",
"Topic :: Scientific/Engineering :: Computer Vision",
"Topic :: Software Development",
],
)

0 comments on commit 76bbf8f

Please sign in to comment.