-
Notifications
You must be signed in to change notification settings - Fork 243
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[http-server-javascript] Implement basic project scaffolding. #5906
[http-server-javascript] Implement basic project scaffolding. #5906
Conversation
All changed packages have been documented.
|
You can try these changes here
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please fix npm install
as discussed.
@allenjzhang The @markcowl I'm going to resolve the comments per our discussion. There's more work to be done here around scaffolding hooks and proper use of the compiler APIs. |
…oft#5906) Adds a new scaffolding command for http-server-js. To run it, a customer calls `npx hsj-scaffold`. It is opinionated, but uses some settings from tspconfig.yaml. - Generates a server entrypoint using either express or Node depending on whether tspconfig.yaml has `express: true` in the emitter options. - Generates a controller for each interface as a class that implements the business logic interface. For now, these controller methods simply throw 501 Not Implemented. - Creates a suitable tsconfig.json to compile the project. - Modifies package.json with scripts to build and start the server. - Adds vscode tasks/launch configurations for debugging. Some changes to the generator itself were required: - Added a new helper module, `helpers/http`, that defines an `HttpResponder` as an object containing a function that can respond to an HTTP request. If the business logic implementations throw an object that is an HttpResponder, then it will be used to respond to the request instead of the default `onInternalError` handler. This makes it easy for any route controller handler to construct and reply with any error they like without having to satisfy the type checker.
Adds a new scaffolding command for http-server-js. To run it, a customer calls
npx hsj-scaffold
. It is opinionated, but uses some settings from tspconfig.yaml.express: true
in the emitter options.Some changes to the generator itself were required:
helpers/http
, that defines anHttpResponder
as an object containing a function that can respond to an HTTP request. If the business logic implementations throw an object that is an HttpResponder, then it will be used to respond to the request instead of the defaultonInternalError
handler. This makes it easy for any route controller handler to construct and reply with any error they like without having to satisfy the type checker.