Sign inSign up

aletech/integra-pedidos

By aletech

•Updated almost 2 years ago

API que recebe um arquivo, processa e persiste no mongo

Image
Integration & delivery
0

10K+

aletech/integra-pedidos repository overview

⁠Docker Compose Configuration

Este arquivo docker-compose define três serviços: mongo-express, mongo, e integra-pedidos. Cada serviço é configurado com suas próprias imagens, variáveis de ambiente, portas e verificações de integridade (healthcheck).

⁠Configuração dos Serviços

⁠1. docker-compose.yml
services:
  mongo-express:
    image: mongo-express
    ports:
      - "8083:8081"
    environment:
      ME_CONFIG_MONGODB_ADMINUSERNAME: root
      ME_CONFIG_MONGODB_ADMINPASSWORD: example
      ME_CONFIG_MONGODB_URL: mongodb://root:example@mongo:27017/

  mongo:
    image: mongo
    environment:
      MONGO_INITDB_ROOT_USERNAME: root
      MONGO_INITDB_ROOT_PASSWORD: example
    ports:
      - "27017:27017"
    healthcheck:
      test: echo 'db.runCommand("ping").ok' | mongo
      interval: 10s
      retries: 5
      start_period: 30s
      timeout: 10s

  integra-pedidos:
    image: aletech/integra-pedidos
    platform: linux/amd64 # For ARM64 use platform: linux/arm64
    ports:
      - "8080:8080"
    healthcheck:
      test: curl --fail http://localhost:8080/actuator/health || exit 1
      interval: 10s
      retries: 5
      start_period: 30s
      timeout: 10s
    depends_on:
      - mongo

Após criar o arquivo acima, basta abrir o prompt e digitar

$ docker-compose up -d

Com isso o ambiente estará pronto para testes.

Abaixo está disponível uma collection do postman que pode ser importada:

{
	"info": {
		"_postman_id": "3faa77d9-254f-4e6c-aecf-5ae9cb37f70f",
		"name": "integra-pedidos",
		"schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json",
		"_exporter_id": "3986066"
	},
	"item": [
		{
			"name": "Upload Arquivos",
			"request": {
				"method": "POST",
				"header": [],
				"body": {
					"mode": "formdata",
					"formdata": [
						{
							"key": "file",
							"type": "file",
							"src": "path_to_your_file"
						}
					]
				},
				"url": {
					"raw": "http://localhost:8080/api/pedidos/upload",
					"protocol": "http",
					"host": [
						"localhost"
					],
					"port": "8080",
					"path": [
						"api",
						"pedidos",
						"upload"
					]
				}
			},
			"response": []
		},
		{
			"name": "Lista todos pedidos",
			"request": {
				"method": "GET",
				"header": [],
				"url": {
					"raw": "http://localhost:8080/api/pedidos",
					"protocol": "http",
					"host": [
						"localhost"
					],
					"port": "8080",
					"path": [
						"api",
						"pedidos"
					]
				}
			},
			"response": []
		},
		{
			"name": "Lista pedido por período de data",
			"request": {
				"method": "GET",
				"header": [],
				"url": {
					"raw": "http://localhost:8080/api/pedidos/between/2021-05-20/2021-05-29",
					"protocol": "http",
					"host": [
						"localhost"
					],
					"port": "8080",
					"path": [
						"api",
						"pedidos",
						"between",
						"2021-05-20",
						"2021-05-29"
					]
				}
			},
			"response": []
		},
		{
			"name": "Lista pedido por id",
			"request": {
				"method": "GET",
				"header": [],
				"url": {
					"raw": "http://localhost:8080/api/pedidos/7",
					"protocol": "http",
					"host": [
						"localhost"
					],
					"port": "8080",
					"path": [
						"api",
						"pedidos",
						"7"
					]
				}
			},
			"response": []
		}
	]
}
⁠Regras do arquivo:
campotamanhotipo
id usuário10numérico
nome45texto
id pedido10numérico
id produto10numérico
valor do produto12decimal
data compra8numérico ( formato: yyyymmdd )
⁠Exemplos:
0000000033                                Luther Hudson00000002910000000003      110.0220211203
0000000005                       Davina Heidenreich PhD00000000480000000005      997.7420210924
0000000151                                    Jan Johns00000014000000000006     1005.8520211106
0000000079                                  Jay Tillman00000007330000000004       686.920210829
0000000019                           Ms. Rory Powlowski00000001680000000003      405.9420210412
0000000187                                 Rodney Crist00000017320000000001     1706.6120211120
0000000040                              Randal Cummings00000003760000000000      874.2220210714

Tag summary

Content type

Image

Digest

sha256:4028bc1e1…

Size

318.4 MB

Last updated

almost 2 years ago

docker pull aletech/integra-pedidos