vulcainjs / vulcain-corejs

Microservice framework for nodejs
https://vulcainjs.github.io
Apache License 2.0
11 stars 3 forks source link

ERROR when trying to load component . On Model decorator #1

Closed workfel closed 8 years ago

workfel commented 8 years ago

I'm on 1.0.23 version. When i add an string on @Model() decorator, this error happen.

message: 'ERROR when trying to load component MeasureSchema.js : TypeError: Cannot create property \'name\' on string \'MeasureSchema\'\n at C:\\Dev\\sovinty\\ConnectedSystems\\tracker.facade\\node_modules\\vulcain-corejs\\dist\\schemas\\annotations.js:6:22\n at DecorateConstructor (C:\\Dev\\sovinty\\ConnectedSystems\\tracker.facade\\node_modules\\reflect-metadata\\Reflect.js:531:29)\n at Object.decorate (C:\\Dev\\sovinty\\ConnectedSystems\\tracker.facade\\node_modules\\reflect-metadata\\Reflect.js:115:20)\n at __decorate (C:\\Dev\\sovinty\\ConnectedSystems\\tracker.facade\\dist\\api\\models\\MeasureSchema.js:4:92)\n at Object.<anonymous> (C:\\Dev\\sovinty\\ConnectedSystems\\tracker.facade\\dist\\api\\models\\MeasureSchema.js:26:17)\n at Module._compile (module.js:541:32)\n at Object.Module._extensions..js (module.js:550:10)\n at Module.load (module.js:458:32)\n at tryModuleLoad (module.js:417:12)\n at Function.Module._load (module.js:409:3) []' }

The class

export class MeasureSchema {

   @Property({type: "string", required: true})
   accessSet:string;

   @Property({type: "string", required: true})
   startdate:string;

   @Property({type: "string"})
   enddate:string;
}

And when in remove the value on decorator, it's working.

@Model()
export class MeasureSchema {

   @Property({type: "string", required: true})
   accessSet:string;

   @Property({type: "string", required: true})
   startdate:string;

   @Property({type: "string"})
   enddate:string;
}```
malain commented 8 years ago

Model decorator accept an object as parameter not a string. The valid signature is

@Model({name:"MeasureSchema"})

Note that providing a name is optional, this is the class name by default.