very-express 0.0.5 → 0.0.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -114,36 +114,30 @@ class {{interfaceName}}Controller {
114
114
 
115
115
  export default new {{interfaceName}}Controller().router;
116
116
  `;
117
- template = template.replace(/{{headerComment}}/g, templateOptions.headerComment);
118
- template = template.replace(/{{interfaceName}}/g, templateOptions.interfaceName);
119
- template = template.replace(/{{modelPath}}/g, templateOptions.modelPath);
120
117
  const indent2 = '\n ';
121
118
  const indent3 = '\n ';
122
119
  const indent4 = '\n ';
123
- if (templateOptions.validator[templateOptions.endpoint].get) {
124
- template = template.replace(/{{getListRoute}}/g, `this.router.get('/', ${indent3}[${indent4 + templateOptions.validator[templateOptions.endpoint].get.join(',' + indent4) + indent3}],${indent3}this.getList${templateOptions.interfaceName}.bind(this)${indent2});`);
125
- }
126
- ;
127
- if (templateOptions.validator[templateOptions.endpoint + '/{id}'].get) {
128
- template = template.replace(/{{getOneRoute}}/g, `this.router.get('/:id', ${indent3}[${indent4 + templateOptions.validator[templateOptions.endpoint + '/{id}'].get.join(',' + indent4) + indent3}],${indent3}this.get${templateOptions.interfaceName}.bind(this)${indent2});`);
129
- }
130
- ;
131
- if (templateOptions.validator[templateOptions.endpoint].post) {
132
- template = template.replace(/{{postRoute}}/g, `this.router.post('/', ${indent3}[${indent4 + templateOptions.validator[templateOptions.endpoint].post.join(',' + indent4) + indent3}],${indent3}this.create${templateOptions.interfaceName}.bind(this)${indent2});`);
133
- }
134
- ;
135
- if (templateOptions.validator[templateOptions.endpoint + '/{id}'].put) {
136
- template = template.replace(/{{putRoute}}/g, `this.router.put('/:id', ${indent3}[${indent4 + templateOptions.validator[templateOptions.endpoint + '/{id}'].put.join(',' + indent4) + indent3}],${indent3}this.update${templateOptions.interfaceName}.bind(this)${indent2});`);
137
- }
138
- ;
139
- if (templateOptions.validator[templateOptions.endpoint + '/{id}'].patch) {
140
- template = template.replace(/{{patchRoute}}/g, `this.router.patch('/:id', ${indent3}[${indent4 + templateOptions.validator[templateOptions.endpoint + '/{id}'].patch.join(',' + indent4) + indent3}],${indent3}this.update${templateOptions.interfaceName}.bind(this)${indent2});`);
141
- }
142
- ;
143
- if (templateOptions.validator[templateOptions.endpoint + '/{id}'].delete) {
144
- template = template.replace(/{{deleteRoute}}/g, `this.router.delete('/:id', ${indent3}[${indent4 + templateOptions.validator[templateOptions.endpoint + '/{id}'].delete.join(',' + indent4) + indent3}],${indent3}this.delete${templateOptions.interfaceName}.bind(this)${indent2});`);
145
- }
146
- ;
120
+ template = template.replace(/{{headerComment}}/g, templateOptions.headerComment);
121
+ template = template.replace(/{{interfaceName}}/g, templateOptions.interfaceName);
122
+ template = template.replace(/{{modelPath}}/g, templateOptions.modelPath);
123
+ template = template.replace(/{{getListRoute}}/g, !templateOptions.validator[templateOptions.endpoint].get ?
124
+ '' :
125
+ `this.router.get('/', ${indent3}[${indent4 + templateOptions.validator[templateOptions.endpoint].get.join(',' + indent4) + indent3}],${indent3}this.getList${templateOptions.interfaceName}.bind(this)${indent2});`);
126
+ template = template.replace(/{{getOneRoute}}/g, !templateOptions.validator[templateOptions.endpoint + '/{id}'].get ?
127
+ '' :
128
+ `this.router.get('/:id', ${indent3}[${indent4 + templateOptions.validator[templateOptions.endpoint + '/{id}'].get.join(',' + indent4) + indent3}],${indent3}this.get${templateOptions.interfaceName}.bind(this)${indent2});`);
129
+ template = template.replace(/{{postRoute}}/g, !templateOptions.validator[templateOptions.endpoint].post ?
130
+ '' :
131
+ `this.router.post('/', ${indent3}[${indent4 + templateOptions.validator[templateOptions.endpoint].post.join(',' + indent4) + indent3}],${indent3}this.create${templateOptions.interfaceName}.bind(this)${indent2});`);
132
+ template = template.replace(/{{putRoute}}/g, !templateOptions.validator[templateOptions.endpoint + '/{id}'].put ?
133
+ '' :
134
+ `this.router.put('/:id', ${indent3}[${indent4 + templateOptions.validator[templateOptions.endpoint + '/{id}'].put.join(',' + indent4) + indent3}],${indent3}this.update${templateOptions.interfaceName}.bind(this)${indent2});`);
135
+ template = template.replace(/{{patchRoute}}/g, !templateOptions.validator[templateOptions.endpoint + '/{id}'].patch ?
136
+ '' :
137
+ `this.router.patch('/:id', ${indent3}[${indent4 + templateOptions.validator[templateOptions.endpoint + '/{id}'].patch.join(',' + indent4) + indent3}],${indent3}this.update${templateOptions.interfaceName}.bind(this)${indent2});`);
138
+ template = template.replace(/{{deleteRoute}}/g, !templateOptions.validator[templateOptions.endpoint + '/{id}'].delete ?
139
+ '' :
140
+ `this.router.delete('/:id', ${indent3}[${indent4 + templateOptions.validator[templateOptions.endpoint + '/{id}'].delete.join(',' + indent4) + indent3}],${indent3}this.delete${templateOptions.interfaceName}.bind(this)${indent2});`);
147
141
  return template;
148
142
  }
149
143
  exports.default = controllerTemplate;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "very-express",
3
- "version": "0.0.5",
3
+ "version": "0.0.7",
4
4
  "description": "based on json schema and openapi, generate Express RestApi server with mongoDb ",
5
5
  "author": "justin26l",
6
6
  "license": "MIT",