Skip to content

Commit

Permalink
test cov
Browse files Browse the repository at this point in the history
  • Loading branch information
abjerry97 committed Apr 22, 2024
1 parent 8200dab commit f38cef1
Show file tree
Hide file tree
Showing 35 changed files with 4,901 additions and 28 deletions.
28 changes: 1 addition & 27 deletions .github/workflows/node.js.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,32 +24,6 @@ jobs:
- name: Lint
run: npm run lint


coverage:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
- name: Install dependencies
run: npm install

- name: Coverage
run: npm run test:cov

- name: Upload coverage reports to Codecov
uses: codecov/codecov-action@v4.0.1
with:
token: ${{ secrets.CODECOV_TOKEN }}
slug: WorldEngines/system-service
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v4
with:
flags: smart-tests
verbose: true
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}


build:
runs-on: ubuntu-latest

Expand Down Expand Up @@ -94,4 +68,4 @@ jobs:
status: ${{ job.status }}
channel: '#just-a-test'
message: Deployed {{ env.GITHUB_REF_NAME }} branch status:${{job.status}}
if: always()
if: always()
36 changes: 35 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,35 @@
node_modules
# compiled output
/dist
/node_modules

# Logs
logs
*.log
npm-debug.log*
pnpm-debug.log*
yarn-debug.log*
yarn-error.log*
lerna-debug.log*

# OS
.DS_Store

# Tests
/coverage
/.nyc_output

# IDEs and editors
/.idea
.project
.classpath
.c9/
*.launch
.settings/
*.sublime-workspace

# IDE - VSCode
.vscode/*
!.vscode/settings.json
!.vscode/tasks.json
!.vscode/launch.json
!.vscode/extensions.json
30 changes: 30 additions & 0 deletions src/interfaces/createProduct.interface.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import { IsNotEmpty, IsNumber, IsString, Min, MinLength } from "class-validator";

export class CreateProductInterface {

id: number;

@IsNotEmpty()
@IsString()
@MinLength(5)
name: string;
image?: string;
@IsNotEmpty()
@IsNumber()
@Min(0)
qty: number;
@IsNotEmpty()
@IsString()
price: string;
@IsNotEmpty()
@IsString()
@MinLength(5)
description?: string;
rating?: string;
reviews?: string[];
sold?: string;
@IsNotEmpty()
@IsString()
@MinLength(2)
sku?: string;
}
16 changes: 16 additions & 0 deletions src/interfaces/product.interface.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import { ProductPricesInterface } from "./productPrices.interface";
import { StoreInterface } from "./store.interface";

export class ProductInterface {
id: number;
name: string;
image?: string;
store?:StoreInterface;
qty?: number;
price?:ProductPricesInterface;
description?: string;
rating?: string;
reviews?: string[];
sold?: string;
sku?: string;
}
11 changes: 11 additions & 0 deletions src/interfaces/productPrices.interface.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
export interface ProductPricesInterface {
id: number;
productId: number;
rawPrice: string;
price: string;
priceDollar: string;
taxDollar: string;
oldPrice: string;
oldPriceDollar: string;
discount: string;
}
13 changes: 13 additions & 0 deletions src/interfaces/store.interface.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
export class StoreInterface {
id?: number;
status?: number;
name?: string;
email?: string;
logo?: string;
link?: string;
welcomeText?: string;
category?: string;
background?: string;
}


6 changes: 6 additions & 0 deletions src/interfaces/user-role.interface.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
export enum RolesType {
owner = 'owner',
admin = 'admin',
}

export type UserRoleType = Record<string, Record<string, RolesType>>;
21 changes: 21 additions & 0 deletions src/interfaces/user.interface.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
export class UserInterface {
id?: number;
firstName?: string;
lastName?: string;
isActive?: boolean;
email: string;
gender?: string;
profilePic?: string;
receiveNotification?: boolean;
receiveMessage?: boolean;
receivePromotionEmail?: boolean;
receiveEmail?: boolean;
roles?: string[];
store?: string;
background?: string;
token?: string;
language?: string;
city?: string;
migrate?: string;
transactions?: string[];
}
24 changes: 24 additions & 0 deletions src/main.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import { ValidationPipe } from '@nestjs/common';
import { NestFactory } from '@nestjs/core';
import { AppModule } from './modules/app/app.module';

async function bootstrap() {
const app = await NestFactory.create(AppModule);
// await app.listen(3000);
app.enableCors({
origin: [
'https://lunnex-seller-kdqsn3cto-abjerry97.vercel.app',
'https://lunnex-seller-git-main-abjerry97.vercel.app',
'https://lunnex-seller-abjerry97.vercel.app',
'https://lunnex-seller.vercel.app',
'http://localhost:3001',
'http://localhost:3000',
], //or whatever port your frontend is using
credentials: true,
methods: ['GET', 'POST', 'PUT', 'DELETE'],
// optionSuccessStatus:200
});
app.useGlobalPipes(new ValidationPipe( ));
await app.listen(3000);
}
bootstrap();
61 changes: 61 additions & 0 deletions src/models/product/product.entity.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
import {
Entity,
Column,
ManyToOne,
PrimaryGeneratedColumn,
JoinColumn,
OneToOne,
} from 'typeorm';
import { ProductPrice } from '../productPrice/productPrice.entity';
import { Store } from '../store/store.entity';

@Entity()
export class Product {
@PrimaryGeneratedColumn()
id: number;

@Column({ default: '' })
name?: string;

// @Column({ default: null })
// @ManyToOne(() => Store, (store) => store.products)
// store?: number;

@Column({ default: '' })
image?: string;

@Column({ default: 0 })
qty?: number;

@Column({ default: 0 })
status?: number;

@Column({ default: '' })
description?: string;

@Column({ default: '0' })
rating?: string;

// @Column()
// reviews: string;
@Column({ default: 0 })
sold?: number;

@JoinColumn()
@ManyToOne(() => Store, (store) => store.products)
store?: Store;

@Column({ default: '' })
sku?: string;

// @Column({ type: 'timestamp', default: () => "CURRENT_TIMESTAMP"})
@Column({ default: null })
createdAt?: Date;

// @Column({ type: 'timestamp', default: () => "CURRENT_TIMESTAMP"})
@Column({ default: null })
deletedAt?: Date;

@OneToOne(() => ProductPrice, (price) => price.product)
price?: ProductPrice;
}
46 changes: 46 additions & 0 deletions src/models/productPrice/productPrice.entity.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
import { Entity, Column, PrimaryGeneratedColumn, OneToOne, JoinColumn } from 'typeorm';
import { Product } from '../product/product.entity';

@Entity()
export class ProductPrice {
@PrimaryGeneratedColumn()
id: number;

// @Column({ default: "" })
@JoinColumn()
@OneToOne(() => Product, (product) => product.price)
product?: Product;

@Column({ default: 10 })
status?: number;

@Column({ default: '' })
rawPrice?: string;

@Column({ default: '' })
price?: string;

@Column({ default: '' })
priceDollar?: string;

@Column({ default: '' })
taxDollar?: string;

@Column({ default: '' })
oldPrice?: string;

@Column({ default: '' })
oldPriceDollar?: string;

@Column({ default: '' })
discount?: string;

@Column({ default: true })
isActive?: boolean;

@Column({ default: null })
createdAt?: Date;

@Column({ default: null })
deletedAt?: Date;
}
53 changes: 53 additions & 0 deletions src/models/store/store.entity.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@

import { Entity, Column,OneToMany, PrimaryGeneratedColumn, ManyToOne } from 'typeorm';
import { Product } from '../product/product.entity';
import { User } from '../user/user.entity';

@Entity()
export class Store{
@PrimaryGeneratedColumn()
id: number;


@ManyToOne(() => User, (user) => user.stores)
user?: User;


@Column({ default: 10 })
status?: number;

@Column({ default: "" })
name: string;

@Column({ default: "" })
email?: string;

@Column({ default: "" })
link: string;

@Column({ default: "" })
welcomeText?: string;

@Column({ default: "" })
logo?: string;


@Column({ default: "" })
category?: string;

@Column({ default: "" })
background?: string;


@OneToMany(() => Product, product => product.store)
products: Product[];

@Column({ default: true })
isActive?: boolean;

@Column({ type: 'timestamp', default: () => "CURRENT_TIMESTAMP"})
createdAt?: Date;

@Column({ type: 'timestamp', default: () => "CURRENT_TIMESTAMP"})
deletedAt?: Date;
}
Loading

0 comments on commit f38cef1

Please sign in to comment.