Greenmap-Server is a Node.js RESTful-api built to serve the Greenmap-App.
Ensure that Node.js and npm is installed on your device.
node --version // v11.14.0
npm --version // 6.9.0
Ensure that MongoDB is installed on your device.
mongo --version // MongoDB shell version v4.0.3
The Greenmap-Server has several endpoints for getting products and putting products into the Greenmap database.
-
Returns a product stored in the Greenmap Database.
-
URL
/:barcode
-
Method:
GET
-
URL Params
Required:
http://serverhost:port/somebarcode ... // e.g. http://localhost:3000/8152210266539
-
-
Adds a product to the Greenmap Database using a Barcodelookup request.
-
URL
/
-
Method:
POST
-
Body Params
Required:
{ barcode:'some barcode' } ... // e.g. { barcode: '0886111601387' }
-
-
- Code: 200
Content:{ "_id": "5cea1545c6a0a2ba74f5d2fb", "barcode": "0886111601387", "name": "HP 932XL Officejet Single Ink Cartridge - Black (CN053AN#14), Black (932xl)", "category": "Electronics > Print, Copy, Scan & Fax > Printer, Copier & Fax Machine Accessories > Printer Consumables > Toner & Inkjet Cartridges", "manufacturer": "Hp", "ESG": "0", "__v": 0 }
- Code: 200
-
- Code: 201
Content:{ "_id": "5cea1545c6a0a2ba74f5d2fb", "barcode": "0886111601387", "name": "HP 932XL Officejet Single Ink Cartridge - Black (CN053AN#14), Black (932xl)", "category": "Electronics > Print, Copy, Scan & Fax > Printer, Copier & Fax Machine Accessories > Printer Consumables > Toner & Inkjet Cartridges", "manufacturer": "Hp", "ESG": "0", "__v": 0 }
- Code: 201
-
- Code: 400 BAD REQUEST
Content:{ // error message }
- Code: 400 BAD REQUEST
-
- Code: 404 NOT FOUND
Content:{ // error message }
- Code: 404 NOT FOUND
-
- Code: 413 PRECONDITION FAILED
Content:{ // error message }
- Code: 413 PRECONDITION FAILED
-
- Code: 500 INTERNAL SERVER ERROR
Content:{ // error message }
- Code: 500 INTERNAL SERVER ERROR