wing
wing copied to clipboard
tsoa service doesn't work from two different entrypoint locations
I tried this:
I tried using the tsoa service from two different entrypoints (different directories).
It turns out that the folder resolution is based on the location of the entrypoint (*.main.w file)
This happened:
currently the tsoa service is dependant on the entrypoint location, which makes it impossible to work with.
I expected this:
to work the same from any place
Is there a workaround?
No response
Anything else?
No response
Wing Version
No response
Node.js Version
No response
Platform(s)
No response
Community Notes
- Please vote by adding a 👍 reaction to the issue to help us prioritize.
- If you are interested to work on this issue, please leave a comment.
I think the library should require that an absolute path and add support for __dirname
as soon as possible.
And we should deprecate entrypointDir
You'll notice that:
-
wing run ./src/wing/main.w
-
wing run ./src/wing/subfolder/main.w
doesn't work
Given the following:
.
├── package.json
├── src
│ ├── controllers
│ │ └── user.ts
│ └── wing
│ ├── main.w
│ ├── my_api.w
│ └── subfolder
│ └── main.w
└── tsconfig.json
4 directories, 6 files
./package.json
{
"name": "my-wing-app",
"version": "0.0.0",
"description": "A description of my Wing application",
"author": "Your Name",
"license": "MIT",
"wing": true,
"dependencies": {
"@winglibs/tsoa": "^0.1.8"
}
}
./tsconfig.json
{
"compilerOptions": {
"noEmit": true,
"experimentalDecorators": true,
"module": "ESNext",
"moduleResolution": "Bundler",
"lib": ["ESNext"],
"target": "ESNext",
"allowArbitraryExtensions": true,
"allowImportingTsExtensions": false,
"strict": true,
"forceConsistentCasingInFileNames": true,
"isolatedModules": true,
"noPropertyAccessFromIndexSignature": true,
"noUncheckedIndexedAccess": true,
"downlevelIteration": false,
"moduleDetection": "force"
},
"exclude": ["build/", "cdk.out/", "node_modules/"]
}
./src/controllers/user.ts
// src/users/usersController.ts
import {
Body,
Controller,
Get,
Path,
Post,
Query,
Route,
SuccessResponse,
} from "tsoa";
@Route("users")
export class UsersController extends Controller {
@Get("{userId}")
public async getUser(
@Path() userId: number,
@Query() name?: string
): Promise<string> {
return "new UsersService().get(userId, name);"
}
@SuccessResponse("201", "Created") // Custom success response
@Post()
public async createUser(
@Body() requestBody: number
): Promise<void> {
this.setStatus(201); // set return status 201
return;
}
}
./src/wing/subfolder/main.w
bring "../my_api.w" as api;
new api.Service();
./src/wing/my_api.w
bring tsoa;
pub class Service {
new() {
let service = new tsoa.Service(
controllerPathGlobs: ["../controllers/**.ts"],
outputDirectory: "../../build",
routesDir: "../../build"
);
}
}
./src/wing/main.w
bring "./my_api.w" as api;
new api.Service();
Hi,
This issue hasn't seen activity in 90 days. Therefore, we are marking this issue as stale for now. It will be closed after 7 days. Feel free to re-open this issue when there's an update or relevant information to be added. Thanks!