From 1d893c4a78376fb937b2dd2241b94b86e137595c Mon Sep 17 00:00:00 2001 From: Wroclaw Date: Mon, 6 Nov 2023 02:57:00 +0100 Subject: [PATCH] Update dependencies, fix (auto)import problems --- components/orderView.vue | 2 +- package-lock.json | 8033 +++++++++++------ package.json | 6 +- pages/client/[id].vue | 4 +- pages/clients.vue | 13 +- pages/firstRun.vue | 8 +- pages/index.vue | 2 +- pages/login.vue | 3 +- server/api/clients.get.ts | 5 +- server/api/clients.post.ts | 6 +- server/api/clients/[id].delete.ts | 2 +- server/api/clients/[id].get.ts | 2 +- server/api/clients/[id].patch.ts | 2 +- server/api/clients/[id]/orders.get.ts | 2 +- server/api/clients/count.get.ts | 2 +- server/api/dbtest/[id].delete.ts | 2 +- server/api/echo.post.ts | 2 +- server/api/firstRun.get.ts | 4 +- server/api/firstRun.post.ts | 5 +- server/api/hi.ts | 2 +- server/api/login.post.ts | 6 +- server/api/logout.ts | 4 +- server/api/orders.get.ts | 6 +- server/api/orders.post.ts | 4 +- server/api/orders/[id].delete.ts | 6 +- server/api/orders/[id].get.ts | 7 +- server/api/orders/[id].patch.ts | 4 +- .../api/orders/[id]/imported_products.get.ts | 4 +- .../api/orders/[id]/imported_products.post.ts | 4 +- server/api/orders/[id]/work.get.ts | 4 +- server/api/orders/[id]/work.post.ts | 4 +- .../api/orders/[id]/work/[idWork].delete.ts | 6 +- server/api/orders/[id]/work/[idWork].get.ts | 4 +- server/api/users/me.get.ts | 5 +- server/middleware/auth.ts | 5 +- server/utils/baaPagination.ts | 14 +- server/utils/database.ts | 6 +- server/utils/getRequestingUser.ts | 9 +- server/utils/validation.ts | 2 +- utils/cookieSettings.ts | 2 +- 40 files changed, 5166 insertions(+), 3047 deletions(-) diff --git a/components/orderView.vue b/components/orderView.vue index aa540b7..5e25109 100644 --- a/components/orderView.vue +++ b/components/orderView.vue @@ -1,5 +1,5 @@ diff --git a/pages/login.vue b/pages/login.vue index 0667932..b177602 100644 --- a/pages/login.vue +++ b/pages/login.vue @@ -2,9 +2,8 @@ /* global $fetch */ import { ref, watch } from "vue"; import { VForm } from "vuetify/components"; -import { navigateTo, useCookie, useFetch, useRoute } from "nuxt/app"; import { cookieSettings } from "~/utils/cookieSettings"; -import { definePageMeta } from "~/.nuxt/imports"; +import { definePageMeta, navigateTo, useCookie, useFetch, useRoute } from "#imports"; const route = useRoute(); diff --git a/server/api/clients.get.ts b/server/api/clients.get.ts index 42e6cca..8d2d498 100644 --- a/server/api/clients.get.ts +++ b/server/api/clients.get.ts @@ -1,7 +1,8 @@ -/* global defineEventHandler getQuery, createError */ +import { defineEventHandler, getQuery } from "h3"; +import { createError } from "#imports"; import BaaPagination from "~/server/utils/baaPagination"; -import { client } from "~/utils/types/database"; +import { type client } from "~/utils/types/database"; export const baaWrapper = new BaaPagination("clients", "id"); diff --git a/server/api/clients.post.ts b/server/api/clients.post.ts index 84fa7e4..6dbe778 100644 --- a/server/api/clients.post.ts +++ b/server/api/clients.post.ts @@ -1,7 +1,9 @@ -/* global defineEventHandler, createError, readBody */ +import { defineEventHandler, readBody } from "h3"; import { baaWrapper } from "./clients.get"; -import { client } from "~/utils/types/database"; +import { type client } from "~/utils/types/database"; + +import { createError } from "#imports"; const clientKeys: Array = [ "name", diff --git a/server/api/clients/[id].delete.ts b/server/api/clients/[id].delete.ts index a4c2e51..9b6ab20 100644 --- a/server/api/clients/[id].delete.ts +++ b/server/api/clients/[id].delete.ts @@ -1,4 +1,4 @@ -/* global defineEventHandler */ +import { defineEventHandler } from "h3"; import { baaWrapper } from "../clients.get"; diff --git a/server/api/clients/[id].get.ts b/server/api/clients/[id].get.ts index 2647b77..75fcc79 100644 --- a/server/api/clients/[id].get.ts +++ b/server/api/clients/[id].get.ts @@ -1,4 +1,4 @@ -/* global defineEventHandler */ +import { defineEventHandler } from "h3"; import { baaWrapper } from "../clients.get"; diff --git a/server/api/clients/[id].patch.ts b/server/api/clients/[id].patch.ts index 38ff3f8..55163ca 100644 --- a/server/api/clients/[id].patch.ts +++ b/server/api/clients/[id].patch.ts @@ -1,4 +1,4 @@ -/* global defineEventHandler */ +import { defineEventHandler } from "h3"; import { checkIsClient } from "../clients.post"; import { baaWrapper } from "../clients.get"; diff --git a/server/api/clients/[id]/orders.get.ts b/server/api/clients/[id]/orders.get.ts index bd9903b..de76c37 100644 --- a/server/api/clients/[id]/orders.get.ts +++ b/server/api/clients/[id]/orders.get.ts @@ -1,4 +1,4 @@ -/* global defineEventHandler */ +import { defineEventHandler } from "h3"; import { baaWrapper } from "~/server/api/orders.get"; diff --git a/server/api/clients/count.get.ts b/server/api/clients/count.get.ts index 38b82b5..565dcd2 100644 --- a/server/api/clients/count.get.ts +++ b/server/api/clients/count.get.ts @@ -1,4 +1,4 @@ -/* global defineEventHandler */ +import { defineEventHandler } from "h3"; import { baaWrapper } from "../clients.get"; diff --git a/server/api/dbtest/[id].delete.ts b/server/api/dbtest/[id].delete.ts index 81560f6..749540a 100644 --- a/server/api/dbtest/[id].delete.ts +++ b/server/api/dbtest/[id].delete.ts @@ -1,4 +1,4 @@ -/* global defineEventHandler */ +import { defineEventHandler } from "h3"; import { database } from "~/server/utils/database"; diff --git a/server/api/echo.post.ts b/server/api/echo.post.ts index 2e8db98..4c90f68 100644 --- a/server/api/echo.post.ts +++ b/server/api/echo.post.ts @@ -1,4 +1,4 @@ -/* global defineEventHandler */ +import { defineEventHandler } from "h3"; export default defineEventHandler((event) => { const message = event.node.req.read(); diff --git a/server/api/firstRun.get.ts b/server/api/firstRun.get.ts index ae1bb23..21ccb65 100644 --- a/server/api/firstRun.get.ts +++ b/server/api/firstRun.get.ts @@ -1,5 +1,5 @@ -/* global defineEventHandler */ -import { data, database } from "../utils/database"; +import { defineEventHandler } from "h3"; +import { type data, database } from "../utils/database"; export async function isFirstRun() { const [tables] = await database.query({ sql: "SHOW TABLES", rowsAsArray: true }, []) as data<[string]>; diff --git a/server/api/firstRun.post.ts b/server/api/firstRun.post.ts index 657b8d5..16436cf 100644 --- a/server/api/firstRun.post.ts +++ b/server/api/firstRun.post.ts @@ -1,12 +1,13 @@ -/* global defineEventHandler, setResponseStatus, readBody, createError */ - import fs from "node:fs/promises"; +import { defineEventHandler, setResponseStatus, readBody } from "h3"; import { database as db } from "../utils/database"; import { isFirstRun } from "./firstRun.get"; import { getPasswordHash } from "./login.post"; import Snowflake from "~/utils/snowflake"; +import { createError } from "#imports"; + export default defineEventHandler(async (e) => { if (!isFirstRun()) { setResponseStatus(e, 404); diff --git a/server/api/hi.ts b/server/api/hi.ts index 2f94714..c5b6e65 100644 --- a/server/api/hi.ts +++ b/server/api/hi.ts @@ -1,4 +1,4 @@ -/* global defineEventHandler */ +import { defineEventHandler } from "h3"; export default defineEventHandler(() => { return "Hi mom!"; diff --git a/server/api/login.post.ts b/server/api/login.post.ts index f603761..49f8690 100644 --- a/server/api/login.post.ts +++ b/server/api/login.post.ts @@ -1,11 +1,13 @@ -/* global defineEventHandler, getCookie, setCookie, readBody, createError */ import crypto from "crypto"; +import { defineEventHandler, getCookie, setCookie, readBody } from "h3"; -import { database, data } from "../utils/database"; +import { database, type data } from "../utils/database"; import { isString } from "../utils/isString"; import { cookieSettings } from "../utils/rootUtils"; import Snowflake from "~/utils/snowflake"; +import { createError } from "#imports"; + export function getPasswordHash(password: string) { return crypto.createHmac("sha512", "42") .update(password) diff --git a/server/api/logout.ts b/server/api/logout.ts index 6923245..59ce9b6 100644 --- a/server/api/logout.ts +++ b/server/api/logout.ts @@ -1,9 +1,11 @@ -/* global defineEventHandler, createError, getCookie, deleteCookie */ +import { defineEventHandler, getCookie, deleteCookie } from "h3"; import { isAuthorised } from "../middleware/auth"; import { database } from "../utils/database"; import { cookieSettings } from "../utils/rootUtils"; +import { createError } from "#imports"; + export default defineEventHandler(async (e) => { const token = getCookie(e, "token"); if (token === undefined) { diff --git a/server/api/orders.get.ts b/server/api/orders.get.ts index 34f7816..526401b 100644 --- a/server/api/orders.get.ts +++ b/server/api/orders.get.ts @@ -1,8 +1,8 @@ -/* global defineEventHandler */ +import { defineEventHandler } from "h3"; import BaaPagination from "../utils/baaPagination"; -import { data, database } from "../utils/database"; -import { client, orderSummary } from "~/utils/types/database"; +import { type data, database } from "../utils/database"; +import { type client, type orderSummary } from "~/utils/types/database"; export const baaWrapper = new BaaPagination( "orderSummaries", diff --git a/server/api/orders.post.ts b/server/api/orders.post.ts index ed31ada..e67913d 100644 --- a/server/api/orders.post.ts +++ b/server/api/orders.post.ts @@ -1,4 +1,4 @@ -/* global defineEventHandler, createError, readBody, setResponseStatus */ +import { defineEventHandler, readBody, setResponseStatus } from "h3"; import { createValidationError, handleRecursedValidationError } from "../utils/validation"; import { database as db } from "../utils/database"; @@ -6,6 +6,8 @@ import getRequestingUser from "../utils/getRequestingUser"; import { getOrder } from "./orders/[id].get"; import Snowflake from "~/utils/snowflake"; +import { createError } from "#imports"; + type importedProduct = { name: string | null, link: string, diff --git a/server/api/orders/[id].delete.ts b/server/api/orders/[id].delete.ts index 0f660d0..662e7d2 100644 --- a/server/api/orders/[id].delete.ts +++ b/server/api/orders/[id].delete.ts @@ -1,8 +1,10 @@ -/* global defineEventHandler, createError */ -import { ResultSetHeader } from "mysql2"; +import { defineEventHandler } from "h3"; +import { type ResultSetHeader } from "mysql2"; import { database } from "~/server/utils/database"; +import { createError } from "#imports"; + export default defineEventHandler(async (e) => { const id = e.context.params?.id; diff --git a/server/api/orders/[id].get.ts b/server/api/orders/[id].get.ts index 9832f2f..6069201 100644 --- a/server/api/orders/[id].get.ts +++ b/server/api/orders/[id].get.ts @@ -1,7 +1,8 @@ -/* global defineEventHandler, createError */ +import { defineEventHandler } from "h3"; +import { createError } from "#imports"; -import { offer as offerType, order } from "~/utils/types/database"; -import { database, data } from "~/server/utils/database"; +import { type offer as offerType, type order } from "~/utils/types/database"; +import { database, type data } from "~/server/utils/database"; export async function orderExists(id: string) { const [[exists]] = await database.query( diff --git a/server/api/orders/[id].patch.ts b/server/api/orders/[id].patch.ts index 87aa718..687066a 100644 --- a/server/api/orders/[id].patch.ts +++ b/server/api/orders/[id].patch.ts @@ -1,8 +1,10 @@ -/* global defineEventHandler, readBody, createError */ +import { defineEventHandler, readBody } from "h3"; import { checkIsOrder } from "../orders.post"; import { database as db } from "~/server/utils/database"; +import { createError } from "#imports"; + export default defineEventHandler(async (e) => { const body = await readBody(e); const id = e.context.params?.id; diff --git a/server/api/orders/[id]/imported_products.get.ts b/server/api/orders/[id]/imported_products.get.ts index ad7d9e0..1e6a027 100644 --- a/server/api/orders/[id]/imported_products.get.ts +++ b/server/api/orders/[id]/imported_products.get.ts @@ -1,7 +1,9 @@ -/* global defineEventHandler, createError */ +import { defineEventHandler } from "h3"; import { orderExists, getImportedProducts } from "../[id].get"; +import { createError } from "#imports"; + export default defineEventHandler(async (e) => { const id = e.context.params?.id as string; diff --git a/server/api/orders/[id]/imported_products.post.ts b/server/api/orders/[id]/imported_products.post.ts index f441432..debf1a8 100644 --- a/server/api/orders/[id]/imported_products.post.ts +++ b/server/api/orders/[id]/imported_products.post.ts @@ -1,10 +1,12 @@ -/* global defineEventHandler, readBody, createError, setResponseStatus */ +import { defineEventHandler, readBody, setResponseStatus } from "h3"; import { checkIsImportedProduct } from "../../orders.post"; import { getImportedProducts, orderExists } from "../[id].get"; import Snowflake from "~/utils/snowflake"; import { database } from "~/server/utils/database"; +import { createError } from "#imports"; + export default defineEventHandler(async (e) => { const body = await readBody(e); const idOrder = e.context.params?.id as string; diff --git a/server/api/orders/[id]/work.get.ts b/server/api/orders/[id]/work.get.ts index 5399cb8..02bd815 100644 --- a/server/api/orders/[id]/work.get.ts +++ b/server/api/orders/[id]/work.get.ts @@ -1,7 +1,9 @@ -/* global defineEventHandler, createError */ +import { defineEventHandler } from "h3"; import { orderExists, getWork } from "../[id].get"; +import { createError } from "#imports"; + export default defineEventHandler(async (e) => { const id = e.context.params?.id as string; diff --git a/server/api/orders/[id]/work.post.ts b/server/api/orders/[id]/work.post.ts index 98e04bd..f153ae6 100644 --- a/server/api/orders/[id]/work.post.ts +++ b/server/api/orders/[id]/work.post.ts @@ -1,10 +1,12 @@ -/* global defineEventHandler, readBody, createError, setResponseStatus */ +import { defineEventHandler, readBody, setResponseStatus } from "h3"; import { checkIsWork } from "../../orders.post"; import { getWork, orderExists } from "../[id].get"; import Snowflake from "~/utils/snowflake"; import { database } from "~/server/utils/database"; +import { createError } from "#imports"; + export default defineEventHandler(async (e) => { const body = await readBody(e); const idOrder = e.context.params?.id as string; diff --git a/server/api/orders/[id]/work/[idWork].delete.ts b/server/api/orders/[id]/work/[idWork].delete.ts index d95f1c3..9c7ef0e 100644 --- a/server/api/orders/[id]/work/[idWork].delete.ts +++ b/server/api/orders/[id]/work/[idWork].delete.ts @@ -1,9 +1,11 @@ -/* global defineEventHandler, createError */ +import { defineEventHandler } from "h3"; -import { ResultSetHeader } from "mysql2"; +import { type ResultSetHeader } from "mysql2"; import { orderExists } from "../../[id].get"; import { database } from "~/server/utils/database"; +import { createError } from "#imports"; + export default defineEventHandler(async (e) => { const idOrder = e.context.params?.id as string; const idWork = e.context.params?.idWork as string; diff --git a/server/api/orders/[id]/work/[idWork].get.ts b/server/api/orders/[id]/work/[idWork].get.ts index 5a8c06c..9c21067 100644 --- a/server/api/orders/[id]/work/[idWork].get.ts +++ b/server/api/orders/[id]/work/[idWork].get.ts @@ -1,7 +1,9 @@ -/* global defineEventHandler, createError */ +import { defineEventHandler } from "h3"; import { orderExists, getWork } from "../../[id].get"; +import { createError } from "#imports"; + export default defineEventHandler((e) => { const idOrder = e.context.params?.id as string; const idWork = e.context.params?.idWork as string; diff --git a/server/api/users/me.get.ts b/server/api/users/me.get.ts index f7ca2e6..1e2f156 100644 --- a/server/api/users/me.get.ts +++ b/server/api/users/me.get.ts @@ -1,7 +1,8 @@ /* global defineEventHandler, getCookie */ +import { defineEventHandler, getCookie } from "h3"; -import { database, data } from "~/server/utils/database"; -import { user } from "~/utils/types/database"; +import { database, type data } from "~/server/utils/database"; +import { type user } from "~/utils/types/database"; export default defineEventHandler(async (e) => { const token = getCookie(e, "token"); diff --git a/server/middleware/auth.ts b/server/middleware/auth.ts index 82760c6..ad4dc48 100644 --- a/server/middleware/auth.ts +++ b/server/middleware/auth.ts @@ -1,6 +1,7 @@ -/* global defineEventHandler, createError, getCookie */ +import { defineEventHandler, getCookie } from "h3"; +import { createError } from "#imports"; -import { database, data } from "~/server/utils/database"; +import { database, type data } from "~/server/utils/database"; const endpointsWithoutAuth: string[] = [ "/dbtest", diff --git a/server/utils/baaPagination.ts b/server/utils/baaPagination.ts index 96e4853..aa78ec7 100644 --- a/server/utils/baaPagination.ts +++ b/server/utils/baaPagination.ts @@ -1,12 +1,12 @@ -/* global defineEventHandler, getQuery, createError, readBody, setResponseStatus */ -import { QueryObject } from "ufo"; -import { H3Event } from "h3"; -import { ResultSetHeader } from "mysql2/promise"; +import { defineEventHandler, getQuery, readBody, setResponseStatus, H3Event } from "h3"; +import { type ResultSetHeader } from "mysql2/promise"; -import { data, database } from "./database"; +import { type data, database } from "./database"; import { isString } from "./isString"; import Snowflake from "~/utils/snowflake"; -import { client } from "~/utils/types/database"; +import { type client } from "~/utils/types/database"; + +import { createError } from "#imports"; type queryType = { type: "before" | "after" | "around", @@ -33,7 +33,7 @@ export default class BaaPagination Promise + new: (localConnectionOptions?: mysql.ConnectionOptions | undefined) => Promise }; -database.new = (localConnectionOptions: mysql.ConnectionOptions | undefined) => { return mysql.createConnection({ ...localConnectionOptions, ...connectionOptions }); }; +database.new = (localConnectionOptions?: mysql.ConnectionOptions | undefined) => { return mysql.createConnection({ ...localConnectionOptions, ...connectionOptions }); }; export type data = [T[], mysql.FieldPacket[]]; diff --git a/server/utils/getRequestingUser.ts b/server/utils/getRequestingUser.ts index 45a0037..02f5b0b 100644 --- a/server/utils/getRequestingUser.ts +++ b/server/utils/getRequestingUser.ts @@ -1,8 +1,9 @@ -/* global getCookie, createError */ -import { H3Event } from "h3"; +import { getCookie, H3Event } from "h3"; -import { database, data } from "./database"; -import { user } from "~/utils/types/database"; +import { database, type data } from "./database"; +import { type user } from "~/utils/types/database"; + +import { createError } from "#imports"; export default async function getRequestingUser(e: H3Event) { const cookie = getCookie(e, "token"); diff --git a/server/utils/validation.ts b/server/utils/validation.ts index 300a55d..9a94222 100644 --- a/server/utils/validation.ts +++ b/server/utils/validation.ts @@ -1,4 +1,4 @@ -/* global createError */ +import { createError } from "#imports"; export function createValidationError(errors: Map) { let message = "Invalid parameters: "; diff --git a/utils/cookieSettings.ts b/utils/cookieSettings.ts index 857ed94..34f7bb6 100644 --- a/utils/cookieSettings.ts +++ b/utils/cookieSettings.ts @@ -1,4 +1,4 @@ -import { CookieSerializeOptions } from "cookie-es"; +import { type CookieSerializeOptions } from "cookie-es"; export const cookieSettings: CookieSerializeOptions = { sameSite: "lax",