Skip to content

Commit

Permalink
feat: add cep methods
Browse files Browse the repository at this point in the history
  • Loading branch information
rfoel committed Dec 16, 2020
1 parent c363a40 commit e3bc574
Show file tree
Hide file tree
Showing 18 changed files with 15,160 additions and 3 deletions.
4 changes: 4 additions & 0 deletions .github/FUNDING.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
github: [rfoel]
patreon: rfoel
open_collective: rfoel
ko_fi: rfoel
12 changes: 12 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
version: 2
updates:
- package-ecosystem: npm
directory: '/'
schedule:
interval: daily
time: '08:00'
open-pull-requests-limit: 10
target-branch: develop
commit-message:
prefix: fix
prefix-development: chore
19 changes: 19 additions & 0 deletions .github/workflows/develop.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
name: Develop

on:
push:
branches:
- develop

jobs:
develop:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v1
with:
node-version: 12
- run: npm install
- run: npm test
- run: npm run lint
- run: npm run build
23 changes: 23 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
name: Publish

on:
push:
branches:
- main

jobs:
publish:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v1
with:
node-version: 12
- run: npm install
- run: npm test
- run: npm run lint
- run: npm run build
- run: npx semantic-release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
24 changes: 24 additions & 0 deletions .releaserc
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{
"branches": [
"main"
],
"plugins": [
"@semantic-release/commit-analyzer",
"@semantic-release/release-notes-generator",
"@semantic-release/changelog",
[
"@semantic-release/npm",
{
"tarballDir": "release"
}
],
[
"@semantic-release/github",
{
"assets": "release/*.tgz"
}
],
"@semantic-release/git"
],
"preset": "angular"
}
89 changes: 89 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,92 @@
# viacep

[![npm](https://img.shields.io/npm/v/viacep)](https://www.npmjs.com/viacep)
[![npm bundle size](https://img.shields.io/bundlephobia/minzip/viacep)](https://www.npmjs.com/viacep)
[![NPM](https://img.shields.io/npm/l/viacep)](LICENSE)
[![semantic-release](https://img.shields.io/badge/%20%20%F0%9F%93%A6%F0%9F%9A%80-semantic--release-e10079.svg)](https://github.com/semantic-release/semantic-release)

Procurando um webservice gratuito e de alto desempenho para consultar Códigos de Endereçamento Postal (CEP) do Brasil? Utilize o serviço, melhore a qualidade de suas aplicações web e colabore para manter esta base de dados atualizada. Mais informações no [site oficial](https://viacep.com.br/).

## Instalação

Para instalar o pacote rode:

```
npm install viacep
```

ou

```
yarn add viacep
```

## Início rápido

```js
import { viacep } from 'viacep'

const viacep = new viacep()

;(async () => {
try {
const data = await viacep.cep('01001-000')
console.log(data)
} catch (error) {
console.log(error)
}
})()
```

## Métodos disponíveis

### CEP

Busca por endereço pelo número do CEP.

```js
viacep.cep('01001-000')

// {
// cep: '01310-000',
// logradouro: 'Avenida Paulista',
// complemento: 'até 610 - lado par',
// bairro: 'Bela Vista',
// localidade: 'São Paulo',
// uf: 'SP',
// ibge: '3550308',
// gia: '1004',
// ddd: '11',
// siafi: '7107'
// }
```

Também existe um overload para encontrar endereços a partir de estado, cidade e rua. O retorno desse método é uma array de endereços.

```js
viacep.cep({ state: 'SP', city: 'São Paulo', street: 'Praça da Sé' })

// [
// {
// cep: '01001-000',
// logradouro: 'Praça da Sé',
// complemento: 'lado ímpar',
// bairro: 'Sé',
// localidade: 'São Paulo',
// uf: 'SP',
// ibge: '3550308',
// gia: '1004',
// ddd: '11',
// siafi: '7107'
// },
// ...
// ]
```

## Contribuindo

Issues e Pull requests são bem-vindos.

## Licença

[MIT](https://github.com/rfoel/viacep/blob/main/LICENSE)
10 changes: 10 additions & 0 deletions jest.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
module.exports = {
preset: 'ts-jest',
testEnvironment: 'node',
globals: {
'ts-jest': {
diagnostics: false,
},
},
testMatch: ['**/tests/*.test.ts'],
}

0 comments on commit e3bc574

Please sign in to comment.