diff --git a/README.md b/README.md index d787fdb0..5367031e 100644 --- a/README.md +++ b/README.md @@ -1,109 +1,40 @@ -# JSON Server Template +# Introduction +This is the json server for FarmFolio. To set it up in a development environment follow the steps below. -## Setup -Fork and clone this repo. Then install the dependencies by running: +# Setting up -```sh -npm install -``` +## 1. Clone the repository -## Seeding Data - -To set up your database, update the `db/seeds.json` file to contain an object -with a key pointing to an array of data, like this: - -```json -{ - "toys": [ - { - "id": 1, - "name": "Woody", - "image": "http://www.pngmart.com/files/3/Toy-Story-Woody-PNG-Photos.png", - "likes": 8 - }, - { - "id": 2, - "name": "Buzz Lightyear", - "image": "http://www.pngmart.com/files/6/Buzz-Lightyear-PNG-Transparent-Picture.png", - "likes": 14 - } - ] -} ``` +git@github.com:NB-Kamoni/FarmFolio-Backend.git -Then, run `npm run seed` to copy data from the `db/seeds.json` file to the -`db/db.json` file. `json-server` uses the `db.json` file to create your RESTful -API, so make sure your `db.json` file is always up to date! - -Any time you want to reset your database back to your original data, run -`npm run seed` again. Doing this will overwrite all the data in your `db.json` -file, so make sure you don't have any data in that file that you don't mind -losing! - -## Running the Server Locally - -To run your server in development mode, run: - -```sh -npm run dev ``` -While running in development mode, the server will re-load any time you make -changes to the `db.json` file, so you can test our your seed data. - -While your server is running, you can make requests to -[http://localhost:3000](http://localhost:3000). Check it out in the browser to -make sure your server works! - -## Deploying +## 2. Install the dependencies -Free services like Render make it simple to deploy your Node server. Render also -works nicely with Rails, which you'll learn later in the program. - -### Sign Up for a Render Account - -You can sign up for a free account at -[https://dashboard.render.com/register][Render signup]. We recommend that you -sign up using GitHub as that will make it a little easier for you to connect -Render to your GitHub account. The instructions below assume you've done that. +``` +npm install -[Render signup]: https://dashboard.render.com/register +``` -Once you've completed the signup process, you will be taken to the Render -dashboard. +## 3. Start the development server -In order to connect Render to your GitHub account, you'll need to click the "New -Web Service" button in the "Web Services" box. On the next page, you will see a -GitHub heading on the right side and below that a link labeled "Configure -account". (If you didn't sign up using GitHub, it will say "Connect account" -instead.) Click that link; a modal will appear asking you for permission to -install Render on your GitHub account. Click "Install." You should then be taken -back to the "Create a New Web Service" page, which should now show a list of -your GitHub repos. +``` +npm run dev -### Deploy the Server +``` -Find the GitHub repo for your json server in the list and click Connect. Give -the web service a name and make sure the Environment is set to Node. Everything -else can be left as is. Scroll down to the bottom of the page and click "Create -Web Service." The build process will begin automatically. +use CTRL + C to stop the server -The URL for your deployed server is shown in the upper left corner of the page, -e.g., `https://my-server.onrender.com`. Once the build is complete, you will be able to -make fetch requests to that URL. +## 3. Reset the data +Since this server is for testing and prototyping, you can reset the data to its initial state.. In future this backend will be migrated to a more secure and scalabele DB. -### Making Updates +Feel free to reset the data to its initial state through: -Since Render deployment integrates with your GitHub repo, you can easily deploy -changes to your database. First, commit and push your code up to GitHub: +``` +npm run seed -```sh -git add . -git commit -m "Updated database" -git push ``` -Then launch the build process by going to the page for your server on the -Render dashboard, clicking the "Manual Deploy" button in the upper right corner -of the page, and selecting "Deploy latest commit." +Incase you add a new endpoint (a new key and its array), Please update the initial state of the data in seeds.json \ No newline at end of file diff --git a/db/db.json b/db/db.json index 746cc522..7e13e83a 100644 --- a/db/db.json +++ b/db/db.json @@ -1,444 +1,262 @@ { - "example": [ + "chickens": [ { "id": 1, - "exampleAttributeString": "This is just an example. Please supply your own data.", - "exampleImgString": "https://placehold.co/150x150.jpg", - "exampleAttributesArray": ["Replace", "this", "data"], - "exampleAttributeNumber": 2341, - "exampleAttributeObj": { - "objectKey": "objectValue" - }, - "exampleAttributeBoolean": false + "age_months": 12, + "weight_kg": 2.5, + "total_eggs": 20, + "date": "2024-05-04", + "daily_eggs": 2 }, { "id": 2, - "exampleAttributeString": "This is just an example. Please supply your own data.", - "exampleImgString": "https://placehold.co/150x150.jpg", - "exampleAttributesArray": ["Replace", "this", "data"], - "exampleAttributeNumber": 2341, - "exampleAttributeObj": { - "objectKey": "objectValue" - }, - "exampleAttributeBoolean": false + "age_months": 8, + "weight_kg": 1.8, + "total_eggs": 15, + "date": "2024-05-04", + "daily_eggs": 1 }, { "id": 3, - "exampleAttributeString": "This is just an example. Please supply your own data.", - "exampleImgString": "https://placehold.co/150x150.jpg", - "exampleAttributesArray": ["Replace", "this", "data"], - "exampleAttributeNumber": 2341, - "exampleAttributeObj": { - "objectKey": "objectValue" - }, - "exampleAttributeBoolean": false + "age_months": 10, + "weight_kg": 1.6, + "total_eggs": 18, + "date": "2024-05-04", + "daily_eggs": 3 }, { "id": 4, - "exampleAttributeString": "This is just an example. Please supply your own data.", - "exampleImgString": "https://placehold.co/150x150.jpg", - "exampleAttributesArray": ["Replace", "this", "data"], - "exampleAttributeNumber": 2341, - "exampleAttributeObj": { - "objectKey": "objectValue" - }, - "exampleAttributeBoolean": false + "age_months": 14, + "weight_kg": 2.3, + "total_eggs": 22, + "date": "2024-05-04", + "daily_eggs": 4 }, { "id": 5, - "exampleAttributeString": "This is just an example. Please supply your own data.", - "exampleImgString": "https://placehold.co/150x150.jpg", - "exampleAttributesArray": ["Replace", "this", "data"], - "exampleAttributeNumber": 2341, - "exampleAttributeObj": { - "objectKey": "objectValue" - }, - "exampleAttributeBoolean": false + "age_months": 9, + "weight_kg": 1.7, + "total_eggs": 17, + "date": "2024-05-04", + "daily_eggs": 2 }, { "id": 6, - "exampleAttributeString": "This is just an example. Please supply your own data.", - "exampleImgString": "https://placehold.co/150x150.jpg", - "exampleAttributesArray": ["Replace", "this", "data"], - "exampleAttributeNumber": 2341, - "exampleAttributeObj": { - "objectKey": "objectValue" - }, - "exampleAttributeBoolean": false + "age_months": 11, + "weight_kg": 2, + "total_eggs": 19, + "date": "2024-05-04", + "daily_eggs": 2 }, { "id": 7, - "exampleAttributeString": "This is just an example. Please supply your own data.", - "exampleImgString": "https://placehold.co/150x150.jpg", - "exampleAttributesArray": ["Replace", "this", "data"], - "exampleAttributeNumber": 2341, - "exampleAttributeObj": { - "objectKey": "objectValue" - }, - "exampleAttributeBoolean": false + "age_months": 13, + "weight_kg": 2.2, + "total_eggs": 21, + "date": "2024-05-04", + "daily_eggs": 3 }, { "id": 8, - "exampleAttributeString": "This is just an example. Please supply your own data.", - "exampleImgString": "https://placehold.co/150x150.jpg", - "exampleAttributesArray": ["Replace", "this", "data"], - "exampleAttributeNumber": 2341, - "exampleAttributeObj": { - "objectKey": "objectValue" - }, - "exampleAttributeBoolean": false + "age_months": 7, + "weight_kg": 1.5, + "total_eggs": 14, + "date": "2024-05-04", + "daily_eggs": 1 }, { "id": 9, - "exampleAttributeString": "This is just an example. Please supply your own data.", - "exampleImgString": "https://placehold.co/150x150.jpg", - "exampleAttributesArray": ["Replace", "this", "data"], - "exampleAttributeNumber": 2341, - "exampleAttributeObj": { - "objectKey": "objectValue" - }, - "exampleAttributeBoolean": false + "age_months": 15, + "weight_kg": 2.6, + "total_eggs": 24, + "date": "2024-05-04", + "daily_eggs": 4 }, { "id": 10, - "exampleAttributeString": "This is just an example. Please supply your own data.", - "exampleImgString": "https://placehold.co/150x150.jpg", - "exampleAttributesArray": ["Replace", "this", "data"], - "exampleAttributeNumber": 2341, - "exampleAttributeObj": { - "objectKey": "objectValue" - }, - "exampleAttributeBoolean": false + "age_months": 16, + "weight_kg": 2.8, + "total_eggs": 26, + "date": "2024-05-04", + "daily_eggs": 3 }, { "id": 11, - "exampleAttributeString": "This is just an example. Please supply your own data.", - "exampleImgString": "https://placehold.co/150x150.jpg", - "exampleAttributesArray": ["Replace", "this", "data"], - "exampleAttributeNumber": 2341, - "exampleAttributeObj": { - "objectKey": "objectValue" - }, - "exampleAttributeBoolean": false + "age_months": 11, + "weight_kg": 2.1, + "total_eggs": 20, + "date": "2024-05-04", + "daily_eggs": 2 }, { "id": 12, - "exampleAttributeString": "This is just an example. Please supply your own data.", - "exampleImgString": "https://placehold.co/150x150.jpg", - "exampleAttributesArray": ["Replace", "this", "data"], - "exampleAttributeNumber": 2341, - "exampleAttributeObj": { - "objectKey": "objectValue" - }, - "exampleAttributeBoolean": false + "age_months": 18, + "weight_kg": 3, + "total_eggs": 28, + "date": "2024-05-04", + "daily_eggs": 4 }, { "id": 13, - "exampleAttributeString": "This is just an example. Please supply your own data.", - "exampleImgString": "https://placehold.co/150x150.jpg", - "exampleAttributesArray": ["Replace", "this", "data"], - "exampleAttributeNumber": 2341, - "exampleAttributeObj": { - "objectKey": "objectValue" - }, - "exampleAttributeBoolean": false + "age_months": 10, + "weight_kg": 2.2, + "total_eggs": 19, + "date": "2024-05-04", + "daily_eggs": 2 }, { "id": 14, - "exampleAttributeString": "This is just an example. Please supply your own data.", - "exampleImgString": "https://placehold.co/150x150.jpg", - "exampleAttributesArray": ["Replace", "this", "data"], - "exampleAttributeNumber": 2341, - "exampleAttributeObj": { - "objectKey": "objectValue" - }, - "exampleAttributeBoolean": false + "age_months": 12, + "weight_kg": 2.3, + "total_eggs": 21, + "date": "2024-05-04", + "daily_eggs": 3 }, { "id": 15, - "exampleAttributeString": "This is just an example. Please supply your own data.", - "exampleImgString": "https://placehold.co/150x150.jpg", - "exampleAttributesArray": ["Replace", "this", "data"], - "exampleAttributeNumber": 2341, - "exampleAttributeObj": { - "objectKey": "objectValue" - }, - "exampleAttributeBoolean": false + "age_months": 14, + "weight_kg": 2.4, + "total_eggs": 23, + "date": "2024-05-04", + "daily_eggs": 3 }, { "id": 16, - "exampleAttributeString": "This is just an example. Please supply your own data.", - "exampleImgString": "https://placehold.co/150x150.jpg", - "exampleAttributesArray": ["Replace", "this", "data"], - "exampleAttributeNumber": 2341, - "exampleAttributeObj": { - "objectKey": "objectValue" - }, - "exampleAttributeBoolean": false + "age_months": 9, + "weight_kg": 1.9, + "total_eggs": 16, + "date": "2024-05-04", + "daily_eggs": 1 }, { "id": 17, - "exampleAttributeString": "This is just an example. Please supply your own data.", - "exampleImgString": "https://placehold.co/150x150.jpg", - "exampleAttributesArray": ["Replace", "this", "data"], - "exampleAttributeNumber": 2341, - "exampleAttributeObj": { - "objectKey": "objectValue" - }, - "exampleAttributeBoolean": false + "age_months": 13, + "weight_kg": 2.3, + "total_eggs": 21, + "date": "2024-05-04", + "daily_eggs": 2 }, { "id": 18, - "exampleAttributeString": "This is just an example. Please supply your own data.", - "exampleImgString": "https://placehold.co/150x150.jpg", - "exampleAttributesArray": ["Replace", "this", "data"], - "exampleAttributeNumber": 2341, - "exampleAttributeObj": { - "objectKey": "objectValue" - }, - "exampleAttributeBoolean": false + "age_months": 10, + "weight_kg": 2.1, + "total_eggs": 18, + "date": "2024-05-04", + "daily_eggs": 2 }, { "id": 19, - "exampleAttributeString": "This is just an example. Please supply your own data.", - "exampleImgString": "https://placehold.co/150x150.jpg", - "exampleAttributesArray": ["Replace", "this", "data"], - "exampleAttributeNumber": 2341, - "exampleAttributeObj": { - "objectKey": "objectValue" - }, - "exampleAttributeBoolean": false + "age_months": 11, + "weight_kg": 2.2, + "total_eggs": 19, + "date": "2024-05-04", + "daily_eggs": 3 }, { "id": 20, - "exampleAttributeString": "This is just an example. Please supply your own data.", - "exampleImgString": "https://placehold.co/150x150.jpg", - "exampleAttributesArray": ["Replace", "this", "data"], - "exampleAttributeNumber": 2341, - "exampleAttributeObj": { - "objectKey": "objectValue" - }, - "exampleAttributeBoolean": false - }, - { - "id": 21, - "exampleAttributeString": "This is just an example. Please supply your own data.", - "exampleImgString": "https://placehold.co/150x150.jpg", - "exampleAttributesArray": ["Replace", "this", "data"], - "exampleAttributeNumber": 2341, - "exampleAttributeObj": { - "objectKey": "objectValue" - }, - "exampleAttributeBoolean": false - }, - { - "id": 22, - "exampleAttributeString": "This is just an example. Please supply your own data.", - "exampleImgString": "https://placehold.co/150x150.jpg", - "exampleAttributesArray": ["Replace", "this", "data"], - "exampleAttributeNumber": 2341, - "exampleAttributeObj": { - "objectKey": "objectValue" - }, - "exampleAttributeBoolean": false - }, - { - "id": 23, - "exampleAttributeString": "This is just an example. Please supply your own data.", - "exampleImgString": "https://placehold.co/150x150.jpg", - "exampleAttributesArray": ["Replace", "this", "data"], - "exampleAttributeNumber": 2341, - "exampleAttributeObj": { - "objectKey": "objectValue" - }, - "exampleAttributeBoolean": false - }, - { - "id": 24, - "exampleAttributeString": "This is just an example. Please supply your own data.", - "exampleImgString": "https://placehold.co/150x150.jpg", - "exampleAttributesArray": ["Replace", "this", "data"], - "exampleAttributeNumber": 2341, - "exampleAttributeObj": { - "objectKey": "objectValue" - }, - "exampleAttributeBoolean": false - }, - { - "id": 25, - "exampleAttributeString": "This is just an example. Please supply your own data.", - "exampleImgString": "https://placehold.co/150x150.jpg", - "exampleAttributesArray": ["Replace", "this", "data"], - "exampleAttributeNumber": 2341, - "exampleAttributeObj": { - "objectKey": "objectValue" - }, - "exampleAttributeBoolean": false - }, - { - "id": 26, - "exampleAttributeString": "This is just an example. Please supply your own data.", - "exampleImgString": "https://placehold.co/150x150.jpg", - "exampleAttributesArray": ["Replace", "this", "data"], - "exampleAttributeNumber": 2341, - "exampleAttributeObj": { - "objectKey": "objectValue" - }, - "exampleAttributeBoolean": false - }, - { - "id": 27, - "exampleAttributeString": "This is just an example. Please supply your own data.", - "exampleImgString": "https://placehold.co/150x150.jpg", - "exampleAttributesArray": ["Replace", "this", "data"], - "exampleAttributeNumber": 2341, - "exampleAttributeObj": { - "objectKey": "objectValue" - }, - "exampleAttributeBoolean": false - }, - { - "id": 28, - "exampleAttributeString": "This is just an example. Please supply your own data.", - "exampleImgString": "https://placehold.co/150x150.jpg", - "exampleAttributesArray": ["Replace", "this", "data"], - "exampleAttributeNumber": 2341, - "exampleAttributeObj": { - "objectKey": "objectValue" - }, - "exampleAttributeBoolean": false - }, - { - "id": 29, - "exampleAttributeString": "This is just an example. Please supply your own data.", - "exampleImgString": "https://placehold.co/150x150.jpg", - "exampleAttributesArray": ["Replace", "this", "data"], - "exampleAttributeNumber": 2341, - "exampleAttributeObj": { - "objectKey": "objectValue" - }, - "exampleAttributeBoolean": false - }, - { - "id": 30, - "exampleAttributeString": "This is just an example. Please supply your own data.", - "exampleImgString": "https://placehold.co/150x150.jpg", - "exampleAttributesArray": ["Replace", "this", "data"], - "exampleAttributeNumber": 2341, - "exampleAttributeObj": { - "objectKey": "objectValue" - }, - "exampleAttributeBoolean": false - }, - { - "id": 31, - "exampleAttributeString": "This is just an example. Please supply your own data.", - "exampleImgString": "https://placehold.co/150x150.jpg", - "exampleAttributesArray": ["Replace", "this", "data"], - "exampleAttributeNumber": 2341, - "exampleAttributeObj": { - "objectKey": "objectValue" - }, - "exampleAttributeBoolean": false - }, - { - "id": 32, - "exampleAttributeString": "This is just an example. Please supply your own data.", - "exampleImgString": "https://placehold.co/150x150.jpg", - "exampleAttributesArray": ["Replace", "this", "data"], - "exampleAttributeNumber": 2341, - "exampleAttributeObj": { - "objectKey": "objectValue" - }, - "exampleAttributeBoolean": false - }, + "age_months": 12, + "weight_kg": 2, + "total_eggs": 20, + "date": "2024-05-04", + "daily_eggs": 1 + } + ], + "products": [ { - "id": 33, - "exampleAttributeString": "This is just an example. Please supply your own data.", - "exampleImgString": "https://placehold.co/150x150.jpg", - "exampleAttributesArray": ["Replace", "this", "data"], - "exampleAttributeNumber": 2341, - "exampleAttributeObj": { - "objectKey": "objectValue" - }, - "exampleAttributeBoolean": false + "id": 1, + "name": "Cow", + "imageUrl": "https://i.pinimg.com/564x/d7/d8/3c/d7d83cf0a11793d98b5907a8afd13b21.jpg", + "description": "3 year old", + "price": 80000, + "location": "Kilifi" }, { - "id": 34, - "exampleAttributeString": "This is just an example. Please supply your own data.", - "exampleImgString": "https://placehold.co/150x150.jpg", - "exampleAttributesArray": ["Replace", "this", "data"], - "exampleAttributeNumber": 2341, - "exampleAttributeObj": { - "objectKey": "objectValue" - }, - "exampleAttributeBoolean": false + "id": 2, + "name": "Chicken", + "imageUrl": "https://i.pinimg.com/564x/30/42/f4/3042f4a966af79f8d6d5c95e59c83fc1.jpg", + "description": "6 months old", + "price": "500", + "location": "Kakamega" }, { - "id": 35, - "exampleAttributeString": "This is just an example. Please supply your own data.", - "exampleImgString": "https://placehold.co/150x150.jpg", - "exampleAttributesArray": ["Replace", "this", "data"], - "exampleAttributeNumber": 2341, - "exampleAttributeObj": { - "objectKey": "objectValue" - }, - "exampleAttributeBoolean": false + "id": 3, + "name": "tractor", + "imageUrl": "https://i.pinimg.com/564x/75/dc/2f/75dc2fbd793747d966cdbe42face51e5.jpg", + "description": "Ford Tractor", + "price": "2600000", + "location": "Kitale" }, { - "id": 36, - "exampleAttributeString": "This is just an example. Please supply your own data.", - "exampleImgString": "https://placehold.co/150x150.jpg", - "exampleAttributesArray": ["Replace", "this", "data"], - "exampleAttributeNumber": 2341, - "exampleAttributeObj": { - "objectKey": "objectValue" - }, - "exampleAttributeBoolean": false + "id": 4, + "name": "Eggs", + "imageUrl": "https://i.pinimg.com/564x/1a/fe/d7/1afed7fe5e450b06c347bfa7810b38a3.jpg", + "description": "A crate of eggs", + "price": 450, + "location": "Eldoret" }, { - "id": 37, - "exampleAttributeString": "This is just an example. Please supply your own data.", - "exampleImgString": "https://placehold.co/150x150.jpg", - "exampleAttributesArray": ["Replace", "this", "data"], - "exampleAttributeNumber": 2341, - "exampleAttributeObj": { - "objectKey": "objectValue" - }, - "exampleAttributeBoolean": false + "id": 5, + "name": "Milk", + "imageUrl": "https://i.pinimg.com/564x/5e/14/52/5e14526b4290b95c0bed550cf004d7f6.jpg", + "description": "fresh milk", + "price": "150 ", + "location": "Eldoret" }, { - "id": 38, - "exampleAttributeString": "This is just an example. Please supply your own data.", - "exampleImgString": "https://placehold.co/150x150.jpg", - "exampleAttributesArray": ["Replace", "this", "data"], - "exampleAttributeNumber": 2341, - "exampleAttributeObj": { - "objectKey": "objectValue" - }, - "exampleAttributeBoolean": false + "id": 6, + "name": "Fertilizer", + "imageUrl": "https://i.pinimg.com/564x/dd/7e/1c/dd7e1ce0e31d33adfabd66934b999cb5.jpg", + "description": "DAP Fertlizer", + "price": "3000", + "location": "Eldoret" }, { - "id": 39, - "exampleAttributeString": "This is just an example. Please supply your own data.", - "exampleImgString": "https://placehold.co/150x150.jpg", - "exampleAttributesArray": ["Replace", "this", "data"], - "exampleAttributeNumber": 2341, - "exampleAttributeObj": { - "objectKey": "objectValue" - }, - "exampleAttributeBoolean": false + "id": 7, + "name": "Maize Seed", + "imageUrl": "https://i.pinimg.com/564x/75/69/87/756987113da38d16783db702353b87b3.jpg", + "description": "A packet of maize seed", + "price": "1500", + "location": "Eldoret" }, { - "id": 40, - "exampleAttributeString": "This is just an example. Please supply your own data.", - "exampleImgString": "https://placehold.co/150x150.jpg", - "exampleAttributesArray": ["Replace", "this", "data"], - "exampleAttributeNumber": 2341, - "exampleAttributeObj": { - "objectKey": "objectValue" - }, - "exampleAttributeBoolean": false + "id": 8, + "name": "Pesticide", + "imageUrl": "https://i.pinimg.com/564x/3e/b4/5a/3eb45a8f5edc24960403124305804284.jpg", + "description": "Best pest killer", + "price": "150 ", + "location": "Eldoret" + }, + { + "name": "Goat", + "imageUrl": "https://i.pinimg.com/736x/02/06/5f/02065f4bfb7b47eedac7f3f36c5a24a9.jpg", + "description": "Fat Female", + "price": "3000", + "location": "Kiambu", + "id": 9 + }, + { + "name": "Donkey", + "imageUrl": "https://i.pinimg.com/564x/b7/5f/66/b75f669f9889e466d84f1987e4a95e38.jpg", + "description": "Hardworking Donkey", + "price": "15000", + "location": "Kisumu", + "id": 10 + }, + { + "name": "Sweet Potato", + "imageUrl": "https://i.pinimg.com/564x/b9/d6/a5/b9d6a5be42e6c4d928b3d1958ed284d0.jpg", + "description": "A bag of sweetest potatoes", + "price": "5000", + "location": "KItale", + "id": 11 + }, + { + "name": "Bananas", + "imageUrl": "https://i.pinimg.com/564x/67/1d/ed/671dedfa441e224d0fe1823e9008046c.jpg", + "description": "A stalk of bananas", + "price": "4000", + "location": "Kisii", + "id": 12 } ] -} +} \ No newline at end of file diff --git a/db/seeds.json b/db/seeds.json index 746cc522..de5ac059 100644 --- a/db/seeds.json +++ b/db/seeds.json @@ -1,444 +1,236 @@ { - "example": [ + "chickens": [ { "id": 1, - "exampleAttributeString": "This is just an example. Please supply your own data.", - "exampleImgString": "https://placehold.co/150x150.jpg", - "exampleAttributesArray": ["Replace", "this", "data"], - "exampleAttributeNumber": 2341, - "exampleAttributeObj": { - "objectKey": "objectValue" - }, - "exampleAttributeBoolean": false + "age_months": 12, + "weight_kg": 2.5, + "total_eggs": 20, + "date": "2024-05-04", + "daily_eggs": 2 }, { "id": 2, - "exampleAttributeString": "This is just an example. Please supply your own data.", - "exampleImgString": "https://placehold.co/150x150.jpg", - "exampleAttributesArray": ["Replace", "this", "data"], - "exampleAttributeNumber": 2341, - "exampleAttributeObj": { - "objectKey": "objectValue" - }, - "exampleAttributeBoolean": false + "age_months": 8, + "weight_kg": 1.8, + "total_eggs": 15, + "date": "2024-05-04", + "daily_eggs": 1 }, { "id": 3, - "exampleAttributeString": "This is just an example. Please supply your own data.", - "exampleImgString": "https://placehold.co/150x150.jpg", - "exampleAttributesArray": ["Replace", "this", "data"], - "exampleAttributeNumber": 2341, - "exampleAttributeObj": { - "objectKey": "objectValue" - }, - "exampleAttributeBoolean": false + "age_months": 10, + "weight_kg": 1.6, + "total_eggs": 18, + "date": "2024-05-04", + "daily_eggs": 3 }, { "id": 4, - "exampleAttributeString": "This is just an example. Please supply your own data.", - "exampleImgString": "https://placehold.co/150x150.jpg", - "exampleAttributesArray": ["Replace", "this", "data"], - "exampleAttributeNumber": 2341, - "exampleAttributeObj": { - "objectKey": "objectValue" - }, - "exampleAttributeBoolean": false + "age_months": 14, + "weight_kg": 2.3, + "total_eggs": 22, + "date": "2024-05-04", + "daily_eggs": 4 }, { "id": 5, - "exampleAttributeString": "This is just an example. Please supply your own data.", - "exampleImgString": "https://placehold.co/150x150.jpg", - "exampleAttributesArray": ["Replace", "this", "data"], - "exampleAttributeNumber": 2341, - "exampleAttributeObj": { - "objectKey": "objectValue" - }, - "exampleAttributeBoolean": false + "age_months": 9, + "weight_kg": 1.7, + "total_eggs": 17, + "date": "2024-05-04", + "daily_eggs": 2 }, { "id": 6, - "exampleAttributeString": "This is just an example. Please supply your own data.", - "exampleImgString": "https://placehold.co/150x150.jpg", - "exampleAttributesArray": ["Replace", "this", "data"], - "exampleAttributeNumber": 2341, - "exampleAttributeObj": { - "objectKey": "objectValue" - }, - "exampleAttributeBoolean": false + "age_months": 11, + "weight_kg": 2.0, + "total_eggs": 19, + "date": "2024-05-04", + "daily_eggs": 2 }, { "id": 7, - "exampleAttributeString": "This is just an example. Please supply your own data.", - "exampleImgString": "https://placehold.co/150x150.jpg", - "exampleAttributesArray": ["Replace", "this", "data"], - "exampleAttributeNumber": 2341, - "exampleAttributeObj": { - "objectKey": "objectValue" - }, - "exampleAttributeBoolean": false + "age_months": 13, + "weight_kg": 2.2, + "total_eggs": 21, + "date": "2024-05-04", + "daily_eggs": 3 }, { "id": 8, - "exampleAttributeString": "This is just an example. Please supply your own data.", - "exampleImgString": "https://placehold.co/150x150.jpg", - "exampleAttributesArray": ["Replace", "this", "data"], - "exampleAttributeNumber": 2341, - "exampleAttributeObj": { - "objectKey": "objectValue" - }, - "exampleAttributeBoolean": false + "age_months": 7, + "weight_kg": 1.5, + "total_eggs": 14, + "date": "2024-05-04", + "daily_eggs": 1 }, { "id": 9, - "exampleAttributeString": "This is just an example. Please supply your own data.", - "exampleImgString": "https://placehold.co/150x150.jpg", - "exampleAttributesArray": ["Replace", "this", "data"], - "exampleAttributeNumber": 2341, - "exampleAttributeObj": { - "objectKey": "objectValue" - }, - "exampleAttributeBoolean": false + "age_months": 15, + "weight_kg": 2.6, + "total_eggs": 24, + "date": "2024-05-04", + "daily_eggs": 4 }, { "id": 10, - "exampleAttributeString": "This is just an example. Please supply your own data.", - "exampleImgString": "https://placehold.co/150x150.jpg", - "exampleAttributesArray": ["Replace", "this", "data"], - "exampleAttributeNumber": 2341, - "exampleAttributeObj": { - "objectKey": "objectValue" - }, - "exampleAttributeBoolean": false + "age_months": 16, + "weight_kg": 2.8, + "total_eggs": 26, + "date": "2024-05-04", + "daily_eggs": 3 }, { "id": 11, - "exampleAttributeString": "This is just an example. Please supply your own data.", - "exampleImgString": "https://placehold.co/150x150.jpg", - "exampleAttributesArray": ["Replace", "this", "data"], - "exampleAttributeNumber": 2341, - "exampleAttributeObj": { - "objectKey": "objectValue" - }, - "exampleAttributeBoolean": false + "age_months": 11, + "weight_kg": 2.1, + "total_eggs": 20, + "date": "2024-05-04", + "daily_eggs": 2 }, { "id": 12, - "exampleAttributeString": "This is just an example. Please supply your own data.", - "exampleImgString": "https://placehold.co/150x150.jpg", - "exampleAttributesArray": ["Replace", "this", "data"], - "exampleAttributeNumber": 2341, - "exampleAttributeObj": { - "objectKey": "objectValue" - }, - "exampleAttributeBoolean": false + "age_months": 18, + "weight_kg": 3.0, + "total_eggs": 28, + "date": "2024-05-04", + "daily_eggs": 4 }, { "id": 13, - "exampleAttributeString": "This is just an example. Please supply your own data.", - "exampleImgString": "https://placehold.co/150x150.jpg", - "exampleAttributesArray": ["Replace", "this", "data"], - "exampleAttributeNumber": 2341, - "exampleAttributeObj": { - "objectKey": "objectValue" - }, - "exampleAttributeBoolean": false + "age_months": 10, + "weight_kg": 2.2, + "total_eggs": 19, + "date": "2024-05-04", + "daily_eggs": 2 }, { "id": 14, - "exampleAttributeString": "This is just an example. Please supply your own data.", - "exampleImgString": "https://placehold.co/150x150.jpg", - "exampleAttributesArray": ["Replace", "this", "data"], - "exampleAttributeNumber": 2341, - "exampleAttributeObj": { - "objectKey": "objectValue" - }, - "exampleAttributeBoolean": false + "age_months": 12, + "weight_kg": 2.3, + "total_eggs": 21, + "date": "2024-05-04", + "daily_eggs": 3 }, { "id": 15, - "exampleAttributeString": "This is just an example. Please supply your own data.", - "exampleImgString": "https://placehold.co/150x150.jpg", - "exampleAttributesArray": ["Replace", "this", "data"], - "exampleAttributeNumber": 2341, - "exampleAttributeObj": { - "objectKey": "objectValue" - }, - "exampleAttributeBoolean": false + "age_months": 14, + "weight_kg": 2.4, + "total_eggs": 23, + "date": "2024-05-04", + "daily_eggs": 3 }, { "id": 16, - "exampleAttributeString": "This is just an example. Please supply your own data.", - "exampleImgString": "https://placehold.co/150x150.jpg", - "exampleAttributesArray": ["Replace", "this", "data"], - "exampleAttributeNumber": 2341, - "exampleAttributeObj": { - "objectKey": "objectValue" - }, - "exampleAttributeBoolean": false + "age_months": 9, + "weight_kg": 1.9, + "total_eggs": 16, + "date": "2024-05-04", + "daily_eggs": 1 }, { "id": 17, - "exampleAttributeString": "This is just an example. Please supply your own data.", - "exampleImgString": "https://placehold.co/150x150.jpg", - "exampleAttributesArray": ["Replace", "this", "data"], - "exampleAttributeNumber": 2341, - "exampleAttributeObj": { - "objectKey": "objectValue" - }, - "exampleAttributeBoolean": false + "age_months": 13, + "weight_kg": 2.3, + "total_eggs": 21, + "date": "2024-05-04", + "daily_eggs": 2 }, { "id": 18, - "exampleAttributeString": "This is just an example. Please supply your own data.", - "exampleImgString": "https://placehold.co/150x150.jpg", - "exampleAttributesArray": ["Replace", "this", "data"], - "exampleAttributeNumber": 2341, - "exampleAttributeObj": { - "objectKey": "objectValue" - }, - "exampleAttributeBoolean": false + "age_months": 10, + "weight_kg": 2.1, + "total_eggs": 18, + "date": "2024-05-04", + "daily_eggs": 2 }, { "id": 19, - "exampleAttributeString": "This is just an example. Please supply your own data.", - "exampleImgString": "https://placehold.co/150x150.jpg", - "exampleAttributesArray": ["Replace", "this", "data"], - "exampleAttributeNumber": 2341, - "exampleAttributeObj": { - "objectKey": "objectValue" - }, - "exampleAttributeBoolean": false + "age_months": 11, + "weight_kg": 2.2, + "total_eggs": 19, + "date": "2024-05-04", + "daily_eggs": 3 }, { "id": 20, - "exampleAttributeString": "This is just an example. Please supply your own data.", - "exampleImgString": "https://placehold.co/150x150.jpg", - "exampleAttributesArray": ["Replace", "this", "data"], - "exampleAttributeNumber": 2341, - "exampleAttributeObj": { - "objectKey": "objectValue" - }, - "exampleAttributeBoolean": false - }, - { - "id": 21, - "exampleAttributeString": "This is just an example. Please supply your own data.", - "exampleImgString": "https://placehold.co/150x150.jpg", - "exampleAttributesArray": ["Replace", "this", "data"], - "exampleAttributeNumber": 2341, - "exampleAttributeObj": { - "objectKey": "objectValue" - }, - "exampleAttributeBoolean": false - }, - { - "id": 22, - "exampleAttributeString": "This is just an example. Please supply your own data.", - "exampleImgString": "https://placehold.co/150x150.jpg", - "exampleAttributesArray": ["Replace", "this", "data"], - "exampleAttributeNumber": 2341, - "exampleAttributeObj": { - "objectKey": "objectValue" - }, - "exampleAttributeBoolean": false - }, - { - "id": 23, - "exampleAttributeString": "This is just an example. Please supply your own data.", - "exampleImgString": "https://placehold.co/150x150.jpg", - "exampleAttributesArray": ["Replace", "this", "data"], - "exampleAttributeNumber": 2341, - "exampleAttributeObj": { - "objectKey": "objectValue" - }, - "exampleAttributeBoolean": false - }, - { - "id": 24, - "exampleAttributeString": "This is just an example. Please supply your own data.", - "exampleImgString": "https://placehold.co/150x150.jpg", - "exampleAttributesArray": ["Replace", "this", "data"], - "exampleAttributeNumber": 2341, - "exampleAttributeObj": { - "objectKey": "objectValue" - }, - "exampleAttributeBoolean": false - }, - { - "id": 25, - "exampleAttributeString": "This is just an example. Please supply your own data.", - "exampleImgString": "https://placehold.co/150x150.jpg", - "exampleAttributesArray": ["Replace", "this", "data"], - "exampleAttributeNumber": 2341, - "exampleAttributeObj": { - "objectKey": "objectValue" - }, - "exampleAttributeBoolean": false - }, - { - "id": 26, - "exampleAttributeString": "This is just an example. Please supply your own data.", - "exampleImgString": "https://placehold.co/150x150.jpg", - "exampleAttributesArray": ["Replace", "this", "data"], - "exampleAttributeNumber": 2341, - "exampleAttributeObj": { - "objectKey": "objectValue" - }, - "exampleAttributeBoolean": false - }, - { - "id": 27, - "exampleAttributeString": "This is just an example. Please supply your own data.", - "exampleImgString": "https://placehold.co/150x150.jpg", - "exampleAttributesArray": ["Replace", "this", "data"], - "exampleAttributeNumber": 2341, - "exampleAttributeObj": { - "objectKey": "objectValue" - }, - "exampleAttributeBoolean": false - }, - { - "id": 28, - "exampleAttributeString": "This is just an example. Please supply your own data.", - "exampleImgString": "https://placehold.co/150x150.jpg", - "exampleAttributesArray": ["Replace", "this", "data"], - "exampleAttributeNumber": 2341, - "exampleAttributeObj": { - "objectKey": "objectValue" - }, - "exampleAttributeBoolean": false - }, - { - "id": 29, - "exampleAttributeString": "This is just an example. Please supply your own data.", - "exampleImgString": "https://placehold.co/150x150.jpg", - "exampleAttributesArray": ["Replace", "this", "data"], - "exampleAttributeNumber": 2341, - "exampleAttributeObj": { - "objectKey": "objectValue" - }, - "exampleAttributeBoolean": false - }, - { - "id": 30, - "exampleAttributeString": "This is just an example. Please supply your own data.", - "exampleImgString": "https://placehold.co/150x150.jpg", - "exampleAttributesArray": ["Replace", "this", "data"], - "exampleAttributeNumber": 2341, - "exampleAttributeObj": { - "objectKey": "objectValue" - }, - "exampleAttributeBoolean": false - }, - { - "id": 31, - "exampleAttributeString": "This is just an example. Please supply your own data.", - "exampleImgString": "https://placehold.co/150x150.jpg", - "exampleAttributesArray": ["Replace", "this", "data"], - "exampleAttributeNumber": 2341, - "exampleAttributeObj": { - "objectKey": "objectValue" - }, - "exampleAttributeBoolean": false - }, - { - "id": 32, - "exampleAttributeString": "This is just an example. Please supply your own data.", - "exampleImgString": "https://placehold.co/150x150.jpg", - "exampleAttributesArray": ["Replace", "this", "data"], - "exampleAttributeNumber": 2341, - "exampleAttributeObj": { - "objectKey": "objectValue" - }, - "exampleAttributeBoolean": false - }, - { - "id": 33, - "exampleAttributeString": "This is just an example. Please supply your own data.", - "exampleImgString": "https://placehold.co/150x150.jpg", - "exampleAttributesArray": ["Replace", "this", "data"], - "exampleAttributeNumber": 2341, - "exampleAttributeObj": { - "objectKey": "objectValue" - }, - "exampleAttributeBoolean": false - }, - { - "id": 34, - "exampleAttributeString": "This is just an example. Please supply your own data.", - "exampleImgString": "https://placehold.co/150x150.jpg", - "exampleAttributesArray": ["Replace", "this", "data"], - "exampleAttributeNumber": 2341, - "exampleAttributeObj": { - "objectKey": "objectValue" - }, - "exampleAttributeBoolean": false - }, - { - "id": 35, - "exampleAttributeString": "This is just an example. Please supply your own data.", - "exampleImgString": "https://placehold.co/150x150.jpg", - "exampleAttributesArray": ["Replace", "this", "data"], - "exampleAttributeNumber": 2341, - "exampleAttributeObj": { - "objectKey": "objectValue" - }, - "exampleAttributeBoolean": false - }, - { - "id": 36, - "exampleAttributeString": "This is just an example. Please supply your own data.", - "exampleImgString": "https://placehold.co/150x150.jpg", - "exampleAttributesArray": ["Replace", "this", "data"], - "exampleAttributeNumber": 2341, - "exampleAttributeObj": { - "objectKey": "objectValue" - }, - "exampleAttributeBoolean": false - }, - { - "id": 37, - "exampleAttributeString": "This is just an example. Please supply your own data.", - "exampleImgString": "https://placehold.co/150x150.jpg", - "exampleAttributesArray": ["Replace", "this", "data"], - "exampleAttributeNumber": 2341, - "exampleAttributeObj": { - "objectKey": "objectValue" - }, - "exampleAttributeBoolean": false - }, - { - "id": 38, - "exampleAttributeString": "This is just an example. Please supply your own data.", - "exampleImgString": "https://placehold.co/150x150.jpg", - "exampleAttributesArray": ["Replace", "this", "data"], - "exampleAttributeNumber": 2341, - "exampleAttributeObj": { - "objectKey": "objectValue" - }, - "exampleAttributeBoolean": false - }, - { - "id": 39, - "exampleAttributeString": "This is just an example. Please supply your own data.", - "exampleImgString": "https://placehold.co/150x150.jpg", - "exampleAttributesArray": ["Replace", "this", "data"], - "exampleAttributeNumber": 2341, - "exampleAttributeObj": { - "objectKey": "objectValue" - }, - "exampleAttributeBoolean": false - }, - { - "id": 40, - "exampleAttributeString": "This is just an example. Please supply your own data.", - "exampleImgString": "https://placehold.co/150x150.jpg", - "exampleAttributesArray": ["Replace", "this", "data"], - "exampleAttributeNumber": 2341, - "exampleAttributeObj": { - "objectKey": "objectValue" - }, - "exampleAttributeBoolean": false + "age_months": 12, + "weight_kg": 2.0, + "total_eggs": 20, + "date": "2024-05-04", + "daily_eggs": 1 } - ] + ], + "products": [ + { + "id": 1, + "name": "Cow", + "imageUrl": "https://i.pinimg.com/564x/d7/d8/3c/d7d83cf0a11793d98b5907a8afd13b21.jpg", + "description": "3 year old", + "price": 80000, + "location": "Kilifi" + }, + { + "id": 2, + "name": "Chicken", + "imageUrl": "https://i.pinimg.com/564x/30/42/f4/3042f4a966af79f8d6d5c95e59c83fc1.jpg", + "description": "6 months old", + "price": "500", + "location": "Kakamega" + }, + { + "id": 3, + "name": "tractor", + "imageUrl": "https://i.pinimg.com/564x/75/dc/2f/75dc2fbd793747d966cdbe42face51e5.jpg", + "description": "Ford Tractor", + "price": "2600000", + "location": "Kitale" + }, + { + "id": 4, + "name": "Eggs", + "imageUrl": "https://i.pinimg.com/564x/1a/fe/d7/1afed7fe5e450b06c347bfa7810b38a3.jpg", + "description": "A crate of eggs", + "price": 450, + "location": "Eldoret" + + }, + { + "id": 5, + "name": "Milk", + "imageUrl": "https://i.pinimg.com/564x/5e/14/52/5e14526b4290b95c0bed550cf004d7f6.jpg", + "description": "fresh milk", + "price": "150 ", + "location": "Eldoret" + + }, + { + "id": 6, + "name": "Fertilizer", + "imageUrl": "https://i.pinimg.com/564x/dd/7e/1c/dd7e1ce0e31d33adfabd66934b999cb5.jpg", + "description": "DAP Fertlizer", + "price": "3000", + "location": "Eldoret" + + }, + { + "id": 7, + "name": "Maize Seed", + "imageUrl": "https://i.pinimg.com/564x/75/69/87/756987113da38d16783db702353b87b3.jpg", + "description": "A packet of maize seed", + "price": "1500", + "location": "Eldoret" + + }, + + { + "id": 8, + "name": "Pesticide", + "imageUrl": "https://i.pinimg.com/564x/3e/b4/5a/3eb45a8f5edc24960403124305804284.jpg", + "description": "Best pest killer", + "price": "150 ", + "location": "Eldoret" + + } + ] } diff --git a/package-lock.json b/package-lock.json index 68b763ec..058d35d1 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,11 +1,12 @@ { "name": "json-server-template", - "version": "1.0.0", + "version": "0.1.0", "lockfileVersion": 2, "requires": true, "packages": { "": { - "version": "1.0.0", + "name": "json-server-template", + "version": "0.1.0", "license": "ISC", "dependencies": { "cors": "^2.8.5", diff --git a/public/index.html b/public/index.html new file mode 100644 index 00000000..5c570ff1 --- /dev/null +++ b/public/index.html @@ -0,0 +1,56 @@ + + + + + + Chicken Server Main Page + + + +

Welcome to the FarmFolio Server

+ +

Endpoints:

+

This server provides access to FarmFolio data through the following endpoints:

+ + +