Refactor fetch and post to use axios

Fix set_label id missing in payload use frontend_message_id

pre-commit

Refactor api fetcher/poster to axios create

lint

Remove string literal for path

Revert oasst_api_client.ts

Fix warning httpStatusCode OasstError optional parameter

Refactor remove api base url for local api

Lint add blank line
This commit is contained in:
rjmacarthy
2023-01-13 17:05:10 +00:00
parent fd8bd49638
commit 2a8d38f058
18 changed files with 56 additions and 56 deletions
+1 -1
View File
@@ -5,7 +5,7 @@ import prisma from "src/lib/prismadb";
* Update's the user's data in the database. Accessible only to admins.
*/
const handler = withRole("admin", async (req, res) => {
const { id, role } = JSON.parse(req.body);
const { id, role } = req.body;
await prisma.user.update({
where: {
+1 -1
View File
@@ -5,7 +5,7 @@ import prisma from "src/lib/prismadb";
const handler = withoutRole("banned", async (req, res) => {
// Parse out the local task ID and the interaction contents.
const { id: frontendId, reason } = await JSON.parse(req.body);
const { id: frontendId, reason } = req.body;
const registeredTask = await prisma.registeredTask.findUniqueOrThrow({ where: { id: frontendId } });
+1 -2
View File
@@ -6,8 +6,7 @@ import { withoutRole } from "src/lib/auth";
*/
const handler = withoutRole("banned", async (req, res, token) => {
// Parse out the local message_id, and the interaction contents.
const { message_id, label_map, text } = await JSON.parse(req.body);
const { message_id, label_map, text } = req.body;
const interactionRes = await fetch(`${process.env.FASTAPI_URL}/api/v1/text_labels`, {
method: "POST",
headers: {
+1 -1
View File
@@ -15,7 +15,7 @@ import prisma from "src/lib/prismadb";
*/
const handler = withoutRole("banned", async (req, res, token) => {
// Parse out the local task ID and the interaction contents.
const { id: frontendId, content, update_type } = await JSON.parse(req.body);
const { id: frontendId, content, update_type } = req.body;
// Accept the task so that we can complete it, this will probably go away soon.
const registeredTask = await prisma.registeredTask.findUniqueOrThrow({ where: { id: frontendId } });