Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Howdy! I'm Lou with Optic, and I've been following along in the Managing changes discussion. I wanted to provide a sample of how Optic could fit into your project and get some feedback. I know it's a bit of a challenge to engineer this in after the fact, and hopefully this is inspirational as to what could be. I'll be happy to help refine this sample further.
Here's a 5 minute demo if you'd like to see the end result first.
Optic sample
Looking at the local development environment, and from an understanding gained in the Optic discussion #469, I thought it would be best to capture the requests proxied from the vue web server to the API server run by nodemon:
This lets Optic focus on the API for the project, and not on local browser traffic. It also will catch traffic regardless of whether it originates from localhost or another IP, reducing confusion. If you want to observe traffic to the front-end application, we'd have to set that up slightly differently.
Constraints
Based on the feedback in the Optic discussion #469, I focused on the following elements for local development:
devDependencies
I didn't cover some other feedback in this sample:
api
here for now.Running OpenTogetherTube with Optic in development
To run Optic with OpenTogetherTube, I made a few small chanegs:
devDependency
dev
script to keep the vue front-end on port 8080. This allows Optic to pass a port through for theapi-server
, so Optic can act as a proxy on port 3000, while not interrupting vue's environment. The same would have to be done for Windows, and this would only work for development. For production modes, we can revisit what makes the most sense.optic-dev
andoptic-test
to run thedev
andtest
scripts with Optic, respectively. Alternatively,npx api start
andnpx api run tests
would work directly.This starts the vue front-end on port 8080 as expected, which proxies
/api
traffic to port 3000. Optic picks up the traffic, observes it, and forwards it on to the back-end which runs on an Optic-assigned port at startup (e.g. 3486). When changes are made, nodemon still has the Optic-assigned port and restarts accordingly.Debugging
This required a bit more work to implement, and to avoid contaminating any current run configurations (to allow for comparison), I created a new launch configuration.
Launch with Optic via NPM
will run a third npm script,optic-api-server
, which in turn runsnpx api run api-server
to kick off the api-server. This would take the place ofLaunch Program > Start
. The developer would still need to runnpm run serve
to run the client.Putting it all together
Here's a 5 minute demo
Remaining work
This can be cleaned up a bit. I tried not to mess with existing tooling, such as concurrently. I also didn't do anything for development on Windows, which would follow the same pattern (or may be supported by a tool such as
cross-env
. I didn't want to go too far before seeing how useful this sample was. However, much of this could be consolidated and streamlined to fit the desired workflow.