Skip to content

pedraumcosta/barcoderestservice

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Barcode Rest Service

Restful service that receive a bar code typed (47 or 48 digits) in the URL parameter and will return a JSON response with validation status, a message, the barcode in the standard format 44 digits, the due date and its value.

Request Example: http://localhost:3000/barras?codigo=846700000017435900240209024050002435842210108119

Response Example: { status: "OK", mensagem: "Barcode eh um documento de concessionaria", codigoBarras: "84670000001435900240200240500024384221010811", dataVencimento: null, valorDocumento: 143.59 }

Solution Design

The service is a NodeJS solution using Express as HTTP server and Mocha for tests. Inspect index.js, server.js, routes.js and config.js to see how the server is coded.

The barcode module has the business logic for brazilian barcodes, please inspect barcode.js to verify barcode implementations.

The test folder contains tests for the moudule and the rest service with a nice coverage.

Deploy

  • Install node 4+.
  • Clone the repository.
  • npm install
  • Launch service: node index.js
  • run tests: npm test

Improvements

The solution doesn't take into account the possibilities for document values represented in the barcoded which are not currency..

About

REST API to handle brazilian barcodes

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published