New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: public api start #674
Conversation
Important Auto Review SkippedAuto reviews are limited to the following labels: coderabbit. Please add one of these labels to enable auto reviews. Please check the settings in the CodeRabbit UI or the To trigger a single review, invoke the WalkthroughThis update introduces a comprehensive suite for document management through an API, including functionalities for managing documents, recipients, fields, and API tokens. It encompasses creating, updating, deleting, and retrieving documents, along with recipient and field management. Additionally, it enhances user experience by providing a dashboard for API token management, enabling users to generate, view, and delete tokens with ease. The implementation is supported by schema validations, server-side logic, and user interface components, ensuring a seamless integration into the existing system. Changes
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (invoked as PR comments)
Additionally, you can add CodeRabbit Configration File (
|
The latest updates on your projects. Learn more about Vercel for Git ↗︎
2 Ignored Deployments
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Review Status
Actionable comments generated: 0
Configuration used: CodeRabbit UI
Files ignored due to path filters (1)
package-lock.json
is excluded by:!**/*.json
Files selected for processing (1)
- packages/prisma/schema.prisma (2 hunks)
Files skipped from review as they are similar to previous changes (1)
- packages/prisma/schema.prisma
This PR adds the public-facing API.
The public API will allow users to interact with Documenso programmatically. At the moment, there are 5 available endpoints:
GET /documents
page
andperPage
, but they are not mandatoryGET /documents/:id
DELETE /documents/:id
POST /documents
PATCH /documents/:id/send-for-signing
The users are authenticated through API tokens. The users can create one or more tokens in their account settings, and each token will be available for 1 year (duration open to suggestions/changes).
Each time the user makes a request, the app checks if the token exists and if it's valid. The app will return
401
(unauthorized) and the appropriate error message if either is false. If both are true AND the user uses the correct HTTP verb and passes the required URL parameters and body, the API call will be successful.Code overview:
@documenso/packages/lib/trpc/api-contract
- this folder contains thecontract
andschema
files. Thecontract.ts
file describes the structure of the API, the format of the requests and responses, and how to authenticate your API calls, among others. Theschema.ts
file contains the Zod schemas used in the API contract.@documenso/packages/trpc/server/api-token-router
- this folder contains therouter.rs
andschema.ts
files. Here are the tRPC procedures used on the frontend. That is, the user's settings page, where the user can list/create/delete API tokens.@documenso/packages/trpc/tsconfig.json
- I added"strict": true
because that's what's suggested in thets-rest
documentation. (source)[...ts-rest].tsx
- This file contains the implementation of the API. You can see the logic behind each route.Summary by CodeRabbit