This repository contains a Go-based REST API server application that uses the GORM library to interact with a MySQL database and Google's OAuth 2.0 for authentication. The application also has a client part, together with which they form a service for searching and placing profiles for joint work on university projects.
Before running this application, ensure that you have the following prerequisites installed on your system:
- Go (version 1.16 or higher)
- MySQL database
- Google OAuth credentials
-
Clone this repository to your local machine:
git clone https://github.com/horoshi10v/apiKurator.git
-
Change into the project directory:
cd apiKurator
-
Install the necessary dependencies using the following command:
go mod download
-
Set up the config by updating .env-file:
GOOGLE_CLIENT_ID = your client ID GOOGLE_CLIENT_SECRET = your client secret SECRET_KEY = your string SERVER_PORT = :8080 CLIENT_PORT = http://localhost:3000 DATABASE_CONFIG = USER:PASSWORD@/DB_NAME?&parseTime=True
-
Start the application by running the following command:
go run main.go
-
The API server will be up and running on
http://localhost:8080
.
The following API endpoints are available:
- POST
/google/login
: Initiates the Google OAuth login process. - GET
/google/callback
: Callback endpoint for handling the OAuth authorization code. - GET
/google/logout
: Revokes the Google OAuth access token and logs out the user. - GET
/user
: Retrieves a page of the authorized user. - GET
/users
: Retrieves a list of all users. - GET
/users/{id}
: Retrieves a user by ID. - PUT
/users/{id}
: Updates a user by ID. - DELETE
/users/{id}
: Deletes a user by ID. - POST
/addUser
: Creates a new user.
The following libraries were used in this project:
- Fiber: HTTP web framework
- GORM: ORM library for interacting with the database
- MySQL: MySQL driver for Go
- Google OAuth: Google OAuth client library for Go
Contributions are welcome! If you find any issues or have suggestions for improvements, please feel free to open an issue or submit a pull request.
This project is licensed under the MIT License.