@@ -78,13 +78,9 @@ async function generateApiRoutes(modelFiles: string[]) {
78
78
}
79
79
80
80
if ( apiRoute === 'index' ) routeString += `route.get('${ uri } ', '${ path } ')\n\n`
81
-
82
81
if ( apiRoute === 'show' ) routeString += `route.get('${ uri } /{id}', '${ path } ')\n\n`
83
-
84
82
if ( apiRoute === 'store' ) routeString += `route.post('${ uri } ', '${ path } ')\n\n`
85
-
86
83
if ( apiRoute === 'update' ) routeString += `route.patch('${ uri } /{id}', '${ path } ')\n\n`
87
-
88
84
if ( apiRoute === 'destroy' ) routeString += `route.delete('${ uri } /{id}', '${ path } ')\n\n`
89
85
}
90
86
}
@@ -100,7 +96,7 @@ async function generateApiRoutes(modelFiles: string[]) {
100
96
async function lookupFile ( fileName : string ) : Promise < string | null > {
101
97
const ormDirectory = path . builtUserActionsPath ( 'src' , { relative : true } )
102
98
const filePath = path . join ( ormDirectory , fileName )
103
- const pathExists = await fs . existsSync ( filePath )
99
+ const pathExists = fs . existsSync ( filePath )
104
100
105
101
// Check if the directory exists
106
102
if ( pathExists ) {
@@ -109,7 +105,7 @@ async function lookupFile(fileName: string): Promise<string | null> {
109
105
110
106
const actionDirectory = path . userActionsPath ( )
111
107
const actionFilePath = path . join ( actionDirectory , fileName )
112
- const fileExists = await fs . existsSync ( actionFilePath )
108
+ const fileExists = fs . existsSync ( actionFilePath )
113
109
114
110
if ( fileExists ) {
115
111
return actionFilePath
@@ -188,18 +184,14 @@ async function writeModelRequest() {
188
184
if ( attribute . fieldArray ?. entity === 'number' ) defaultValue = 0
189
185
190
186
fieldString += ` ${ attribute . field } : ${ entity } \n `
191
-
192
187
fieldStringType += ` get(key: '${ attribute . field } '): ${ entity } \n`
193
-
194
188
fieldStringInt += `public ${ attribute . field } = ${ defaultValue } \n`
195
189
keyCounter ++
196
190
}
197
191
198
192
for ( const otherModel of otherModelRelations ) {
199
193
fieldString += ` ${ otherModel . foreignKey } : number\n `
200
-
201
194
fieldStringType += ` get(key: '${ otherModel . foreignKey } '): string \n`
202
-
203
195
fieldStringInt += `public ${ otherModel . foreignKey } = 0\n`
204
196
keyCounterForeign ++
205
197
}
@@ -288,9 +280,7 @@ async function writeOrmActions(apiRoute: string, modelName: String): Promise<voi
288
280
let method = 'GET'
289
281
let actionString = `import { Action } from '@stacksjs/actions'\n`
290
282
actionString += `import ${ modelName } from '../../orm/src/models/${ modelName } '\n`
291
-
292
283
let handleString = ``
293
-
294
284
actionString += ` import type { ${ modelName } RequestType } from '../../types/requests'\n\n`
295
285
296
286
if ( apiRoute === 'index' ) {
@@ -341,7 +331,6 @@ async function writeOrmActions(apiRoute: string, modelName: String): Promise<voi
341
331
await request.validate()
342
332
343
333
const id = request.getParam('id')
344
-
345
334
const model = await ${ modelName } .findOrFail(Number(id))
346
335
347
336
return model.update(request.all())
@@ -371,7 +360,6 @@ async function initiateModelGeneration(modelStringFile?: string): Promise<void>
371
360
await deleteExistingModelNameTypes ( )
372
361
await deleteExistingModelRequest ( modelStringFile )
373
362
await deleteExistingOrmRoute ( )
374
-
375
363
await writeModelNames ( )
376
364
await writeModelRequest ( )
377
365
0 commit comments