-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
63 changed files
with
3,003 additions
and
184 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,62 +1,3 @@ | ||
# PetMis | ||
|
||
<a alt="Nx logo" href="https://nx.dev" target="_blank" rel="noreferrer"><img src="https://raw.githubusercontent.com/nrwl/nx/master/images/nx-logo.png" width="45"></a> | ||
|
||
✨ **This workspace has been generated by [Nx, Smart Monorepos · Fast CI.](https://nx.dev)** ✨ | ||
|
||
## Integrate with editors | ||
|
||
Enhance your Nx experience by installing [Nx Console](https://nx.dev/nx-console) for your favorite editor. Nx Console | ||
provides an interactive UI to view your projects, run tasks, generate code, and more! Available for VSCode, IntelliJ and | ||
comes with a LSP for Vim users. | ||
|
||
## Start the application | ||
|
||
Run `npx nx serve pet-mis` to start the development server. Happy coding! | ||
|
||
## Build for production | ||
|
||
Run `npx nx build pet-mis` to build the application. The build artifacts are stored in the output directory (e.g. `dist/` or `build/`), ready to be deployed. | ||
|
||
## Running tasks | ||
|
||
To execute tasks with Nx use the following syntax: | ||
|
||
``` | ||
npx nx <target> <project> <...options> | ||
``` | ||
|
||
You can also run multiple targets: | ||
|
||
``` | ||
npx nx run-many -t <target1> <target2> | ||
``` | ||
|
||
..or add `-p` to filter specific projects | ||
|
||
``` | ||
npx nx run-many -t <target1> <target2> -p <proj1> <proj2> | ||
``` | ||
|
||
Targets can be defined in the `package.json` or `projects.json`. Learn more [in the docs](https://nx.dev/features/run-tasks). | ||
|
||
## Set up CI! | ||
|
||
Nx comes with local caching already built-in (check your `nx.json`). On CI you might want to go a step further. | ||
|
||
- [Set up remote caching](https://nx.dev/features/share-your-cache) | ||
- [Set up task distribution across multiple machines](https://nx.dev/nx-cloud/features/distribute-task-execution) | ||
- [Learn more how to setup CI](https://nx.dev/recipes/ci) | ||
|
||
## Explore the project graph | ||
|
||
Run `npx nx graph` to show the graph of the workspace. | ||
It will show tasks that you can run with Nx. | ||
|
||
- [Learn more about Exploring the Project Graph](https://nx.dev/core-features/explore-graph) | ||
|
||
## Connect with us! | ||
|
||
- [Join the community](https://nx.dev/community) | ||
- [Subscribe to the Nx Youtube Channel](https://www.youtube.com/@nxdevtools) | ||
- [Follow us on Twitter](https://twitter.com/nxdevtools) | ||
TODO WRITE README |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import { Test, TestingModule } from '@nestjs/testing'; | ||
import { DoctorController } from './doctor.controller'; | ||
|
||
describe('DoctorController', () => { | ||
let controller: DoctorController; | ||
|
||
beforeEach(async () => { | ||
const module: TestingModule = await Test.createTestingModule({ | ||
controllers: [DoctorController], | ||
}).compile(); | ||
|
||
controller = module.get<DoctorController>(DoctorController); | ||
}); | ||
|
||
it('should be defined', () => { | ||
expect(controller).toBeDefined(); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import { Body, Controller, Post, ValidationPipe } from '@nestjs/common'; | ||
import { DoctorService } from './doctor.service'; | ||
import { CreateDoctorDto } from './dto'; | ||
import { Doctor } from './entities'; | ||
import { ApiTags } from '@nestjs/swagger'; | ||
|
||
@ApiTags("doctor") | ||
@Controller('doctor') | ||
export class DoctorController { | ||
constructor(private doctorService: DoctorService) {} | ||
@Post() | ||
async createPatient(@Body(new ValidationPipe()) createDoctorDto: CreateDoctorDto): Promise<Doctor> { | ||
return await this.doctorService.create(createDoctorDto); | ||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import { Module } from '@nestjs/common'; | ||
import { DoctorService } from './doctor.service'; | ||
import { DoctorController } from './doctor.controller'; | ||
import { TypeOrmModule } from '@nestjs/typeorm'; | ||
import { Doctor } from './entities'; | ||
|
||
@Module({ | ||
imports: [TypeOrmModule.forFeature([Doctor])], | ||
exports: [TypeOrmModule], | ||
providers: [DoctorService], | ||
controllers: [DoctorController] | ||
}) | ||
export class DoctorModule {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import { Test, TestingModule } from '@nestjs/testing'; | ||
import { DoctorService } from './doctor.service'; | ||
|
||
describe('DoctorService', () => { | ||
let service: DoctorService; | ||
|
||
beforeEach(async () => { | ||
const module: TestingModule = await Test.createTestingModule({ | ||
providers: [DoctorService], | ||
}).compile(); | ||
|
||
service = module.get<DoctorService>(DoctorService); | ||
}); | ||
|
||
it('should be defined', () => { | ||
expect(service).toBeDefined(); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import { HttpException, HttpStatus, Injectable } from '@nestjs/common'; | ||
import { InjectRepository } from '@nestjs/typeorm'; | ||
import { Repository } from 'typeorm'; | ||
import { Doctor } from './entities'; | ||
import { CreateDoctorDto } from './dto'; | ||
|
||
@Injectable() | ||
export class DoctorService { | ||
constructor( | ||
@InjectRepository(Doctor) | ||
private doctorRepository: Repository<Doctor>, | ||
) {} | ||
|
||
async create(createDoctorDto: CreateDoctorDto): Promise<Doctor> { | ||
const entity = this.doctorRepository.create(createDoctorDto); | ||
if (entity.price < 0) { | ||
throw new HttpException("price can not be less than 0", HttpStatus.BAD_REQUEST); | ||
} | ||
|
||
return await this.doctorRepository.save(entity); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import { IsInt, IsNotEmpty, IsString, Min } from 'class-validator'; | ||
import { ApiProperty } from '@nestjs/swagger'; | ||
|
||
export class CreateDoctorDto { | ||
@IsString() | ||
@IsNotEmpty() | ||
@ApiProperty() | ||
name: string; | ||
|
||
@IsString() | ||
@IsNotEmpty() | ||
@ApiProperty() | ||
spec: string; | ||
|
||
@IsInt() | ||
@Min(0) | ||
@ApiProperty() | ||
price: number; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
import { CreateDoctorDto } from "./create-doctor.dto"; | ||
|
||
export { CreateDoctorDto } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import { Column, Entity, PrimaryGeneratedColumn } from 'typeorm'; | ||
|
||
@Entity("doctors") | ||
export class Doctor { | ||
@PrimaryGeneratedColumn('uuid') | ||
id: string; | ||
|
||
@Column() | ||
name: string; | ||
|
||
@Column() | ||
spec: string; | ||
|
||
@Column() | ||
price: number; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
import { Doctor } from "./doctor.entity"; | ||
|
||
export { Doctor } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import { Gender } from '../enums'; | ||
import { IsEmail, IsEnum, IsNotEmpty, IsString, Matches } from 'class-validator'; | ||
import { ApiProperty } from '@nestjs/swagger'; | ||
|
||
export class CreatePatientDto { | ||
@IsNotEmpty() | ||
@IsString() | ||
@ApiProperty() | ||
firstName: string; | ||
|
||
@IsNotEmpty() | ||
@IsString() | ||
@ApiProperty() | ||
lastName: string; | ||
|
||
@Matches(/^\+\d+/, { | ||
message: "phone must be valid phone format: +123456789..." | ||
}) | ||
@IsString() | ||
@ApiProperty() | ||
phone: string; | ||
|
||
@IsNotEmpty() | ||
@IsEmail() | ||
@ApiProperty() | ||
email: string; | ||
|
||
@IsEnum(Gender) | ||
@ApiProperty({ enum: Gender }) | ||
gender: Gender; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
import { CreatePatientDto } from "./create-patient.dto"; | ||
|
||
export { CreatePatientDto } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
import { Patient } from "./patient.entity"; | ||
|
||
export { Patient } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import { Entity, Column, PrimaryGeneratedColumn } from 'typeorm'; | ||
import { Gender } from '../enums'; | ||
|
||
@Entity("patients") | ||
export class Patient { | ||
@PrimaryGeneratedColumn('uuid') | ||
id: string; | ||
|
||
@Column() | ||
name: string; | ||
|
||
@Column({ unique: true }) | ||
phone: string; | ||
|
||
@Column({ unique: true }) | ||
email: string; | ||
|
||
@Column({ type: "enum", enum: Gender }) | ||
gender: Gender; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
export enum Gender { | ||
MALE = 'male', | ||
FEMALE = 'female' | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
import { Gender } from "./gender.enum"; | ||
|
||
export { Gender } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import { Test, TestingModule } from '@nestjs/testing'; | ||
import { PatientController } from './patient.controller'; | ||
|
||
describe('PatientController', () => { | ||
let controller: PatientController; | ||
|
||
beforeEach(async () => { | ||
const module: TestingModule = await Test.createTestingModule({ | ||
controllers: [PatientController], | ||
}).compile(); | ||
|
||
controller = module.get<PatientController>(PatientController); | ||
}); | ||
|
||
it('should be defined', () => { | ||
expect(controller).toBeDefined(); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import { Body, Controller, Post, ValidationPipe } from '@nestjs/common'; | ||
import { CreatePatientDto } from './dto'; | ||
import { ApiTags } from '@nestjs/swagger'; | ||
import { PatientService } from './patient.service'; | ||
import { Patient } from './entities'; | ||
|
||
@ApiTags("patient") | ||
@Controller('patient') | ||
export class PatientController { | ||
constructor(private patientService: PatientService) {} | ||
|
||
@Post() | ||
async createPatient(@Body(new ValidationPipe()) createPatientDto: CreatePatientDto): Promise<Patient> { | ||
return await this.patientService.create(createPatientDto); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import { Module } from '@nestjs/common'; | ||
import { TypeOrmModule } from '@nestjs/typeorm'; | ||
import { Patient } from './entities'; | ||
import { PatientController } from './patient.controller'; | ||
import { PatientService } from './patient.service'; | ||
|
||
@Module({ | ||
imports: [TypeOrmModule.forFeature([Patient])], | ||
exports: [TypeOrmModule, PatientService], | ||
controllers: [PatientController], | ||
providers: [PatientService] | ||
}) | ||
export class PatientModule {} |
Oops, something went wrong.