fix: reqParams read error & feat: set default db as faas

This commit is contained in:
MiaoWoo 2019-06-11 18:09:24 +08:00
parent 24e2526eab
commit 28bab3e7e3
2 changed files with 5 additions and 5 deletions

View File

@ -1,12 +1,12 @@
import {
controller, response, requestBody, httpGet, httpPost, queryParam
controller, response, requestBody, httpGet, httpPost, queryParam, requestParam
} from 'inversify-express-utils';
import { inject } from 'inversify';
import { DBClient } from 'cc-server-db'
import 'cc-server-db-mongo'
//process.env.FAAS_MONGO_URL = 'mongodb://192.168.0.2:27017';
process.env.FAAS_MONGO_DB = "faas";
//process.env.FAAS_MONGO_DB = "faas";
const TABLE = 'users'
@ -32,7 +32,7 @@ export class Controller {
@httpGet('/:id')
public async get(
@queryParam('id') id: string
@requestParam('id') id: string
): Promise<Model> {
return this.client.findOneById(TABLE, id);
}
@ -46,7 +46,7 @@ export class Controller {
@httpPost('/:id')
public async update(
@queryParam('id') id: string,
@requestParam('id') id: string,
@requestBody() model: Model
): Promise<boolean> {
return this.client.updateById(TABLE, id, model);

View File

@ -1,7 +1,7 @@
import { Db, MongoClient } from 'mongodb';
const connStr = process.env.FAAS_MONGO_URL || 'mongodb://192.168.0.2:27017';
const dbName = process.env.FAAS_MONGO_DB || "frppool";
const dbName = process.env.FAAS_MONGO_DB || "faas";
export class MongoDBConnection {
private static isConnected: boolean = false;