Skip to content
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

feat, introduce an API Server to run commands through HTTP server #7056

Merged
merged 20 commits into from
Feb 17, 2023

Conversation

davidfirst
Copy link
Member

To start the server, run bit server, which creates a new express server locally on port 3000.
To run a command on this server, make a POST request to /api/cli/:cmd. Optionally, in the body, add the args and the flags of the command. For example:

http://localhost:3000/api/cli/list

{
    "args": ["teambit.workspace"],
    "options": {
        "ids": true
    }
}

The result is a JSON object with the same output you would get when running the command with --json flag.
If the command doesn't accept json flag, it'll throw a descriptive error about it.

The main goal of this server is to provide a fast way to communicate with bit (e.g. vscode extension makes requests to bit). Because the server is running constantly, there is no bootstrap penalty we have in the CLI. Also, once the components are loaded in-memory, they're accessible immediately at no cost.
It runs a "watcher" in the background to make sure to update/clean the memory cache when needed.

@davidfirst davidfirst changed the title feat, introduce API Server to run commands through HTTP server feat, introduce an API Server to run commands through HTTP server Feb 17, 2023
@davidfirst davidfirst merged commit 7ae80f6 into master Feb 17, 2023
@davidfirst davidfirst deleted the bit-server branch February 17, 2023 22:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants