- Launch Mysql workbench
- Logon with default root account on default port 3306
- Run the following sql statement to create a schema named
your_db
CREATE SCHEMA IF NOT EXISTS your_db;
- Go to Server > Data Import. Import sql dumps located in:
...<ProjectRootFolder>/your_db
- if steps 4 failed, manually run the following sql script
Use your_db;
CREATE TABLE `pickups` (
`id` varchar(40) NOT NULL,
`coord` point NOT NULL,
`address` varchar(150) NOT NULL,
`created_by` varchar(40) NOT NULL,
`attend_by` varchar(40) NOT NULL DEFAULT '',
`completed` tinyint NOT NULL DEFAULT '0',
PRIMARY KEY (`id`),
UNIQUE KEY `idrecycle_UNIQUE` (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci
- Create a recyle table
CREATE TABLE `recyclebinsdetails` (
`ID` int NOT NULL AUTO_INCREMENT,
`BinID` varchar(10) DEFAULT NULL,
`BinType` varchar(10) DEFAULT NULL,
`BinLocationLat` double DEFAULT NULL,
`BinLocationLong` double DEFAULT NULL,
`BinAddress` varchar(60) DEFAULT NULL,
`Postcode` varchar(10) DEFAULT NULL,
`UserID` varchar(30) DEFAULT NULL,
`FBOptions` varchar(20) DEFAULT NULL,
`ColorCode` varchar(20) DEFAULT NULL,
`Remarks` varchar(150) DEFAULT NULL,
`BinStatusUpdate` varchar(20) DEFAULT NULL,
PRIMARY KEY (`ID`)
) ENGINE=InnoDB AUTO_INCREMENT=13 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci
- Create a
user1
in mysql workbench and grant all privilege toyour_db
The connection goes like this:
sql.Open("mysql", "user1:password@tcp(127.0.0.1:3306)/your_db")
- Clone repo (or unzip if you are downloading via zip file)
git clone https://github.com/heartziq/recycle-lah.git
- Go into the root of the project folder, create a folder named
cert
insideserver/
. Generate own secret keys and server certificate
cd recycle-lah
mkdir server/cert
./runthis.sh
- Verify all dependencies are install
go mod tidy
- Run server
cd server
go run server.go
- Use your favourite client (Postman recommended)
| Endpoints | Features | Sample payload (JSON) |
| ------------------------------------------------------------ | ------------------------------------------ | ------------------------------------------------------------ |
| PUT
https://localhost:5000/api/v1/pickups/<Pickup_ID>?key=secretkey&role=user
| User Approve a pickup | | | DELETEhttps://localhost:5000/api/v1/pickups/<Pickup_ID>?key=secretkey&role=user
| User cancels a pickup | | | GEThttps://localhost:5000/api/v1/pickups/3?key=secretkey&role=user
| Show this user's pickup requests | | | GEThttps://localhost:5000/api/v1/pickups
| Show all available pickups | | | PUThttps://localhost:5000/api/v1/pickups/3?key=secretkey&role=collector
| collector accepts/cancel a pickup | {"pickup_id": "0487d326-9947-4d00-b3b6-a576cdafc506", "collector_id": ""} | | GEThttps://localhost:5000/api/v1/pickups/3?key=secretkey&role=collector
| collector view currently attending pickups | | | POSThttps://localhost:5000/api/v1/pickups/3?key=secretkey&role=user
| user request for a pickup | {"lat": 1.2411412, "lng": 102.78319552131565, "address": "Thor's avenue St 32, Milwaukee TN", "created_by": "14222"} |
- Launch a new terminal (from the root project folder)
- Go to
server/v2
cd server/v2/server
go run main.go
- curl (or postman)
curl http://localhost:8090/api/v2/pickups