Git Product home page Git Product logo

doctorapi's Introduction

Projeto DoctorAPI

Consiste em uma simples API que permite o registro de médicos e seus dados.

DoctorAPI

Built With

Description

Nesse desafio foi proposto a criação de uma API que permitisse o registro de médicos, informando os dados pessoais, juntamente com o CEP. A partir do CEP deve ser feito uma requisição para a API dos correios e pegar as informações do endereço do médico.

Features

  • Add doctor.
  • Get all registered doctors, Get doctor by queries and params .
  • Update doctor info.
  • Soft delete a doctor.

Seed db

http://localhost:5000
POST /specialties/seed

Response:

message: Specialties added!
status: 201

Get registered specialties

http://localhost:5000
GET /specialties

Response:

status: 200
data:[
  {
		"id": 1,
		"name": "Alergologia",
		"doctors": []
	},
	{
		"id": 2,
		"name": "Angiologia",
		"doctors": []
	},
	{
		"id": 3,
		"name": "Buco maxilo",
		"doctors": []
	},
	{
		"id": 4,
		"name": "Cardiologia clínica",
		"doctors": []
	},
  {
		"id": 5,
		"name": "Cardiologia infantil",
		"doctors": []
	},
	{
		"id": 6,
		"name": "Cirurgia cabeça e pescoço",
		"doctors": []
	},
	{
		"id": 7,
		"name": "Cirurgia cardíaca",
		"doctors": []
	},
	{
		"id": 8,
		"name": "Cirurgia de tórax",
		"doctors": []
	}
]

Add doctor

http://localhost:5000
POST /doctors/add

Request:

Body Type Description
name string Required. doctor name
crm string Required. doctor crm
telefoneFixo string Required. doctor telefoneFixo
telefoneCelular string Required. doctor telefoneCelular
cep string Required. doctor cep
specialties number[] Required. doctor specialties

name: no máximo 120 caractéres

crm: no máximo 7 caracteres

cep: deve ser um cep válido.

specialties: Array de números de 1 a 8, deve conter pelo menos dois números

Response:

message: Doctor successfully registered!
status: 201

Get all registered doctors

http://localhost:5000
GET /doctors

Response:

status: 200
data:[
	{
		"id": 1,
		"name": "Almeida",
		"crm": "7554611",
		"telefoneFixo": "81374098174",
		"telefoneCelular": "813298470349",
		"cep": "60720096",
		"specialties": [
			"Alergologia",
			"Angiologia",
			"Buco maxilo",
			"Cardiologia infantil",
			"Cirurgia cabeça e pescoço"
		]
	},
	{
		"id": 2,
		"name": "Carlos",
		"crm": "7554622",
		"telefoneFixo": "85374098174",
		"telefoneCelular": "853298470349",
		"cep": "79002051",
		"specialties": [
			"Alergologia",
			"Angiologia",
		]
	},
  ...
]

Get doctor by queries and params

http://localhost:5000
GET /doctors/:id
GET /doctors?name={}
GET /doctors?crm={}
GET /doctors?telefoneFixo={}
GET /doctors?telefoneCelular={}}
GET /doctors?cep={}
GET /doctors?name=specialties={}

Response:

status:200
data:
[
	{
		"id": 1,
		"name": "Almeida",
		"crm": "7554611",
		"telefoneFixo": "81374098174",
		"telefoneCelular": "813298470349",
		"cep": "60720096",
		"specialties": [
			"Alergologia",
			"Angiologia",
			"Buco maxilo",
			"Cardiologia infantil",
			"Cirurgia cabeça e pescoço"
		]
	}
]

Cep query

status:200
data:
[
	{
		"id": 1,
		"name": "Almeida",
		"crm": "7554611",
		"telefoneFixo": "81374098174",
		"telefoneCelular": "813298470349",
		"specialties": [
			"Alergologia",
			"Angiologia",
			"Buco maxilo",
			"Cardiologia infantil",
			"Cirurgia cabeça e pescoço"
		],
		"address": {
			"cep": "60720-096",
			"logradouro": "Rua Cônego de Castro",
			"complemento": "até 1538 - lado par",
			"bairro": "Parangaba",
			"localidade": "Fortaleza",
			"uf": "CE",
			"ibge": "2304400",
			"gia": "",
			"ddd": "85",
			"siafi": "1389"
		}
	}
]

Update doctor info

http://localhost:5000
PATCH /doctors/update/:id

Request:

Params Type Description
id integer Required. doctorId

Body Type Description
name string Optional. doctor name
crm string Optional. doctor crm
telefoneFixo string Optional. doctor telefoneFixo
telefoneCelular string Optional. doctor telefoneCelular
cep string Optional. doctor cep
specialties number[] Optional. doctor specialties

Response:

status:200
updatedData:
{
	"id": 1,
	"name": "Almeida",
	"crm": "7554611",
	"telefoneFixo": "81374098174",
	"telefoneCelular": "813298470349",
	"cep": "60720096",
	"specialties": [
		"Cirurgia cabeça e pescoço",
		"Cirurgia cardíaca"
	]
}

Soft delete doctor

http://localhost:5000
PATCH /doctors/delete/:id

Request:

Params Type Description
id integer Required. doctorId

Response:

message: Doctor deactivated from system!

Re-activate soft deleted doctor

http://localhost:5000
PATCH doctors/activate/:id

Request:

Params Type Description
id integer Required. doctorId

Response:

message: Doctor active!

Environment Variables

POSTGRES_HOST=gcb-db

POSTGRES_PORT=5432

POSTGRES_USER=postgres

POSTGRES_PASSWORD=1234

POSTGRES_DATABASE=gcb

PORT=5000

NODE_ENV=development

Run Locally

Clone the project

  git clone https://github.com/FKnight-cyber/DoctorApi

Start the server

First remember to create .env, check .env-example archive.

on root folder

  run: npm run docker-compose up --build -d

Run e2e tests

 run: npm run test:e2e

Run unit tests

 run: npm run test:watch doctor.service.spec.ts
 run: npm run test:watch specialty.service.spec.ts

Lessons Learned

Apesar de simples foi um projeto que me fez aprender bastante, até então não tinha desenvolvido nenhum projeto com NestJS e TypeORM, gostei muito da forma como o Nest lida com o Typescript. Foi uma experiência nova e gratificante construir uma API com Nest.js .

Authors

  • Ryan Nicholas a full-stack developer looking for new challenges!.

doctorapi's People

Contributors

fknight-cyber avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.