Skip to content

victorfernandesraton/cep-any

Repository files navigation

cep-any

build version

A low dependency CEP lib

WARNING

if you use node.js 15 or lower, see 1.3.0 version, 2.0.0 version breaking changes because fetch native has been in use

Simple use

const {cep} = require("cep-any");

cep("41342315").them(console.log);
import {cep} from "cep-any";

Using factory and create a custonservice

const { factory, CepService , Requester} = require("cep-any");

class NewService extends CepService {
	// Requester is a http client using fetch api, but you shuld be replace for another lib
	constructor() {
		super('custonapi', Requester)
	}
	handler = async (cep) => {
		return {
			cep: "88888888",
			city: "something",
			neighborhood: "something",
			street: "something",
			state: "AB",
		};
	};
}
const instanceService = new NewService("newService");
const handler = factory({
	useDefaultProviders: false,
	custonProviders: [instanceService],
});

handler.execute("41342315").them(console.log);