Skip to content

Commit

Permalink
chore: wip
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisbbreuer committed May 10, 2024
1 parent cc6078b commit 4fe1098
Show file tree
Hide file tree
Showing 9 changed files with 19 additions and 21 deletions.
4 changes: 2 additions & 2 deletions app/Actions/Dashboard/GetDeploymentCount.ts
@@ -1,12 +1,12 @@
import { Action } from '@stacksjs/actions'
import { Deployment } from '@stacksjs/orm'
// import { Deployment } from '@stacksjs/orm'

export default new Action({
name: 'GetDeploymentCount',
description: 'Gets the total number of deployments.',
apiResponse: true,

async handle() {
return Deployment.count()
// return Deployment.count()
},
})
4 changes: 2 additions & 2 deletions app/Actions/Dashboard/GetDownloadCount.ts
@@ -1,12 +1,12 @@
import { Action } from '@stacksjs/actions'
import { Library } from '@stacksjs/orm'
// import { Library } from '@stacksjs/orm'

export default new Action({
name: 'GetDownloadCount',
description: 'Gets the total number of downloads.',
apiResponse: true,

async handle() {
return Library.downloadCount()
// return Library.downloadCount()
},
})
4 changes: 2 additions & 2 deletions app/Actions/Dashboard/GetRecentCommits.ts
@@ -1,12 +1,12 @@
import { Action } from '@stacksjs/actions'
import { Commit } from '@stacksjs/orm'
// import { Commit } from '@stacksjs/orm'

export default new Action({
name: 'GetRecentCommits',
description: 'Gets recent commits.',
apiResponse: true,

async handle() {
return Commit.recent(3)
// return Commit.recent(3)
},
})
4 changes: 2 additions & 2 deletions app/Actions/Dashboard/GetRecentDeployments.ts
@@ -1,12 +1,12 @@
import { Action } from '@stacksjs/actions'
import { Deployment } from '@stacksjs/orm'
// import { Deployment } from '@stacksjs/orm'

export default new Action({
name: 'GetRecentDeployments',
description: 'Gets recent deployments.',
apiResponse: true,

async handle() {
return Deployment.recent(3)
// return Deployment.recent(3)
},
})
4 changes: 2 additions & 2 deletions app/Actions/Dashboard/GetSubscriberCount.ts
@@ -1,12 +1,12 @@
import { Action } from '@stacksjs/actions'
import { Subscriber } from '@stacksjs/orm'
// import { Subscriber } from '@stacksjs/orm'

export default new Action({
name: 'GetSubscriberCount',
description: 'Gets the total number of subscribers.',
apiResponse: true,

async handle() {
return Subscriber.count()
// return Subscriber.count()
},
})
4 changes: 2 additions & 2 deletions app/Actions/Dashboard/GetTotalUsers.ts
@@ -1,12 +1,12 @@
import { Action } from '@stacksjs/actions'
import { User } from '@stacksjs/orm'
// import { User } from '@stacksjs/orm'

export default new Action({
name: 'GetTotalUsers',
description: 'Gets the total number of users.',
apiResponse: true,

async handle() {
return User.count()
// return User.count()
},
})
6 changes: 3 additions & 3 deletions app/Actions/LogAction.ts
@@ -1,6 +1,6 @@
import { Action } from '@stacksjs/actions'
import { log } from '@stacksjs/logging'
import { rule } from '@stacksjs/validation'
import { schema } from '@stacksjs/validation'

interface Request {
message: string
Expand All @@ -14,12 +14,12 @@ export default new Action({
// the request object is optional, but if it is provided, it will be used for validation
fields: {
message: {
rule: rule.string().minLength(3).maxLength(255),
rule: schema.string().minLength(3).maxLength(255),
message: 'The message must be between 3 and 255 characters long.',
},

level: {
rule: rule.enum(['info', 'warn', 'error']),
rule: schema.enum(['info', 'warn', 'error']),
message: 'The log level must be one of "info", "warn", or "error".',
},
},
Expand Down
Binary file modified bun.lockb
Binary file not shown.
10 changes: 4 additions & 6 deletions storage/framework/core/actions/src/helpers/utils.ts
Expand Up @@ -26,14 +26,12 @@ export async function runAction(action: string, options?: ActionOptions) {
if (file === `${action}.ts` || file.endsWith(`${action}.ts`))
return ((await import(p.userActionsPath(file))).default as Action).handle()

// console.log('model', model.name)
// WIP: if (model.name === action) return await model.handle()

// const a = await import(p.userActionsPath(file))
// if (a.name === action) return await a.handle()
// if a custom model name is used, we need to check for it
const a = await import(p.userActionsPath(file))
if (a.name === action) return await a.handle()
}

// or else, just run the action normally by assuming it's stored in p.actionsPath
// or else, just run the action normally by assuming the action is core Action, stored in p.actionsPath
const opts = buddyOptions()
const path = p.relativeActionsPath(`src/${action}.ts`)
const cmd = `bun --bun ${path} ${opts}`.trimEnd()
Expand Down

0 comments on commit 4fe1098

Please sign in to comment.