added tooling (eslint, typescript and prettier)

This commit is contained in:
Carl-Gerhard Lindesvärd
2023-11-02 12:14:37 +01:00
parent 575b3c23bf
commit 493e1b7650
82 changed files with 1890 additions and 1363 deletions

View File

@@ -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 {

View File

@@ -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;

View File

@@ -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 ?? {}),