added tooling (eslint, typescript and prettier)
This commit is contained in:
@@ -1,16 +1,17 @@
|
||||
import { validateSdkRequest } from "@/server/auth";
|
||||
import { createError, handleError } from "@/server/exceptions";
|
||||
import { tickProfileProperty } from "@/server/services/profile.service";
|
||||
import { type ProfileIncrementPayload } from "@mixan/types";
|
||||
import type { NextApiRequest, NextApiResponse } from "next";
|
||||
import { validateSdkRequest } from '@/server/auth';
|
||||
import { createError, handleError } from '@/server/exceptions';
|
||||
import { tickProfileProperty } from '@/server/services/profile.service';
|
||||
import type { NextApiRequest, NextApiResponse } from 'next';
|
||||
|
||||
import { type ProfileIncrementPayload } from '@mixan/types';
|
||||
|
||||
interface Request extends NextApiRequest {
|
||||
body: ProfileIncrementPayload;
|
||||
}
|
||||
|
||||
export default async function handler(req: Request, res: NextApiResponse) {
|
||||
if (req.method !== "PUT") {
|
||||
return handleError(res, createError(405, "Method not allowed"));
|
||||
if (req.method !== 'PUT') {
|
||||
return handleError(res, createError(405, 'Method not allowed'));
|
||||
}
|
||||
|
||||
try {
|
||||
|
||||
@@ -1,21 +1,22 @@
|
||||
import { validateSdkRequest } from "@/server/auth";
|
||||
import { createError, handleError } from "@/server/exceptions";
|
||||
import { tickProfileProperty } from "@/server/services/profile.service";
|
||||
import { type ProfileIncrementPayload } from "@mixan/types";
|
||||
import type { NextApiRequest, NextApiResponse } from "next";
|
||||
import { validateSdkRequest } from '@/server/auth';
|
||||
import { createError, handleError } from '@/server/exceptions';
|
||||
import { tickProfileProperty } from '@/server/services/profile.service';
|
||||
import type { NextApiRequest, NextApiResponse } from 'next';
|
||||
|
||||
import { type ProfileIncrementPayload } from '@mixan/types';
|
||||
|
||||
interface Request extends NextApiRequest {
|
||||
body: ProfileIncrementPayload;
|
||||
}
|
||||
|
||||
export default async function handler(req: Request, res: NextApiResponse) {
|
||||
if (req.method !== "PUT") {
|
||||
return handleError(res, createError(405, "Method not allowed"));
|
||||
if (req.method !== 'PUT') {
|
||||
return handleError(res, createError(405, 'Method not allowed'));
|
||||
}
|
||||
|
||||
try {
|
||||
// Check client id & secret
|
||||
await validateSdkRequest(req)
|
||||
await validateSdkRequest(req);
|
||||
|
||||
const profileId = req.query.profileId as string;
|
||||
|
||||
|
||||
@@ -1,26 +1,27 @@
|
||||
import { validateSdkRequest } from "@/server/auth";
|
||||
import { db } from "@/server/db";
|
||||
import { createError, handleError } from "@/server/exceptions";
|
||||
import { getProfile } from "@/server/services/profile.service";
|
||||
import { type ProfilePayload } from "@mixan/types";
|
||||
import type { NextApiRequest, NextApiResponse } from "next";
|
||||
import { validateSdkRequest } from '@/server/auth';
|
||||
import { db } from '@/server/db';
|
||||
import { createError, handleError } from '@/server/exceptions';
|
||||
import { getProfile } from '@/server/services/profile.service';
|
||||
import type { NextApiRequest, NextApiResponse } from 'next';
|
||||
|
||||
import { type ProfilePayload } from '@mixan/types';
|
||||
|
||||
interface Request extends NextApiRequest {
|
||||
body: ProfilePayload;
|
||||
}
|
||||
|
||||
export default async function handler(req: Request, res: NextApiResponse) {
|
||||
if (req.method !== "PUT" && req.method !== "POST") {
|
||||
return handleError(res, createError(405, "Method not allowed"));
|
||||
export default async function handler(req: Request, res: NextApiResponse) {
|
||||
if (req.method !== 'PUT' && req.method !== 'POST') {
|
||||
return handleError(res, createError(405, 'Method not allowed'));
|
||||
}
|
||||
|
||||
try {
|
||||
// Check client id & secret
|
||||
await validateSdkRequest(req)
|
||||
await validateSdkRequest(req);
|
||||
|
||||
const profileId = req.query.profileId as string;
|
||||
const profile = await getProfile(profileId)
|
||||
|
||||
const profile = await getProfile(profileId);
|
||||
|
||||
const { body } = req;
|
||||
await db.profile.update({
|
||||
where: {
|
||||
@@ -33,7 +34,7 @@ export default async function handler(req: Request, res: NextApiResponse) {
|
||||
last_name: body.last_name,
|
||||
avatar: body.avatar,
|
||||
properties: {
|
||||
...(typeof profile.properties === "object"
|
||||
...(typeof profile.properties === 'object'
|
||||
? profile.properties ?? {}
|
||||
: {}),
|
||||
...(body.properties ?? {}),
|
||||
|
||||
Reference in New Issue
Block a user