Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 3 additions & 11 deletions apps/backend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -63,22 +63,14 @@
"typescript": "^5.7.3"
},
"jest": {
"moduleFileExtensions": [
"js",
"json",
"ts"
],
"moduleFileExtensions": ["js", "json", "ts"],
"rootDir": "./",
"modulePaths": [
"<rootDir>"
],
"modulePaths": ["<rootDir>"],
"testRegex": ".*\\.spec\\.ts$",
"transform": {
"^.+\\.(t|j)s$": "ts-jest"
},
"collectCoverageFrom": [
"**/*.(t|j)s"
],
"collectCoverageFrom": ["**/*.(t|j)s"],
"coverageDirectory": "../coverage",
"testEnvironment": "node"
},
Expand Down
4 changes: 3 additions & 1 deletion apps/backend/src/core/core.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,16 @@ import { Module } from "@nestjs/common";
import { ConfigModule, ConfigService } from "@nestjs/config";
import { GraphQLModule } from "@nestjs/graphql";

import { AuthModule } from "src/auth/auth.module";
import { CategoryModule } from "src/modules/categories/category.module";
import { ProductImageModule } from "src/modules/product-image/product-image.module";
import { ProductModule } from "src/modules/product/product.module";
import { UsersModule } from "src/modules/users/users.module";
import { IS_DEV_ENV } from "src/shared/utils/is-dev.util";
import { MessageModule } from "../modules/message/message.module";
import { getGraphQLConfig } from "./config/graphql.config";
import { PrismaModule } from "./prisma/prisma.module";

import { AuthModule } from "src/auth/auth.module";
@Module({
imports: [
AuthModule,
Expand All @@ -30,6 +31,7 @@ import { AuthModule } from "src/auth/auth.module";
ProductModule,
ProductImageModule,
UsersModule,
MessageModule,
],
controllers: [],
providers: [],
Expand Down
143 changes: 80 additions & 63 deletions apps/backend/src/core/graphql/schema.gql
Original file line number Diff line number Diff line change
Expand Up @@ -3,101 +3,118 @@
# ------------------------------------------------------

type Category {
createdAt: DateTime!
id: ID!
imageUrl: String
name: String!
updatedAt: DateTime!
createdAt: DateTime!
id: ID!
imageUrl: String
name: String!
updatedAt: DateTime!
}

input CreateCategoryInput {
name: String!
name: String!
}

input CreateMessageInput {
content: String!
orderId: String!
senderAddress: String!
}

input CreateProductInput {
categoryId: String!
description: String
name: String!
price: Float!
slug: String!
categoryId: String!
description: String
name: String!
price: Float!
slug: String!
}

input CreateUserInput {
country: String!
email: String!
isSeller: Boolean! = false
name: String!
surname: String!
telegramUsername: String
walletAddress: String!
country: String!
email: String!
isSeller: Boolean! = false
name: String!
surname: String!
telegramUsername: String
walletAddress: String!
}

"""
A date-time string at UTC, such as 2019-12-03T09:54:33Z, compliant with the date-time format.
"""
scalar DateTime

type Message {
content: String!
createdAt: DateTime!
id: ID!
orderId: String!
senderAddress: String!
updatedAt: DateTime!
}

type Mutation {
createCategory(data: CreateCategoryInput!): Category!
createProduct(data: CreateProductInput!): ProductDTO!
createProductImage(createProductImage: ProductImageDTO!): ProductImage!
createUser(data: CreateUserInput!): User!
updateUser(data: UpdateUserInput!, walletAddress: String!): User!
createCategory(data: CreateCategoryInput!): Category!
createProduct(data: CreateProductInput!): ProductDTO!
createProductImage(createProductImage: ProductImageDTO!): ProductImage!
createUser(data: CreateUserInput!): User!
sendMessage(data: CreateMessageInput!): Message!
updateUser(data: UpdateUserInput!, walletAddress: String!): User!
}

type ProductDTO {
categoryId: String!
createdAt: DateTime!
description: String
id: ID!
name: String!
price: Float!
slug: String!
updatedAt: DateTime!
categoryId: String!
createdAt: DateTime!
description: String
id: ID!
name: String!
price: Float!
slug: String!
updatedAt: DateTime!
}

type ProductImage {
createdAt: DateTime!
id: ID!
imageUrl: String!
productId: String!
updatedAt: DateTime!
createdAt: DateTime!
id: ID!
imageUrl: String!
productId: String!
updatedAt: DateTime!
}

input ProductImageDTO {
imageUrl: String!
productId: String!
imageUrl: String!
productId: String!
}

type Query {
categories: [Category!]!
category(id: String!): Category
product(id: String!): ProductDTO
productImage(id: String!): ProductImage
productImages: [ProductImage!]!
products: [ProductDTO!]!
user(walletAddress: String!): User
users: [User!]!
categories: [Category!]!
category(id: String!): Category
getMessagesByOrder(orderId: String!): [Message!]!
product(id: String!): ProductDTO
productImage(id: String!): ProductImage
productImages: [ProductImage!]!
products: [ProductDTO!]!
user(walletAddress: String!): User
users: [User!]!
}

input UpdateUserInput {
country: String
email: String
isSeller: Boolean = false
name: String
surname: String
telegramUsername: String
walletAddress: String
country: String
email: String
isSeller: Boolean = false
name: String
surname: String
telegramUsername: String
walletAddress: String
}

type User {
country: String!
createdAt: DateTime!
email: String!
isSeller: Boolean!
name: String!
surname: String!
telegramUsername: String
updatedAt: DateTime!
walletAddress: String!
}
country: String!
createdAt: DateTime!
email: String!
isSeller: Boolean!
name: String!
surname: String!
telegramUsername: String
updatedAt: DateTime!
walletAddress: String!
}
14 changes: 7 additions & 7 deletions apps/backend/src/modules/message/dto/create-message.input.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import { InputType, Int, Field } from '@nestjs/graphql';
import { Field, InputType, Int } from "@nestjs/graphql";

@InputType()
export class CreateMessageInput {
@Field()
orderId: string;
@Field()
orderId: string;

@Field()
senderAddress: string;
@Field()
senderAddress: string;

@Field()
content: string;
@Field()
content: string;
}
8 changes: 4 additions & 4 deletions apps/backend/src/modules/message/dto/update-message.input.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { CreateMessageInput } from './create-message.input';
import { InputType, Field, Int, PartialType } from '@nestjs/graphql';
import { Field, InputType, Int, PartialType } from "@nestjs/graphql";
import { CreateMessageInput } from "./create-message.input";

@InputType()
export class UpdateMessageInput extends PartialType(CreateMessageInput) {
@Field(() => Int)
id: number;
@Field(() => Int)
id: number;
}
26 changes: 13 additions & 13 deletions apps/backend/src/modules/message/entities/message.entity.ts
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
import { ObjectType, Field, Int, ID } from '@nestjs/graphql';
import { Field, ID, Int, ObjectType } from "@nestjs/graphql";

@ObjectType()
export class Message {
@Field(() => ID)
id: string;
@Field(() => ID)
id: string;

@Field()
orderId: string;
@Field()
orderId: string;

@Field()
senderAddress: string;
@Field()
senderAddress: string;

@Field()
content: string;
@Field()
content: string;

@Field()
createdAt: Date;
@Field()
createdAt: Date;

@Field()
updatedAt: Date;
@Field()
updatedAt: Date;
}
12 changes: 5 additions & 7 deletions apps/backend/src/modules/message/message.module.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
import { Module } from '@nestjs/common';
import { MessageService } from './message.service';
import { MessageResolver } from './message.resolver';
import { PrismaService } from 'src/core/prisma/prisma.service';
import { Module } from "@nestjs/common";
import { PrismaService } from "src/core/prisma/prisma.service";
import { MessageResolver } from "./message.resolver";
import { MessageService } from "./message.service";

@Module({
providers: [MessageResolver, MessageService, PrismaService],
providers: [MessageResolver, MessageService, PrismaService],
})
export class MessageModule {}


Loading