Skip to content

Commit

Permalink
prettier
Browse files Browse the repository at this point in the history
  • Loading branch information
KMKoushik committed Sep 4, 2024
1 parent 259937c commit 7e1a63e
Show file tree
Hide file tree
Showing 2 changed files with 80 additions and 80 deletions.
72 changes: 36 additions & 36 deletions apps/web/src/server/public-api/api/contacts/delete-contact.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,49 +5,49 @@ import { deleteContact } from "~/server/service/contact-service";
import { getContactBook } from "../../api-utils";

const route = createRoute({
method: "delete",
path: "/v1/contactBooks/{contactBookId}/contacts/{contactId}",
request: {
params: z.object({
contactBookId: z.string().openapi({
param: {
name: "contactBookId",
in: "path",
},
example: "cuiwqdj74rygf74",
}),
contactId: z.string().openapi({
param: {
name: "contactId",
in: "path",
},
example: "cuiwqdj74rygf74",
}),
}),
},
responses: {
200: {
content: {
"application/json": {
schema: z.object({ success: z.boolean() }),
},
},
description: "Contact deleted successfully",
method: "delete",
path: "/v1/contactBooks/{contactBookId}/contacts/{contactId}",
request: {
params: z.object({
contactBookId: z.string().openapi({
param: {
name: "contactBookId",
in: "path",
},
example: "cuiwqdj74rygf74",
}),
contactId: z.string().openapi({
param: {
name: "contactId",
in: "path",
},
example: "cuiwqdj74rygf74",
}),
}),
},
responses: {
200: {
content: {
"application/json": {
schema: z.object({ success: z.boolean() }),
},
},
description: "Contact deleted successfully",
},
},
});

function deleteContactHandler(app: PublicAPIApp) {
app.openapi(route, async (c) => {
const team = await getTeamFromToken(c);
app.openapi(route, async (c) => {
const team = await getTeamFromToken(c);

await getContactBook(c, team.id);
const contactId = c.req.param("contactId");
await getContactBook(c, team.id);
const contactId = c.req.param("contactId");

await deleteContact(contactId);
await deleteContact(contactId);

return c.json({ success: true });
});
return c.json({ success: true });
});
}

export default deleteContactHandler;
export default deleteContactHandler;
88 changes: 44 additions & 44 deletions apps/web/src/server/public-api/api/contacts/upsert-contact.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,61 +5,61 @@ import { addOrUpdateContact } from "~/server/service/contact-service";
import { getContactBook } from "../../api-utils";

const route = createRoute({
method: "put",
path: "/v1/contactBooks/{contactBookId}/contacts/{contactId}",
request: {
params: z.object({
contactBookId: z
.string()
.min(3)
.openapi({
param: {
name: "contactBookId",
in: "path",
},
example: "cuiwqdj74rygf74",
}),
method: "put",
path: "/v1/contactBooks/{contactBookId}/contacts/{contactId}",
request: {
params: z.object({
contactBookId: z
.string()
.min(3)
.openapi({
param: {
name: "contactBookId",
in: "path",
},
example: "cuiwqdj74rygf74",
}),
body: {
required: true,
content: {
"application/json": {
schema: z.object({
email: z.string(),
firstName: z.string().optional(),
lastName: z.string().optional(),
properties: z.record(z.string()).optional(),
subscribed: z.boolean().optional(),
}),
},
},
}),
body: {
required: true,
content: {
"application/json": {
schema: z.object({
email: z.string(),
firstName: z.string().optional(),
lastName: z.string().optional(),
properties: z.record(z.string()).optional(),
subscribed: z.boolean().optional(),
}),
},
},
},
responses: {
200: {
content: {
"application/json": {
schema: z.object({ contactId: z.string() }),
},
},
description: "Contact upserted successfully",
},
responses: {
200: {
content: {
"application/json": {
schema: z.object({ contactId: z.string() }),
},
},
description: "Contact upserted successfully",
},
},
});

function upsertContact(app: PublicAPIApp) {
app.openapi(route, async (c) => {
const team = await getTeamFromToken(c);
app.openapi(route, async (c) => {
const team = await getTeamFromToken(c);

const contactBook = await getContactBook(c, team.id);
const contactBook = await getContactBook(c, team.id);

const contact = await addOrUpdateContact(
contactBook.id,
c.req.valid("json")
);
const contact = await addOrUpdateContact(
contactBook.id,
c.req.valid("json")
);

return c.json({ contactId: contact.id });
});
return c.json({ contactId: contact.id });
});
}

export default upsertContact;

0 comments on commit 7e1a63e

Please sign in to comment.