ReviewOS

also looking at this

stacks/stx

chore: wip stx improvements

#1649
Merged fingersandmind wants to merge feat/stx-improvements into main
241 files +19022 -1323
packages/api/test/scanner.test.tsadded+41-0
Changes to packages/api/test/scanner.test.ts
@@ -0,0 +1,41 @@
1import { describe, expect, test } from 'bun:test'
2import { filePathToRoutePath } from '../src'
3
4describe('filePathToRoutePath', () => {
5 test('converts simple file path', () => {
6 expect(filePathToRoutePath('posts.ts')).toBe('/api/posts')
7 })
8
9 test('converts nested file path', () => {
10 expect(filePathToRoutePath('posts/comments.ts')).toBe('/api/posts/comments')
11 })
12
13 test('converts dynamic param [id]', () => {
14 expect(filePathToRoutePath('posts/[id].ts')).toBe('/api/posts/:id')
15 })
16
17 test('converts nested dynamic params', () => {
18 expect(filePathToRoutePath('posts/[id]/comments.ts')).toBe('/api/posts/:id/comments')
19 })
20
21 test('converts multiple dynamic params', () => {
22 expect(filePathToRoutePath('posts/[postId]/comments/[commentId].ts'))
23 .toBe('/api/posts/:postId/comments/:commentId')
24 })
25
26 test('handles index files', () => {
27 expect(filePathToRoutePath('posts/index.ts')).toBe('/api/posts')
28 })
29
30 test('handles .js extension', () => {
31 expect(filePathToRoutePath('users.js')).toBe('/api/users')
32 })
33
34 test('uses custom prefix', () => {
35 expect(filePathToRoutePath('posts.ts', '/v1')).toBe('/v1/posts')
36 })
37
38 test('handles empty prefix', () => {
39 expect(filePathToRoutePath('posts.ts', '')).toBe('/posts')
40 })
41})