Install Dependencies using go get
:
$ go get
Then run the API on Port:8080 :
$ go run .
- These libraries are the most important that allowed me to build this project.
- Gin library which was very helpful for HTTP request routing.
- jwt-go for Auth tokens in requests to verify users.
- bcrypt for encrypting and decrypting passwords stored in the SQL DataBase.
- And go-sqlite3 for running the SQL server.
- Description: Get a list of available events
- Example Request:
GET http://localhost:8080/events
- Example Response:
[ { "ID": 1, "Name": "Test event", "Description": "Test event!!!", "Location": "A test location", "DateTime": "2025-01-01T15:30:00Z", "UserID": 1 }, { "ID": 2, "Name": "Second Test event", "Description": "A Second Test event!!!", "Location": "Another test location", "DateTime": "2025-02-01T15:30:00Z", "UserID": 1 } ]
- Description: Get an event by specific ID
- Example Request:
GET http://localhost:8080/events/21
- Example Response:
{ "ID": 1, "Name": "Test event", "Description": "Test event!!!", "Location": "A test location", "DateTime": "2025-01-01T15:30:00Z", "UserID": 1 }
- Description: Create bookable event
- (Auth Required)
- Example Request:
POST http://localhost:8080/events content-type: application/json authorization: <JWT TOKEN> { "name": "Test event", "description": "Test event!!!", "location": "A test location", "dateTime": "2025-01-01T15:30:00.000Z" }
- Example Response:
{ "event": { "ID": 1, "Name": "Test event", "Description": "Test event!!!", "Location": "A test location", "DateTime": "2025-01-01T15:30:00Z", "UserID": 1 }, "message": "Event created!" }
- Example Request:
- Description: Create a new user
- Example Request:
POST http://localhost:8080/signup content-type: application/json { "email": "[email protected]", "password": "test" }
- Example Response:
{"message":"User created successfully"}
- Description: Sign in and Authenticate user
- (Returns Auth Token)
- Example Request:
POST http://localhost:8080/login content-type: application/json { "email": "[email protected]", "password": "test" }
- Example Response:
{ "message": "Login successful!", "token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJlbWFpbCI6InRlc3QyQGV4YW1wbGUuY29tIiwiZXhwIjoxNzA2NTcyMjQzLCJ1c2VySWQiOjF9.RYcqW9laXx91E-0JNqPtyngLdYK3P9O8CvC7YgqrSVk" }
- Example Request:
- Description: Register the user for an Event
- (Auth Required)
- Example Request:
POST http://localhost:8080/events/21/register authorization: <JWT TOKEN>
- Example Response:
{ "message": "Registered!" }
- Example Request:
- Description: Update an existing Event
- (Auth Required) (Only by Creator)
- Example Request:
PUT http://localhost:8080/events/21 content-type: application/json authorization: <JWT TOKEN> { "name": "Updated test event", "description": "A test event", "location": "Test location (Updated!)", "dateTime": "2025-01-01T15:30:00Z" }
- Example Response:
{ "message": "Event updated successfully!" }
- Example Request:
- Description: Delete an Event by ID
- (Auth Required) (Only by Creator)
- Example Request:
DELETE http://localhost:8080/events/21 authorization: <JWT TOKEN>
- Example Response:
{ "message": "Event deleted successfully!" }
- Example Request:
- Description: Delete a registration for an Event
- (Auth Required)
- Example Request:
DELETE http://localhost:8080/events/21/register authorization: <JWT TOKEN>
- Example Response:
{ "message": "Cancelled!" }
- Example Request: