(filename: string)
| 128 | * Handles both tsx (source) and node (dist) execution contexts. |
| 129 | */ |
| 130 | export function getPublicFilePath(filename: string): string { |
| 131 | // Check if we're running from source (tsx) or dist (node) |
| 132 | // In tsx: __dirname is server/src/utils |
| 133 | // In dist: __dirname is dist/utils |
| 134 | const isRunningFromSource = __dirname.includes('server/src'); |
| 135 | |
| 136 | if (isRunningFromSource) { |
| 137 | // tsx: server/src/utils -> server/public |
| 138 | return path.join(__dirname, "../../public", filename); |
| 139 | } else { |
| 140 | // dist: dist/utils -> server/public |
| 141 | return path.join(__dirname, "../../server/public", filename); |
| 142 | } |
| 143 | } |
| 144 | |
| 145 | /** |
| 146 | * Resolve the admin flag for a user using the same rules as the requireAdmin |
no outgoing calls
no test coverage detected