Skip to content
Open
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
4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,16 @@
"@nestjs/jwt": "^10.2.0",
"@nestjs/passport": "^10.0.3",
"@nestjs/platform-express": "^11.0.1",
"@nestjs/swagger": "^11.2.3",
"@prisma/client": "^6.16.2",
"bcrypt": "^6.0.0",
"bcryptjs": "^3.0.2",
"class-validator": "^0.14.2",
"passport": "^0.7.0",
"passport-jwt": "^4.0.1",
"reflect-metadata": "^0.2.2",
"rxjs": "^7.8.1"
"rxjs": "^7.8.1",
"swagger-ui-express": "^5.0.1"
},
"devDependencies": {
"@nestjs/cli": "^11.0.0",
Expand Down
107 changes: 107 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

19 changes: 19 additions & 0 deletions prisma/migrations/20251102183247_create_order/migration.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
-- CreateEnum
CREATE TYPE "OrderType" AS ENUM ('BUY', 'SELL');

-- CreateEnum
CREATE TYPE "OrderStatus" AS ENUM ('PENDING', 'EXECUTED', 'CANCELED');

-- CreateTable
CREATE TABLE "Order" (
"id" TEXT NOT NULL,
"userId" TEXT NOT NULL,
"assetId" INTEGER NOT NULL,
"type" "OrderType" NOT NULL,
"status" "OrderStatus" NOT NULL DEFAULT 'PENDING',
"quantity" INTEGER NOT NULL,
"price" DOUBLE PRECISION NOT NULL,
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,

CONSTRAINT "Order_pkey" PRIMARY KEY ("id")
);
22 changes: 22 additions & 0 deletions prisma/migrations/20251127000653_/migration.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
/*
Warnings:

- You are about to drop the `Order` table. If the table is not empty, all the data it contains will be lost.

*/
-- DropTable
DROP TABLE "public"."Order";

-- CreateTable
CREATE TABLE "public"."orders" (
"id" TEXT NOT NULL,
"userId" TEXT NOT NULL,
"assetId" INTEGER NOT NULL,
"type" "public"."OrderType" NOT NULL,
"status" "public"."OrderStatus" NOT NULL DEFAULT 'PENDING',
"quantity" INTEGER NOT NULL,
"price" DOUBLE PRECISION NOT NULL,
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,

CONSTRAINT "orders_pkey" PRIMARY KEY ("id")
);
25 changes: 25 additions & 0 deletions prisma/schema.prisma
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,29 @@ model User {
role String @default("user")
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
}

enum OrderType {
BUY
SELL
}

enum OrderStatus {
PENDING
EXECUTED
CANCELED
}

model Order {
id String @id @default(uuid())
userId String
assetId Int
type OrderType
status OrderStatus @default(PENDING)
quantity Int
price Float
createdAt DateTime @default(now())

@@map("orders")

}
2 changes: 2 additions & 0 deletions src/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,14 @@ import { AssetsModule } from "./assets/assets.module";
import { UsersModule } from "./users/users.module";
import { AuthModule } from "./auth/auth.module";
import { ConfigModule } from "@nestjs/config";
import { OrdersModule } from "./orders/order.module";

@Module({
imports: [
AssetsModule,
UsersModule,
AuthModule,
OrdersModule,
ConfigModule.forRoot({
isGlobal: true,
}),
Expand Down
2 changes: 1 addition & 1 deletion src/auth/auth.service.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Injectable } from "@nestjs/common";
import { JwtService } from "@nestjs/jwt";
import { UsersService } from "../users/users.service";
import * as bcrypt from "bcrypt";
import * as bcrypt from "bcryptjs";
import { UnauthorizedException } from "@nestjs/common";

@Injectable()
Expand Down
18 changes: 17 additions & 1 deletion src/main.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,23 @@
import { NestFactory } from "@nestjs/core";
import { ValidationPipe } from "@nestjs/common";
import { AppModule } from "./app.module";
import { DocumentBuilder, SwaggerModule } from '@nestjs/swagger';

async function bootstrap() {
const app = await NestFactory.create(AppModule);
await app.listen(process.env.PORT ?? 3000);



const config = new DocumentBuilder()
.setTitle('Orders API')
.setDescription('API documentation for the Orders system')
.setVersion('1.0')
.build();

const document = SwaggerModule.createDocument(app, config);
SwaggerModule.setup('api', app, document);

console.log('Swagger running at http://localhost:3000/api');

app.enableCors({
origin: process.env.CORS_ORIGIN || "*",
Expand All @@ -19,5 +32,8 @@ async function bootstrap() {
transform: true, // converts plain JavaScript objects into instances of their corresponding DTO classes
})
);

await app.listen(process.env.PORT ?? 3000);

}
bootstrap();
1 change: 0 additions & 1 deletion src/orders/.keep

This file was deleted.

Loading