This is a Node.js server for the Grocery Scan App. It provides APIs for managing grocery products using SQLite as the database.
- Node.js installed on your system.
- npm (Node Package Manager) installed on your system.
-
Clone the repository:
git clone <repository-url>
-
Navigate to the project directory:
cd grocery-scan-app-server
-
Install dependencies:
npm install
-
Make a copy of a
.env.example
file in the root directory and add your environment variables:copy .\.env.example .env
To start the Node.js server, run the following command:
node server.js
The base URL for all API requests is localhost:PORT
or https://<PROJECT_ID>.ondigitalocean.app
API requests must include a predefined Authorization header with a valid token.
- Key:
Authorization
- Value:
Bearer <API_TOKEN>
- Route:
/products
- Method: GET
- Description: Retrieves all products from the database.
- Route:
/product/:barcode
- Method: GET
- Description: Retrieves a product from the database based on its barcode with ingredients list.
- Parameters:
barcode
: The unique identifier of the product.
-
401 Unauthorized: Missing Authorization header Returned when the request does not include an Authorization header.
-
401 Unauthorized: Invalid token Returned when the provided token in the Authorization header is invalid.
-
404 Product not found for barcode: [barcode] Returned when no product is found in the database for the specified barcode.
Continuous deployment is live to a DigitalOcean Droplet, and the app is auto-updating relative to changes to the main branch.
Made with ❤️ and JavaScript.