Skip to content

Commit 402aa52

Browse files
chore: wip
1 parent 8665458 commit 402aa52

File tree

10 files changed

+62
-2
lines changed

10 files changed

+62
-2
lines changed

bun.lockb

14 KB
Binary file not shown.

stacks

20 KB
Binary file not shown.
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import process from 'node:process'
2+
import { listRoutes } from '@stacksjs/router'
3+
import { log } from '@stacksjs/logging'
4+
5+
// first, reset the database, if it exists
6+
const result = await listRoutes()
7+
8+
if (result?.isErr()) {
9+
console.error(result.error)
10+
log.error('Route lists failed', result.error)
11+
process.exit(1)
12+
}
13+
14+
process.exit(0)

storage/framework/core/buddy/src/cli.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ async function main() {
6464
cmd.make(buddy)
6565
cmd.migrate(buddy)
6666
cmd.release(buddy)
67+
cmd.route(buddy)
6768
cmd.seed(buddy)
6869
cmd.setup(buddy)
6970
cmd.test(buddy)

storage/framework/core/buddy/src/commands/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ export * from './ports'
2222
export * from './prepublish'
2323
export * from './projects'
2424
export * from './release'
25+
export * from './route'
2526
export * from './seed'
2627
export * from './setup'
2728
export * from './test'
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
import process from 'node:process'
2+
import { runAction } from '@stacksjs/actions'
3+
import { intro, outro } from '@stacksjs/cli'
4+
import { Action } from '@stacksjs/enums'
5+
import { ExitCode } from '@stacksjs/types'
6+
import type { CLI, MigrateOptions } from '@stacksjs/types'
7+
8+
export function route(buddy: CLI) {
9+
const descriptions = {
10+
route: 'Lists your routes',
11+
}
12+
13+
buddy
14+
.command('route:list', descriptions.route)
15+
.action(async (options: MigrateOptions) => {
16+
const perf = await intro('buddy route:list')
17+
const result = await runAction(Action.RouteList, options)
18+
19+
if (result.isErr()) {
20+
await outro(
21+
'While running the migrate command, there was an issue',
22+
{ startTime: perf, useSeconds: true },
23+
result.error,
24+
)
25+
process.exit()
26+
}
27+
28+
29+
await outro(`Successfully listed routes`)
30+
31+
process.exit(ExitCode.Success)
32+
})
33+
}

storage/framework/core/enums/src/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@ export enum Action {
8585
LintFix = 'lint/fix',
8686
Prepublish = 'prepublish',
8787
Release = 'release', // ✅
88+
RouteList = 'route/list', // ✅
8889
ShowFeatureTestReport = 'show-feature-test-report',
8990
Test = 'test',
9091
TestUi = 'test-ui',

storage/framework/core/router/src/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,4 @@ export * from './middleware'
22
export * from './request'
33
export * from './server'
44
export * from './router'
5+
export * from './utils'

storage/framework/core/router/src/router.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -216,6 +216,7 @@ export class Router implements RouterInterface {
216216
return this.routes
217217
}
218218

219+
219220
private setGroupPrefix(prefix: string, options: RouteGroupOptions = {}) {
220221
if (prefix !== '') {
221222
prefix = `/${this.groupPrefix}/${prefix}`.replace(/\/\//g, '/') // remove double slashes in case there are any
@@ -292,8 +293,6 @@ export class Router implements RouterInterface {
292293

293294
path = `${this.apiPrefix}${this.groupPrefix}/${path}`
294295

295-
console.log(path)
296-
297296
// if path ends in "/", then remove it
298297
// e.g. triggered when route is "/"
299298
return path.endsWith('/') ? path.slice(0, -1) : path
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import { ok } from '@stacksjs/error-handling'
2+
import { route } from './router'
3+
4+
export async function listRoutes() {
5+
const routeLists = await route.getRoutes()
6+
7+
console.table(routeLists)
8+
9+
return ok('')
10+
}

0 commit comments

Comments
 (0)