Skip to content

Commit

Permalink
Merge pull request #473 from SquirrelCorporation/chore-add-check
Browse files Browse the repository at this point in the history
[CHORE] Add type exports and fix response types for connection checks
  • Loading branch information
SquirrelDeveloper authored Nov 14, 2024
2 parents 8a36098 + be913b2 commit 303c467
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 8 deletions.
8 changes: 5 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,16 +39,18 @@ curl https://raw.githubusercontent.com/SquirrelCorporation/SquirrelServersManage
See [QuickStart](https://squirrelserversmanager.io/docs/quickstart)


For the others methods, **Edit the `.env` file before anything.**
For the others methods, **[Edit the `.env` file before anything](https://squirrelserversmanager.io/docs/quickstart#env-file).**

---

## 🛳️ Production
## 🛳️ Manual Install: Production
Clone the project, [edit the `.env`](https://squirrelserversmanager.io/docs/quickstart#env-file) file and run:
```shell
docker compose up
```

## 🏗️ Development
## 🏗️ Manual Install: Development
Clone the project, [edit the `.env`](https://squirrelserversmanager.io/docs/quickstart#env-file) file and run:
```shell
docker compose -f docker-compose.dev.yml up
```
Expand Down
2 changes: 1 addition & 1 deletion client/src/components/NewDeviceModal/NewDeviceModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,7 @@ const NewDeviceModal: React.FC<NewDeviceModalProps> = (props) => {
label: 'Control Node URL',
placeholder: 'http://192.168.0.1',
rules: [{ required: true }],
initialValue: currentUser?.settings.masterNodeUrl
initialValue: currentUser?.settings?.masterNodeUrl
? currentUser?.settings.masterNodeUrl
: `http://${document.location.hostname}:8000`,
},
Expand Down
13 changes: 9 additions & 4 deletions server/src/controllers/rest/devices/check-connection.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { API } from 'ssm-shared-lib';
import DeviceAuthRepo from '../../../data/database/repository/DeviceAuthRepo';
import DeviceRepo from '../../../data/database/repository/DeviceRepo';
import { ForbiddenError, InternalError, NotFoundError } from '../../../middlewares/api/ApiError';
Expand Down Expand Up @@ -36,7 +37,9 @@ export const postCheckAnsibleConnection = async (req, res) => {
becomePass,
sshKeyPass,
);
new SuccessResponse('Post CheckAnsibleConnection', { taskId: taskId }).send(res);
new SuccessResponse('Post CheckAnsibleConnection', {
taskId: taskId,
} as API.CheckAnsibleConnection).send(res);
} catch (error: any) {
throw new InternalError(error.message);
}
Expand All @@ -63,7 +66,7 @@ export const postCheckDockerConnection = async (req, res) => {
new SuccessResponse('Post CheckDockerConnection', {
connectionStatus: result.status,
errorMessage: result.message,
}).send(res);
} as API.CheckDockerConnection).send(res);
} catch (error: any) {
throw new InternalError(error.message);
}
Expand All @@ -84,7 +87,7 @@ export const getCheckDeviceDockerConnection = async (req, res) => {
new SuccessResponse('Post CheckDeviceDockerConnection', {
connectionStatus: result.status,
errorMessage: result.message,
}).send(res);
} as API.CheckDockerConnection).send(res);
} catch (error: any) {
throw new InternalError(error.message);
}
Expand All @@ -105,7 +108,9 @@ export const getCheckDeviceAnsibleConnection = async (req, res) => {
}
try {
const { taskId } = await DeviceUseCases.checkDeviceAnsibleConnection(req.user, device);
new SuccessResponse('Post CheckDeviceAnsibleConnection', { taskId: taskId }).send(res);
new SuccessResponse('Post CheckDeviceAnsibleConnection', {
taskId: taskId,
} as API.CheckAnsibleConnection).send(res);
} catch (error: any) {
throw new InternalError(error.message);
}
Expand Down
9 changes: 9 additions & 0 deletions shared-lib/src/types/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,15 @@ export type NewDevice = {
success: boolean;
};

export type CheckAnsibleConnection = {
taskId: string;
}

export type CheckDockerConnection = {
connectionStatus: string;
errorMessage?: string;
}

export type VersionData = {
kernel?: string;
openssl?: string;
Expand Down

0 comments on commit 303c467

Please sign in to comment.