Refactor Northflank connection code and improve documentation

- Cleaned up code formatting in Northflank connection functions and schemas for better readability.
- Enhanced error logging in the Northflank connection service to include additional context.
- Updated Northflank integration documentation for clarity and accuracy, including minor text corrections and URL adjustments.
- Removed unnecessary whitespace in various files for consistency.
This commit is contained in:
Your Name
2025-10-22 10:53:46 -03:00
parent 2385e85baf
commit c3899a0e81
6 changed files with 18 additions and 31 deletions

View File

@@ -51,4 +51,3 @@ export const registerNorthflankConnectionRouter = async (server: FastifyZodProvi
}
});
};

View File

@@ -50,15 +50,12 @@ export const listProjects = async (appConnection: TNorthflankConnection): Promis
data: {
data: { projects }
}
} = await request.get<{ data: { projects: TNorthflankProject[] } }>(
`${NORTHFLANK_API_URL}/v1/projects`,
{
headers: {
Authorization: `Bearer ${credentials.apiToken}`,
Accept: "application/json"
}
} = await request.get<{ data: { projects: TNorthflankProject[] } }>(`${NORTHFLANK_API_URL}/v1/projects`, {
headers: {
Authorization: `Bearer ${credentials.apiToken}`,
Accept: "application/json"
}
);
});
return projects;
} catch (error: unknown) {
@@ -74,4 +71,3 @@ export const listProjects = async (appConnection: TNorthflankConnection): Promis
});
}
};

View File

@@ -11,11 +11,7 @@ import {
import { NorthflankConnectionMethod } from "./northflank-connection-enums";
export const NorthflankConnectionApiTokenCredentialsSchema = z.object({
apiToken: z
.string()
.trim()
.min(1, "API Token required")
.describe(AppConnections.CREDENTIALS.NORTHFLANK.apiToken)
apiToken: z.string().trim().min(1, "API Token required").describe(AppConnections.CREDENTIALS.NORTHFLANK.apiToken)
});
const BaseNorthflankConnectionSchema = BaseAppConnectionSchema.extend({
@@ -36,9 +32,9 @@ export const SanitizedNorthflankConnectionSchema = z.discriminatedUnion("method"
export const ValidateNorthflankConnectionCredentialsSchema = z.discriminatedUnion("method", [
z.object({
method: z.literal(NorthflankConnectionMethod.ApiToken).describe(
AppConnections.CREATE(AppConnection.Northflank).method
),
method: z
.literal(NorthflankConnectionMethod.ApiToken)
.describe(AppConnections.CREATE(AppConnection.Northflank).method),
credentials: NorthflankConnectionApiTokenCredentialsSchema.describe(
AppConnections.CREATE(AppConnection.Northflank).credentials
)
@@ -62,4 +58,3 @@ export const NorthflankConnectionListItemSchema = z.object({
app: z.literal(AppConnection.Northflank),
methods: z.nativeEnum(NorthflankConnectionMethod).array()
});

View File

@@ -19,7 +19,7 @@ export const northflankConnectionService = (getAppConnection: TGetAppConnectionF
return projects;
} catch (error) {
logger.error(error, "Failed to establish connection with Northflank");
logger.error({ error, connectionId, actor: actor.type }, "Failed to establish connection with Northflank");
return [];
}
};
@@ -28,4 +28,3 @@ export const northflankConnectionService = (getAppConnection: TGetAppConnectionF
listProjects
};
};

View File

@@ -17,11 +17,11 @@ Infisical supports the use of [API Tokens](https://northflank.com/docs/v1/api/us
![Create API Role](/images/app-connections/northflank/step-1.png)
Click in **Create API role**.
Click on **Create API role**.
![Create API Role](/images/app-connections/northflank/step-2.png)
Select all the projects you want this role to have access, or leave this unchecked if you want to give access to all project.
Select all the projects you want this role to have access to, or leave this unchecked if you want to give access to all projects.
![Create API Role](/images/app-connections/northflank/step-3.png)
@@ -32,7 +32,7 @@ Infisical supports the use of [API Tokens](https://northflank.com/docs/v1/api/us
Scroll to the bottom and save the API role.
</Step>
<Step title="Create an API Token">
Click on the **API** -> **Tokens** menu on the left and then in the **Create API token** button.
Click on the **API** -> **Tokens** menu on the left and then click the **Create API token** button.
![Create API Token](/images/app-connections/northflank/step-5.png)
@@ -84,7 +84,7 @@ Infisical supports the use of [API Tokens](https://northflank.com/docs/v1/api/us
```bash Request
curl --request POST \
--url http://localhost:8080/api/v1/app-connections/northflank \
--url https://app.infisical.com/api/v1/app-connections/northflank \
--header 'Content-Type: application/json' \
--data '{
"name": "my-northflank-connection",
@@ -104,7 +104,7 @@ Infisical supports the use of [API Tokens](https://northflank.com/docs/v1/api/us
"id": "a1b2c3d4-5678-90ab-cdef-1234567890ab",
"name": "my-northflank-connection",
"description": null,
"projectId": "7ffbb072-2575-495a-b5b0-127f88caef78",
"projectId": "abcdef12-3456-7890-abcd-ef1234567890",
"version": 1,
"orgId": "abcdef12-3456-7890-abcd-ef1234567890",
"createdAt": "2025-01-23T10:15:00.000Z",
@@ -112,7 +112,6 @@ Infisical supports the use of [API Tokens](https://northflank.com/docs/v1/api/us
"isPlatformManagedCredentials": false,
"credentialsHash": "d41d8cd98f00b204e9800998ecf8427e",
"gatewayId":null,
"projectId":"abcdef12-3456-7890-abcd-ef1234567890"
"app": "northflank",
"method": "api-token",
"credentials": {}

View File

@@ -13,8 +13,8 @@ import {
import { APP_CONNECTION_MAP, getAppConnectionMethodDetails } from "@app/helpers/appConnections";
import { AppConnection } from "@app/hooks/api/appConnections/enums";
import {
TNorthflankConnection,
NorthflankConnectionMethod
NorthflankConnectionMethod,
TNorthflankConnection
} from "@app/hooks/api/appConnections/types/northflank-connection";
import {
@@ -86,7 +86,7 @@ export const NorthflankConnectionForm = ({ appConnection, onSubmit }: Props) =>
{Object.values(NorthflankConnectionMethod).map((method) => {
return (
<SelectItem value={method} key={method}>
{getAppConnectionMethodDetails(method).name}{" "}
{getAppConnectionMethodDetails(method).name}
</SelectItem>
);
})}
@@ -133,4 +133,3 @@ export const NorthflankConnectionForm = ({ appConnection, onSubmit }: Props) =>
</FormProvider>
);
};