Skip to content
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

add api assistants endpoints #951

Merged
merged 2 commits into from Mar 22, 2024
Merged

add api assistants endpoints #951

merged 2 commits into from Mar 22, 2024

Conversation

alak
Copy link
Collaborator

@alak alak commented Mar 21, 2024

Adding 2 endpoints to the API:

/api/assistants: A paginated endpoint to list/search across all assistants

/api/user/assistants: A endpoint to list current user's assistants and the ones he already used in the past

Copy link
Collaborator

@nsarrazin nsarrazin left a comment

Choose a reason for hiding this comment

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

Seems to work well in local testing! Do you also need to expose the endpoints for subscribing/creating/editing assistants or can you use the form actions directly?

@coyotte508
Copy link
Member

coyotte508 commented Mar 22, 2024

At one point error response between the API endpoints and the hooks.server.ts should be standardized cc @nsarrazin , for now in the hooks the error response looks like this:

	function errorResponse(status: number, message: string) {
		const sendJson =
			event.request.headers.get("accept")?.includes("application/json") ||
			event.request.headers.get("content-type")?.includes("application/json");
		return new Response(sendJson ? JSON.stringify({ error: message }) : message, {
			status,
			headers: {
				"content-type": sendJson ? "application/json" : "text/plain",
			},
		});
	}

It sends {error: ...} instead of {message: ...}

Or we could create a handleError in hooks.server.ts and throw errors in the api endpoints maybe

@alak
Copy link
Collaborator Author

alak commented Mar 22, 2024

Seems to work well in local testing! Do you also need to expose the endpoints for subscribing/creating/editing assistants or can you use the form actions directly?

Yes that's the next step

@alak alak merged commit 5f64024 into main Mar 22, 2024
3 checks passed
@alak alak deleted the adding-assistant-endpoint branch March 22, 2024 14:13
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.

None yet

3 participants