@@ -21,69 +21,23 @@ module.exports = function () {
2121
2222 let things = { } ;
2323
24- things . User = new Thing ( {
25- name : 'User' ,
26- uriPrefix : 'U/' ,
27- idProperty : 'UserID' ,
28- } ) ;
24+ let routes ;
2925
30- things . Type = new Thing ( {
31- name : 'Type' ,
32- uriPrefix : 'T/' ,
33- idProperty : 'ClassName' ,
34- parentThing : things . User ,
35- provide : {
36- l : true ,
37- c : true ,
38- r : true ,
39- } ,
40- } ) ;
26+ things . User = requireThing ( 'User' ) ;
27+ things . Type = requireThing ( 'Type' ) ;
28+ things . TypeAttribute = requireThing ( 'TypeAttribute' ) ;
29+ things . Entity = requireThing ( 'Entity' ) ;
30+ things . EntityAttribute = requireThing ( 'EntityAttribute' ) ;
4131
42- things . TypeAttribute = new Thing ( {
43- name : 'TypeAttribute' ,
44- uriName : 'Attribute' ,
45- uriPrefix : 'A/' ,
46- idProperty : 'AttributeKey' ,
47- parentThing : things . Type ,
48- provide : {
49- c : true ,
50- r : true ,
51- u : true ,
52- } ,
53- } ) ;
54-
55- things . Entity = new Thing ( {
56- name : 'Entity' ,
57- pluralUriName : 'Entities' ,
58- uriPrefix : 'E/' ,
59- idProperty : 'EntityID' ,
60- parentThing : things . Type ,
61- provide : {
62- l : true ,
63- c : true ,
64- r : true ,
65- d : true ,
66- } ,
67- } ) ;
68-
69- things . EntityAttribute = new Thing ( {
70- name : 'EntityAttribute' ,
71- uriName : 'Attribute' ,
72- uriPrefix : 'A/' ,
73- idProperty : 'AttributeKey' ,
74- parentThing : things . Entity ,
75- provide : {
76- r : true ,
77- u : true ,
78- d : true ,
79- } ,
80- } ) ;
81-
82- let routes = things . User . routes ( ) ;
32+ routes = things . User . routes ( ) ;
8333
8434 process . stdout . write ( JSON . stringify ( routes , undefined , ' ' ) ) ;
8535 process . stdout . write ( '' + routes . length ) ;
8636
8737 return routes ;
8838
39+ function requireThing ( name ) {
40+ return require ( `./things/${ name } ` ) ( Thing , things ) ;
41+ }
42+
8943} ;
0 commit comments