New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

github.com/kiriwill/events-api

Package Overview
Dependencies
Alerts
File Explorer
Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

github.com/kiriwill/events-api

  • v0.0.0-20240530211740-3c771b6a4d31
  • Source
  • Go
  • Socket score

Version published
Created
Source

API Simples para Eventos

API escrita para criar e obter eventos e suas metricas

Dependencias

  • github.com/kelseyhightower/envconfig v1.4.0
  • github.com/labstack/echo/v4 v4.11.3
  • gorm.io/driver/mysql v1.5.6
  • gorm.io/gorm v1.25.10

Estrutura do projeto

  • /cmd abriga todo o código que será construído e enviado como binários. Ele está noemado como main.go e encontrados em /cmd/<nome-do-executável>/main.go
  • /pkg abriga a base de código compartilhada real do projeto. Todos os módulos usados pelos pontos de entrada virão desta pasta.
  • /scripts abriga scripts utilitários úteis, como dev.sh que executa o projeto em um ambiente de desenvolvimento local

Instalação

Com api no docker:

docker compose up

Sem API no docker (rodando atualmente só o db no container):

make dev

Examplos de rotas

ATENÇÂO: Para acessar as rotas é necessário criar um usuario e depois passar um token obtido a partir da rota user/signin para a rota que será acessada

Criar um novo usuario

POST {host:port}/v1/user/

requisição
curl --location 'localhost:8080/v1/user/' \
--header 'Content-Type: application/json' \
--data-raw '{
    "name": "user teste",
    "birthdate": "1989-01-02",
    "email": "will@email.com",
    "password": "1234"
}'
resposta
{
    "ID": 6
}

Obter um novo token de acesso

POST {host:port}/v1/user/signin

requisição
curl --location 'localhost:8080/v1/user/signin' \
--header 'Content-Type: application/json' \
--data-raw '{
    "email": "will@email.com",
    "password": "1234"
}'
resposta
{
    "ID": 6
}

Criar um novo evento

POST {host:port}/v1/events/

requisição
curl --location 'localhost:8080/v1/events/' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJleHAiOjE3MTczNjE3MTR9.JYS8slfIo-1ySGPEFM6qBbVOPPUHomGTn8yEdecKjjw' \
--data '{
    "category": "teste categoria",
    "description": "descrição teste",
    "country": "colômbia"
}'
resposta
{
    "id": 1,
    "createdat": "2024-05-30t13:20:14.821z",
    "updatedat": "2024-05-30t13:20:14.821z",
    "deletedat": null,
    "category": "teste categoria",
    "description": "descrição teste",
    "country": "colômbia"
}

Busca um novo evento

GET {host:port}/v1/events/

Requisição
curl --location 'localhost:8080/v1/events/?date=2024-05&type=teste%20cate' \
--header 'Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJleHAiOjE3MTczNjE3MTR9.JYS8slfIo-1ySGPEFM6qBbVOPPUHomGTn8yEdecKjjw'
Resposta
[
    {
        "ID": 1,
        "CreatedAt": "2024-05-30T13:20:14.821Z",
        "UpdatedAt": "2024-05-30T13:20:14.821Z",
        "DeletedAt": null,
        "category": "teste categoria",
        "description": "descrição teste",
        "country": "colômbia"
    }
]

Cria metricas (três paises com maior quantidade de eventos)

GET {host:port}/v1/events/metrics/

Requisição
curl --location 'localhost:8080/v1/events/metrics/' \
--header 'Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJleHAiOjE3MTczNjE3MTR9.JYS8slfIo-1ySGPEFM6qBbVOPPUHomGTn8yEdecKjjw'
Resposta
[
    {
        "Country": "colômbia",
        "Count": 55
    },
    {
        "Country": "brasil",
        "Count": 30
    },
    {
        "Country": "argentina",
        "Count": 12
    }
]

FAQs

Package last updated on 30 May 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc