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 }
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.
- Install node 4+.
- Clone the repository.
- npm install
- Launch service: node index.js
- run tests: npm test
The solution doesn't take into account the possibilities for document values represented in the barcoded which are not currency..