Skip to content

Commit

Permalink
perf: Improve imports for graphql upload
Browse files Browse the repository at this point in the history
  • Loading branch information
aXenDeveloper committed May 12, 2024
1 parent eb5063a commit 504a142
Show file tree
Hide file tree
Showing 19 changed files with 516 additions and 425 deletions.
4 changes: 2 additions & 2 deletions backend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@
"config:finish": "ts-node ./src/utils/actions/finish-build.ts",
"build": "nest build",
"format": "prettier --write \"src/**/*.ts\" \"test/**/*.ts\"",
"start": "nest start -b swc",
"dev": "cross-env NODE_ENV=development pnpm config:finish && nest start -b swc -w",
"start:swc": "nest start -b swc",
"start:debug": "nest start --debug --watch",
"start:prod": "node dist/main",
"start": "node dist/main",
"lint": "eslint \"{src,apps,libs,test}/**/*.ts\" --fix",
"test": "jest",
"test:watch": "jest --watch",
Expand Down
4 changes: 3 additions & 1 deletion backend/src/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import { ApolloDriver, ApolloDriverConfig } from "@nestjs/apollo";
import { ApolloServerPluginLandingPageLocalDefault } from "@apollo/server/plugin/landingPage/default";
import { DatabaseModule } from "./database/database.module";
import { ServeStaticModule } from "@nestjs/serve-static";
import { Ctx } from "./utils/types/context.type";

@Module({
imports: [
Expand All @@ -23,7 +24,8 @@ import { ServeStaticModule } from "@nestjs/serve-static";
autoSchemaFile: join(process.cwd(), "schema.gql"),
sortSchema: true,
playground: false,
plugins: [ApolloServerPluginLandingPageLocalDefault()]
plugins: [ApolloServerPluginLandingPageLocalDefault()],
context: ({ req, res }): Ctx => ({ req, res })
}),
JwtModule.register({ global: true }),
ServeStaticModule.forRoot({
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { ArgsType, Field } from "@nestjs/graphql";

import { FileUpload } from "@/utils/graphql-upload/Upload";
import { FileUpload } from "@/utils/graphql-upload/uploads";
import { GraphQLUpload } from "@/utils/graphql-upload/graphql-upload";

@ArgsType()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { ArgsType, Field } from "@nestjs/graphql";

import { FileUpload } from "@/utils/graphql-upload/Upload";
import { FileUpload } from "@/utils/graphql-upload/uploads";
import { GraphQLUpload } from "@/utils/graphql-upload/graphql-upload";

@ArgsType()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import { ChangeFilesAdminPluginsService } from "../helpers/files/change/change.s
import { pluginPaths } from "../paths";
import { ConfigPlugin } from "../plugins.module";

import { FileUpload } from "@/utils/graphql-upload/Upload";
import { FileUpload } from "@/utils/graphql-upload/uploads";
import { currentDate } from "@/functions/date";
import { core_plugins } from "../../database/schema/plugins";
import { DatabaseService } from "@/database/database.service";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { ArgsType, Field, Int } from "@nestjs/graphql";

import { FileUpload } from "@/utils/graphql-upload/Upload";
import { FileUpload } from "@/utils/graphql-upload/uploads";
import { GraphQLUpload } from "@/utils/graphql-upload/graphql-upload";

@ArgsType()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import { generateRandomString } from "@/functions/generate-random-string";
import { currentDate } from "@/functions/date";

import { core_themes } from "../../database/schema/themes";
import { FileUpload } from "@/utils/graphql-upload/Upload";
import { FileUpload } from "@/utils/graphql-upload/uploads";
import { NotFoundError } from "@/utils/errors/not-found-error";
import { DatabaseService } from "@/database/database.service";
import { CustomError } from "@/utils/errors/custom-error";
Expand Down
2 changes: 1 addition & 1 deletion backend/src/plugins/core/editor/upload/dto/upload.args.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { ArgsType, Field } from "@nestjs/graphql";

import { FileUpload } from "@/utils/graphql-upload/Upload";
import { FileUpload } from "@/utils/graphql-upload/uploads";
import { GraphQLUpload } from "@/utils/graphql-upload/graphql-upload";

@ArgsType()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { ArgsType, Field } from "@nestjs/graphql";

import { FileUpload } from "@/utils/graphql-upload/Upload";
import { FileUpload } from "@/utils/graphql-upload/uploads";
import { GraphQLUpload } from "@/utils/graphql-upload/graphql-upload";

@ArgsType()
Expand Down
2 changes: 1 addition & 1 deletion backend/src/plugins/core/files/helpers/upload/helpers.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { CustomError } from "@/utils/errors/custom-error";
import { FileUpload } from "@/utils/graphql-upload/Upload";
import { FileUpload } from "@/utils/graphql-upload/uploads";

export const acceptMimeTypeImage = [
"image/jpeg",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import {
} from "fs";
import { join } from "path";

import * as sharp from "sharp";
import sharp from "sharp";
import { Injectable } from "@nestjs/common";

import { UploadCoreFilesArgs } from "./dto/upload.args";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { ArgsType, Field } from "@nestjs/graphql";

import { FileUpload } from "@/utils/graphql-upload/Upload";
import { FileUpload } from "@/utils/graphql-upload/uploads";
import { GraphQLUpload } from "@/utils/graphql-upload/graphql-upload";

@ArgsType()
Expand Down
2 changes: 1 addition & 1 deletion backend/src/utils/graphql-upload/graphql-upload.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { GraphQLError, GraphQLScalarType } from "graphql";

import Upload from "./Upload";
import Upload from "./uploads";

export const GraphQLUpload = new GraphQLScalarType({
name: "Upload",
Expand Down
8 changes: 4 additions & 4 deletions backend/src/utils/graphql-upload/process-request.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { IncomingMessage, ServerResponse } from "http";

import * as busboy from "busboy";
import * as createError from "http-errors";
import * as objectPath from "object-path";
import busboy from "busboy";
import createError from "http-errors";
import objectPath from "object-path";

import Upload, { FileUpload } from "./Upload";
import Upload, { FileUpload } from "./uploads";
import ignoreStream from "./ignore-stream";
import { ProcessRequestOptions } from "./graphql-upload-express";
import { WriteStream } from "./fs-capacitor";
Expand Down
File renamed without changes.
6 changes: 3 additions & 3 deletions frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -97,13 +97,13 @@
"@radix-ui/react-popover": "^1.0.7",
"@radix-ui/react-toolbar": "^1.0.4",
"@tanstack/eslint-plugin-query": "^5.32.1",
"@tanstack/react-query": "^5.35.1",
"@tanstack/react-query-devtools": "^5.35.1",
"@tanstack/react-query": "^5.35.5",
"@tanstack/react-query-devtools": "^5.35.5",
"@tanstack/react-table": "^8.16.0",
"@testing-library/react": "^15.0.7",
"@types/lodash": "^4.17.1",
"@types/node": "^20.12.11",
"@types/react": "^18.3.1",
"@types/react": "^18.3.2",
"@types/react-dom": "^18.3.0",
"@typescript-eslint/eslint-plugin": "^7.8.0",
"@typescript-eslint/parser": "^7.8.0",
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
"lint": "turbo lint",
"lint:fix": "turbo lint:fix",
"test": "turbo test:once",
"start": "turbo start",
"preinstall": "npx only-allow pnpm",
"config:init": "cd backend && pnpm config:init && cd ..",
"config:finish": "cd backend && pnpm config:finish && cd ..",
Expand Down
Loading

0 comments on commit 504a142

Please sign in to comment.