Skip to content

Commit

Permalink
Added start/stop/delete commands
Browse files Browse the repository at this point in the history
  • Loading branch information
thedanielforum committed Oct 31, 2022
1 parent 6dfe0dd commit 70d497d
Show file tree
Hide file tree
Showing 5 changed files with 111 additions and 1 deletion.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "zefhub",
"version": "0.0.12",
"version": "0.0.13",
"main": "dist/index.js",
"bin": {
"zefhub": "dist/index.js"
Expand Down
35 changes: 35 additions & 0 deletions src/commands/delete.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
/**
* Copyright 2022 Synchronous Technologies Pte Ltd
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

import chalk from "chalk";
import axios from "axios";
import config from "../config";
import { checkAuth } from "../utils/auth";

const del = async () => {
const user = await checkAuth();

const listResponse = await axios.delete(
`${config.host}/v1/deployment/services`,
{
headers: {
"X-Api-Key": user?.apiKey || "",
},
}
);
};

export default del;
32 changes: 32 additions & 0 deletions src/commands/start.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
/**
* Copyright 2022 Synchronous Technologies Pte Ltd
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

import chalk from "chalk";
import axios from "axios";
import config from "../config";
import { checkAuth } from "../utils/auth";

const start = async () => {
const user = await checkAuth();

await axios.put(`${config.host}/v1/service/{id}/start`, {
headers: {
"X-Api-Key": user?.apiKey || "",
},
});
};

export default start;
34 changes: 34 additions & 0 deletions src/commands/stop.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
/**
* Copyright 2022 Synchronous Technologies Pte Ltd
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

import chalk from "chalk";
import axios from "axios";
import config from "../config";
import { checkAuth } from "../utils/auth";

const stop = async () => {
const user = await checkAuth();

await axios.put(`${config.host}/v1/service/{id}/stop`, {
headers: {
"X-Api-Key": user?.apiKey || "",
},
});

console.log(chalk.green("Service stopped"));
};

export default stop;
9 changes: 9 additions & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ import up from "./commands/up";
import deploy from "./commands/deploy";
import list from "./commands/list";
import logs from "./commands/logs";
import start from "./commands/start";
import stop from "./commands/stop";
import del from "./commands/delete";

const program = new Command();

Expand Down Expand Up @@ -63,4 +66,10 @@ easygraphql

easygraphql.command("logs").description("get logs for a service").action(logs);

easygraphql.command("start").description("start a service").action(start);

easygraphql.command("stop").description("stop a service").action(stop);

easygraphql.command("delete").description("delete a service").action(del);

program.parse(process.argv);

0 comments on commit 70d497d

Please sign in to comment.