feat: new api endpoints to get and update neon managed projects (#751)
Some checks failed
all-good: Did all the other checks pass? / all-good (push) Has been cancelled
Ensure Prisma migrations are in sync with the schema / check_prisma_migrations (22.x) (push) Has been cancelled
Docker Emulator Test / docker (push) Has been cancelled
Docker Server Build and Push / Docker Build and Push Server (push) Has been cancelled
Docker Server Test / docker (push) Has been cancelled
Runs E2E API Tests / build (22.x) (push) Has been cancelled
Lint & build / lint_and_build (latest) (push) Has been cancelled
Dev Environment Test / restart-dev-and-test (push) Has been cancelled
Run setup tests / setup-tests (push) Has been cancelled
TOC Generator / TOC Generator (push) Has been cancelled
Update pull request branches / Update pull request branches (push) Has been cancelled

Added GET and PATCH endpoint for Neon managed project with
`secret-admin-key` auth. The API handler is same as internal projects
API - `/internal/projects/current`
This commit is contained in:
Shridhar Deshmukh 2025-07-10 19:41:35 +02:00 committed by GitHub
parent cce15ee0f9
commit daff52250e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 175 additions and 0 deletions

View File

@ -0,0 +1,4 @@
import { projectsCrudHandlers } from "../../../../internal/projects/current/crud";
export const GET = projectsCrudHandlers.readHandler;
export const PATCH = projectsCrudHandlers.updateHandler;

View File

@ -0,0 +1,171 @@
import { it } from "../../../../../../../helpers";
import { Auth, Project, niceBackendFetch } from "../../../../../../backend-helpers";
it("get project details", async ({ expect }) => {
await Auth.Otp.signIn();
const { adminAccessToken } = await Project.createAndGetAdminToken();
const response = await niceBackendFetch("/api/v1/integrations/neon/projects/current", {
accessType: "admin",
headers: {
'x-stack-admin-access-token': adminAccessToken,
},
});
expect(response).toMatchInlineSnapshot(`
NiceResponse {
"status": 200,
"body": {
"config": {
"allow_localhost": true,
"allow_team_api_keys": false,
"allow_user_api_keys": false,
"client_team_creation_enabled": false,
"client_user_deletion_enabled": false,
"create_team_on_sign_up": false,
"credential_enabled": true,
"domains": [],
"email_config": { "type": "shared" },
"email_theme": "default-light",
"enabled_oauth_providers": [],
"magic_link_enabled": false,
"oauth_account_merge_strategy": "link_method",
"oauth_providers": [],
"passkey_enabled": false,
"sign_up_enabled": true,
"team_creator_default_permissions": [{ "id": "team_admin" }],
"team_member_default_permissions": [{ "id": "team_member" }],
"user_default_permissions": [],
},
"created_at_millis": <stripped field 'created_at_millis'>,
"description": "",
"display_name": "New Project",
"id": "<stripped UUID>",
"is_production_mode": false,
"user_count": 0,
},
"headers": Headers { <some fields may have been hidden> },
}
`);
});
it("creates and updates the basic project information of a project", async ({ expect }) => {
await Auth.Otp.signIn();
const { adminAccessToken } = await Project.createAndGetAdminToken();
const response = await niceBackendFetch("/api/v1/integrations/neon/projects/current", {
accessType: "admin",
method: "PATCH",
headers: {
'x-stack-admin-access-token': adminAccessToken,
},
body: {
display_name: "Updated Project",
description: "Updated description",
is_production_mode: true,
},
});
expect(response).toMatchInlineSnapshot(`
NiceResponse {
"status": 200,
"body": {
"config": {
"allow_localhost": true,
"allow_team_api_keys": false,
"allow_user_api_keys": false,
"client_team_creation_enabled": false,
"client_user_deletion_enabled": false,
"create_team_on_sign_up": false,
"credential_enabled": true,
"domains": [],
"email_config": { "type": "shared" },
"email_theme": "default-light",
"enabled_oauth_providers": [],
"magic_link_enabled": false,
"oauth_account_merge_strategy": "link_method",
"oauth_providers": [],
"passkey_enabled": false,
"sign_up_enabled": true,
"team_creator_default_permissions": [{ "id": "team_admin" }],
"team_member_default_permissions": [{ "id": "team_member" }],
"user_default_permissions": [],
},
"created_at_millis": <stripped field 'created_at_millis'>,
"description": "Updated description",
"display_name": "Updated Project",
"id": "<stripped UUID>",
"is_production_mode": true,
"user_count": 0,
},
"headers": Headers { <some fields may have been hidden> },
}
`);
});
it("creates and updates the email config of a project", async ({ expect }) => {
await Auth.Otp.signIn();
const { adminAccessToken } = await Project.createAndGetAdminToken();
const response = await niceBackendFetch("/api/v1/integrations/neon/projects/current", {
accessType: "admin",
method: "PATCH",
headers: {
'x-stack-admin-access-token': adminAccessToken,
},
body: {
config: {
email_config: {
"host": "smtp.example.com",
"port": 587,
"username": "username",
"password": "this-is-a-placeholder-password",
"sender_email": "from@example.com",
"sender_name": "Test Sender",
"type": "standard",
},
},
},
});
expect(response).toMatchInlineSnapshot(`
NiceResponse {
"status": 200,
"body": {
"config": {
"allow_localhost": true,
"allow_team_api_keys": false,
"allow_user_api_keys": false,
"client_team_creation_enabled": false,
"client_user_deletion_enabled": false,
"create_team_on_sign_up": false,
"credential_enabled": true,
"domains": [],
"email_config": {
"host": "smtp.example.com",
"password": "this-is-a-placeholder-password",
"port": 587,
"sender_email": "from@example.com",
"sender_name": "Test Sender",
"type": "standard",
"username": "username",
},
"email_theme": "default-light",
"enabled_oauth_providers": [],
"magic_link_enabled": false,
"oauth_account_merge_strategy": "link_method",
"oauth_providers": [],
"passkey_enabled": false,
"sign_up_enabled": true,
"team_creator_default_permissions": [{ "id": "team_admin" }],
"team_member_default_permissions": [{ "id": "team_member" }],
"user_default_permissions": [],
},
"created_at_millis": <stripped field 'created_at_millis'>,
"description": "",
"display_name": "New Project",
"id": "<stripped UUID>",
"is_production_mode": false,
"user_count": 0,
},
"headers": Headers { <some fields may have been hidden> },
}
`);
});