Giter VIP home page Giter VIP logo

go-events-api's Introduction

Events Rest-API

Quick Start

Install Dependencies using go get:

$ go get

Then run the API on Port:8080 :

$ go run .

API Details

  • 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.

API Routes

GET Requests

- /api/events

  • 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
    }
    ]

- /api/events/<id>

  • 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
    }

POST Requests

- /api/events

  • 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!"
      }

- /api/signup

  • 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"}

- /api/login

  • 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"
      }

- /api/events/<id>/register

  • 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!"
      }

PUT Requests

- /api/events/<id>

  • 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!"
      }

DELETE Requests

- /api/events/<id>

  • 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!"
      }

- /api/events/<id>/register

  • 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!"
      }

go-events-api's People

Contributors

gnarlylasagna avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.