@@ -189,13 +189,19 @@ endpoints.forEach(function(endpoint) {
189
189
// filter out aggregated_queries for a while (see #17)
190
190
return
191
191
}
192
+
193
+ // define before "if", to make it available later
194
+ let dataType
195
+ if (method .name !== ' delete' ) {
196
+ const dto = query2dto (sqlParser, method)
197
+ // LATER: do we really need signature and cache?
198
+ dataType = obtainDtoName (dto)
199
+ }
200
+
192
201
const params = extractParamsFromQuery (method .query )
193
202
const hasGetOne = method .name === ' get'
194
203
const hasGetMany = method .name === ' get_list'
195
204
if (hasGetOne || hasGetMany) {
196
- const dto = query2dto (sqlParser, method)
197
- // LATER: do we really need signature and cache?
198
- const dataType = obtainDtoName (dto)
199
205
const resultVariableDeclaration = hasGetMany
200
206
? ` result := []${ dataType} \{\} `
201
207
: ` var result ${ dataType} `
@@ -238,9 +244,6 @@ endpoints.forEach(function(endpoint) {
238
244
< %
239
245
}
240
246
if (method .name === ' post' ) {
241
- const dto = query2dto (sqlParser, method)
242
- // LATER: do we really need signature and cache?
243
- const dataType = obtainDtoName (dto)
244
247
% >
245
248
r .Post (" <%- path %>" , func (w http .ResponseWriter , r * http .Request ) {
246
249
var body < %- dataType % >
@@ -264,9 +267,6 @@ endpoints.forEach(function(endpoint) {
264
267
< %
265
268
}
266
269
if (method .name === ' put' ) {
267
- const dto = query2dto (sqlParser, method)
268
- // LATER: do we really need signature and cache?
269
- const dataType = obtainDtoName (dto)
270
270
% >
271
271
r .Put (" <%- path %>" , func (w http .ResponseWriter , r * http .Request ) {
272
272
var body < %- dataType % >
0 commit comments