Skip to content

Commit

Permalink
add Dockerfile & tslint fix
Browse files Browse the repository at this point in the history
  • Loading branch information
xzyaoi committed Nov 10, 2018
1 parent 97b1355 commit 4bcc85a
Show file tree
Hide file tree
Showing 10 changed files with 52 additions and 38 deletions.
13 changes: 13 additions & 0 deletions discovery/Dockerfile
@@ -0,0 +1,13 @@
FROM node:latest

RUN mkdir -p /usr/src/app
WORKDIR /usr/src/app

COPY package.json /usr/src/app/
RUN npm install

COPY . /usr/src/app
RUN npm build

EXPOSE 3000
CMD ["npm", "start"]
5 changes: 3 additions & 2 deletions discovery/package.json
Expand Up @@ -5,8 +5,9 @@
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"build-server": "tslint --project . && tsc",
"watch-server": "nodemon --watch 'src/**/*' -e ts,tsx --exec 'ts-node' ./src/server.ts"
"build": "tslint --project . --fix && tsc",
"watch-server": "nodemon --watch 'src/**/*' -e ts,tsx --exec 'ts-node' ./src/server.ts",
"start": "node dist/server.js"
},
"author": "",
"license": "ISC",
Expand Down
8 changes: 4 additions & 4 deletions discovery/src/controller/entity.ts
@@ -1,6 +1,6 @@
interface importPackageRequest {
linkedTo: string
interface ImportPackageRequest {
linkedTo: string;
}
export {
importPackageRequest
}
ImportPackageRequest
};
8 changes: 4 additions & 4 deletions discovery/src/controller/package.ts
@@ -1,10 +1,10 @@
import { Context } from 'koa';
import { Package } from '../dynamo/entity';
import { importPackageRequest } from './entity'
import { ImportPackageRequest } from './entity';
export default class PackageController {
public static async importPackage (ctx: Context) {
const toImportPackage:Package = new Package();
console.log(toImportPackage)
const toImportPackage: Package = new Package();

console.log(toImportPackage);
}
}
4 changes: 2 additions & 2 deletions discovery/src/controller/pretrained.ts
Expand Up @@ -2,7 +2,7 @@ import { Context } from 'koa';
import { putPretrained, getPretrained } from '../dynamo/action';
export default class PackageController {
public static async importPretrained (ctx: Context) {
putPretrained('yolo_tiny','https://premium.file.cvtron.xyz/data/yolo_tiny.ckpt');
putPretrained('yolo_tiny', 'https://premium.file.cvtron.xyz/data/yolo_tiny.ckpt');
ctx.status = 200;
ctx.body = {
'code': '200',
Expand All @@ -14,6 +14,6 @@ export default class PackageController {
ctx.body = {
'code': '200',
'results': await getPretrained()
}
};
}
}
34 changes: 17 additions & 17 deletions discovery/src/dynamo/action.ts
Expand Up @@ -8,54 +8,54 @@ import { isSymbol } from 'util';
*/

/**
*
* @param isSymbol
* @param linkedTo
*
* @param isSymbol
* @param linkedTo
*/
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)
})
console.log(objectSaved);
});
}
/**
*
*
* Following will be pretrained manipulations
*/

/**
*
* @param linkedTo
*
* @param linkedTo
* @param name
*/
function putPretrained (name: string, linkedTo: string) {
const toPutPretrained = Object.assign(new Pretrained, {
id: Guid.create(),
name: name,
linkedTo: linkedTo
})
});
mapper.put(toPutPretrained).then(objectSaved => {
console.log(objectSaved)
})
console.log(objectSaved);
});
}

/**
*
*
*/
async function getPretrained () {
let results: Pretrained[] = []
const results: Pretrained[] = [];
for await (const item of mapper.scan(Pretrained)) {
results.push(item)
results.push(item);
}
return results
return results;
}

export {
putPretrained,
putPackage,
getPretrained
}
};
4 changes: 2 additions & 2 deletions discovery/src/dynamo/config.ts
Expand Up @@ -2,8 +2,8 @@ const AWSConfig = {
region: 'us-east-1',
accessKeyId: process.env.AWS_ACCESS_KEY,
secretAccessKey: process.env.AWS_SECRET_ACCESS_KEY,
}
};

export {
AWSConfig
}
};
10 changes: 5 additions & 5 deletions discovery/src/dynamo/dynamo.ts
Expand Up @@ -5,13 +5,13 @@

import { DataMapper } from '@aws/dynamodb-data-mapper';
import DynamoDB = require('aws-sdk/clients/dynamodb');
import AWS = require('aws-sdk')
import { AWSConfig } from './config'
import AWS = require('aws-sdk');
import { AWSConfig } from './config';

AWS.config.update(AWSConfig)
AWS.config.update(AWSConfig);

const mapper = new DataMapper({
client: new DynamoDB({region: 'us-east-1'})
})
});

export default mapper
export default mapper;
2 changes: 1 addition & 1 deletion discovery/src/dynamo/entity.ts
Expand Up @@ -41,4 +41,4 @@ class Pretrained {
export {
Package,
Pretrained
}
};
2 changes: 1 addition & 1 deletion discovery/src/server.ts
Expand Up @@ -12,7 +12,7 @@ const app = new Koa();

app.use(cors());
app.use(helmet());
app.use(logger(winston))
app.use(logger(winston));
app.use(bodyParser());
app.use(router.routes()).use(router.allowedMethods());

Expand Down

0 comments on commit 4bcc85a

Please sign in to comment.