Skip to content

Backend frontend agent#1849

Merged
Artuomka merged 2 commits into
mainfrom
backend-frontend_agent
Jun 25, 2026
Merged

Backend frontend agent#1849
Artuomka merged 2 commits into
mainfrom
backend-frontend_agent

Conversation

@Artuomka

@Artuomka Artuomka commented Jun 25, 2026

Copy link
Copy Markdown
Collaborator

Summary by CodeRabbit

  • New Features

    • Added Sitenova support to the app, including new site and internal endpoints for end-user registration, login, row management, and raw query execution.
    • Introduced public-read access checks and end-user token handling for connection-specific access.
  • Bug Fixes

    • Expanded public CORS handling so the new Sitenova routes work correctly.
    • Added end-to-end coverage for authentication, access control, and CRUD flows.

Artuomka added 2 commits June 23, 2026 09:57
…entication and CRUD operations

- Add SitenovaSiteController for handling user registration, login, and data operations.
- Create SitenovaModule to encapsulate the microservice's functionality and dependencies.
- Implement use cases for registering and logging in end-users, executing raw queries, and managing data.
- Introduce interfaces for use cases to ensure consistent implementation.
- Enhance public CORS middleware to support new Sitenova routes.
- Develop end-to-end tests for user authentication and data management functionalities.
Copilot AI review requested due to automatic review settings June 25, 2026 06:42
@Artuomka Artuomka enabled auto-merge June 25, 2026 06:42
@coderabbitai

coderabbitai Bot commented Jun 25, 2026

Copy link
Copy Markdown

Review Change Stack

Caution

Review failed

Pull request was closed or merged during review

📝 Walkthrough

Walkthrough

Sitenova is added to the backend with new contracts, guards, use cases, controllers, module wiring, public CORS matching, and end-to-end tests for raw query, auth, CRUD, and public read flows.

Changes

Sitenova microservice feature

Layer / File(s) Summary
Shared contracts and DTOs
backend/src/common/data-injection.tokens.ts, backend/src/microservices/sitenova-microservice/data-structures/*, backend/src/microservices/sitenova-microservice/dto/*, backend/src/microservices/sitenova-microservice/use-cases/*interface.ts
New Sitenova data shapes, DTOs, interfaces, and DI tokens define the request/response and use-case contracts for raw query and end-user auth.
Auth service and guards
backend/src/microservices/sitenova-microservice/services/sitenova-enduser-auth.service.ts, backend/src/microservices/sitenova-microservice/guards/*.ts
End-user JWT signing/verification and the new guards enforce connection-bound auth and public-read gating.
Raw-query and auth use cases
backend/src/microservices/sitenova-microservice/use-cases/sitenova-*.use.case.ts
Raw-query execution and end-user register/login use cases implement the new database and authentication paths.
HTTP controllers
backend/src/microservices/sitenova-microservice/sitenova-*.controller.ts
The internal raw-query endpoint and the Sitenova auth, public-read, and CRUD routes map request DTOs to the new use cases and table access calls.
Module and middleware wiring
backend/src/microservices/sitenova-microservice/sitenova.module.ts, backend/src/app.module.ts, backend/src/middlewares/public-crud-cors.middleware.ts
SitenovaModule is added to the Nest graph, the app imports it, and public CORS matching expands to /sitenova routes.
E2E coverage
backend/test/ava-tests/non-saas-tests/non-saas-sitenova-microservice-e2e.test.ts
The AVA suite provisions test tables and covers internal raw query, end-user auth, CRUD, public-read, and connection-scoped token behavior.

Sequence Diagram(s)

sequenceDiagram
  participant SitenovaSiteController
  participant SitenovaRegisterEndUserUseCase
  participant SitenovaLoginEndUserUseCase
  participant SitenovaEndUserAuthService
  SitenovaSiteController->>SitenovaRegisterEndUserUseCase: POST /:connectionId/auth/register
  SitenovaRegisterEndUserUseCase->>SitenovaEndUserAuthService: signEndUserToken(connectionId, sub)
  SitenovaEndUserAuthService-->>SitenovaRegisterEndUserUseCase: token
  SitenovaRegisterEndUserUseCase-->>SitenovaSiteController: token + user
  SitenovaSiteController->>SitenovaLoginEndUserUseCase: POST /:connectionId/auth/login
  SitenovaLoginEndUserUseCase->>SitenovaEndUserAuthService: signEndUserToken(connectionId, sub)
  SitenovaEndUserAuthService-->>SitenovaLoginEndUserUseCase: token
  SitenovaLoginEndUserUseCase-->>SitenovaSiteController: token + user
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~60 minutes

Possibly related PRs

Suggested reviewers

  • gugu
  • lyubov-voloshko

Poem

I hopped through sitenova by moonlit leaf,
Signed tiny tokens with a whisker of brief.
Raw queries thumped, and the rows all gleamed,
While guards and reads in tidy lines teamed.
Hoppy trails! 🐰

🚥 Pre-merge checks | ✅ 3 | ❌ 3

❌ Failed checks (2 warnings, 1 inconclusive)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 57.14% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
Security Check ⚠️ Warning SitenovaSiteController hardcodes userId:'' for create/update/delete, so guarded end-user writes no longer use the token’s subject for downstream authorization. Pass request.sitenovaEndUser?.sub into the write handlers and reject blank optional fields at the DTO boundary so authz stays enforced.
Title check ❓ Inconclusive The title is too vague and generic to convey the main change in the changeset. Use a concise, specific title such as "Add Sitenova microservice endpoints and auth flow".
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch backend-frontend_agent

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds a new backend “SiteNova” microservice surface that exposes (1) an internal, microservice-authenticated raw SQL provisioning endpoint and (2) a browser-facing generated-site API for end-user register/login plus data CRUD, along with an AVA e2e test suite and CORS support for the new public routes.

Changes:

  • Introduces SitenovaModule with internal (/internal/sitenova/...) and public (/sitenova/...) controllers, DTOs, guards, and use cases.
  • Adds end-user JWT issuance/verification via SitenovaEndUserAuthService (per-connection signing keys).
  • Extends the existing wildcard CORS middleware to cover the new SiteNova public API and adds a new e2e test file.

Reviewed changes

Copilot reviewed 20 out of 20 changed files in this pull request and generated 7 comments.

Show a summary per file
File Description
backend/test/ava-tests/non-saas-tests/non-saas-sitenova-microservice-e2e.test.ts Adds e2e coverage for internal raw-query auth + public SiteNova auth and CRUD flows.
backend/src/middlewares/public-crud-cors.middleware.ts Extends wildcard CORS handling to include SiteNova public endpoints.
backend/src/microservices/sitenova-microservice/use-cases/sitenova-use-cases.interface.ts Defines the raw-query use case interface contract.
backend/src/microservices/sitenova-microservice/use-cases/sitenova-site-use-cases.interface.ts Defines register/login end-user use case interfaces.
backend/src/microservices/sitenova-microservice/use-cases/sitenova-register-enduser.use.case.ts Implements end-user registration into a connection-scoped users table.
backend/src/microservices/sitenova-microservice/use-cases/sitenova-login-enduser.use.case.ts Implements end-user login with password verification and token minting.
backend/src/microservices/sitenova-microservice/use-cases/sitenova-execute-raw-query.use.case.ts Implements internal write-capable raw SQL execution against a connection.
backend/src/microservices/sitenova-microservice/sitenova.module.ts Wires controllers, guards, services, and use cases; applies microservice auth middleware to internal controller.
backend/src/microservices/sitenova-microservice/sitenova-site.controller.ts Adds the browser-facing SiteNova API: register/login and CRUD endpoints.
backend/src/microservices/sitenova-microservice/sitenova-internal.controller.ts Adds the microservice-authenticated raw-query endpoint for provisioning.
backend/src/microservices/sitenova-microservice/services/sitenova-enduser-auth.service.ts Adds per-connection HS256 token signing/verification for generated-site visitors.
backend/src/microservices/sitenova-microservice/guards/sitenova-public-read.guard.ts Enforces public-read policy (Cedar) for SiteNova read endpoints.
backend/src/microservices/sitenova-microservice/guards/sitenova-enduser-auth.guard.ts Enforces SiteNova end-user JWT for write endpoints.
backend/src/microservices/sitenova-microservice/dto/sitenova.dtos.ts Adds DTOs for internal raw-query requests.
backend/src/microservices/sitenova-microservice/dto/sitenova-site.dtos.ts Adds DTOs for public SiteNova register/login and CRUD payloads.
backend/src/microservices/sitenova-microservice/data-structures/sitenova.ds.ts Adds DS for internal raw-query use case inputs.
backend/src/microservices/sitenova-microservice/data-structures/sitenova-site.ds.ts Adds DS/constants for end-user auth (audience/ttl/payload).
backend/src/microservices/sitenova-microservice/data-structures/sitenova-responses.ds.ts Adds response RO for raw-query results.
backend/src/common/data-injection.tokens.ts Registers new SiteNova use case injection tokens.
backend/src/app.module.ts Registers SitenovaModule in the main application module.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +5 to +8
// Browser-facing SiteNova site API (register/login + data CRUD) served to AI-generated sites from
// arbitrary CDN origins. Anchored at the start of the path so it matches `/sitenova/...` but never
// the server-to-server `/internal/sitenova/...` controller, which needs no CORS.
const SITENOVA_PUBLIC_ROUTE_REGEX = /^\/sitenova\//;
Comment on lines +55 to +61
const hashedPassword = await Encryptor.hashUserPassword(password);
const rowToInsert: Record<string, unknown> = { ...extra, [emailField]: email, [passwordField]: hashedPassword };
await dao.addRowInTable(tableName, rowToInsert, userEmail);

const token = await this.endUserAuthService.signEndUserToken(connectionId, email);
const user: Record<string, unknown> = { ...extra, [emailField]: email };
return { token, user };
Comment on lines +26 to +29
const connection = await this._dbContext.connectionRepository.findAndDecryptConnection(
connectionId,
masterPassword as string,
);
Comment on lines +130 to +140
const inputData: PureGetRowsDs = {
connectionId,
masterPwd: '',
page: body.page ?? 0,
perPage: body.perPage ?? 0,
query: {},
searchingFieldValue: body.search ?? '',
tableName: body.tableName,
userId: undefined,
filters: body.filters,
};
Comment on lines +173 to +180
const inputData: PureCreateRowDs = {
connectionId,
masterPwd: '',
row: body.row,
tableName: body.tableName,
userId: '',
};
return await this.pureCreateRowInTableUseCase.execute(inputData, InTransactionEnum.OFF);
Comment on lines +36 to +44
const tableStructure = await dao.getTableStructure(tableName, userEmail);

const filteringFields = parseFilteringFieldsFromBodyData({ [emailField]: { eq: email } }, tableStructure);
const settings = buildDAOsTableSettingsDs(buildCommonTableSettingsInput(null), null);
const found = await dao.getRowsFromTable(
tableName,
settings,
1,
1,
Comment on lines +36 to +44
const tableStructure = await dao.getTableStructure(tableName, userEmail);

// Direct, parameterized DAO read (NOT the public column-filtered path) so the hashed password
// column is available to verify against. The hash is never returned to the caller.
const filteringFields = parseFilteringFieldsFromBodyData({ [emailField]: { eq: email } }, tableStructure);
const settings = buildDAOsTableSettingsDs(buildCommonTableSettingsInput(null), null);
const found = await dao.getRowsFromTable(
tableName,
settings,
@Artuomka Artuomka merged commit 95595f5 into main Jun 25, 2026
16 of 18 checks passed
@Artuomka Artuomka deleted the backend-frontend_agent branch June 25, 2026 06:53
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