Skip to content
This repository was archived by the owner on Dec 7, 2023. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ This `Admin` JWT should be passed as the `Authorization` header when making a re
There are a couple other useful but not necessary tools for working on the API. The first is a GUI tool for viewing and modifying the database. There are many options including [MongoDB Compass](https://www.mongodb.com/products/compass) and [Robo 3T](https://robomongo.org/). You will also want to install [Postman](https://www.getpostman.com/) for making requests to the API when testing.

## Building, Testing, and Running the API
In order to simply API development `make` is used for building, testing, and running the API. All `make` commands can be run from the root of the repository and they will properly find and operate on all of the services.
In order to simplify API development `make` is used for building, testing, and running the API. All `make` commands can be run from the root of the repository and they will properly find and operate on all of the services.

### Building the API
Run the following command from the root of the repository. The gateway and all services will be built into `bin`.
Expand Down
6 changes: 6 additions & 0 deletions config/dev_config.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
"STAT_SERVICE": "http://localhost:8011",
"NOTIFICATIONS_SERVICE": "http://localhost:8012",
"PROJECT_SERVICE": "http://localhost:8013",
"RECOGNITION_SERVICE": "http://localhost:8014",

"GATEWAY_PORT": "8000",
"AUTH_PORT": ":8002",
Expand All @@ -25,6 +26,8 @@
"STAT_PORT": ":8011",
"NOTIFICATIONS_PORT": ":8012",
"PROJECT_PORT": ":8013",
"RECOGNITION_PORT": ":8014",


"AUTH_DB_HOST": "localhost",
"USER_DB_HOST": "localhost",
Expand All @@ -38,6 +41,8 @@
"STAT_DB_HOST": "localhost",
"NOTIFICATIONS_DB_HOST": "localhost",
"PROJECT_DB_HOST": "localhost",
"RECOGNITION_DB_HOST": "localhost",


"AUTH_DB_NAME": "auth",
"USER_DB_NAME": "user",
Expand All @@ -51,6 +56,7 @@
"STAT_DB_NAME": "stat",
"NOTIFICATIONS_DB_NAME": "notifications",
"PROJECT_DB_NAME": "project",
"RECOGNITION_DB_NAME": "recognition",

"S3_REGION": "us-east-1",
"S3_BUCKET": "hackillinois-upload-2019",
Expand Down
4 changes: 4 additions & 0 deletions config/test_config.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
"STAT_SERVICE": "http://localhost:8011",
"NOTIFICATIONS_SERVICE": "http://localhost:8012",
"PROJECT_SERVICE": "http://localhost:8013",
"RECOGNITION_SERVICE": "http://localhost:8014",

"GATEWAY_PORT": "8000",
"AUTH_PORT": ":8002",
Expand All @@ -25,6 +26,7 @@
"STAT_PORT": ":8011",
"NOTIFICATIONS_PORT": ":8012",
"PROJECT_PORT": ":8013",
"RECOGNITION_PORT": ":8014",

"AUTH_DB_HOST": "localhost",
"USER_DB_HOST": "localhost",
Expand All @@ -38,6 +40,7 @@
"STAT_DB_HOST": "localhost",
"NOTIFICATIONS_DB_HOST": "localhost",
"PROJECT_DB_HOST": "localhost",
"RECOGNITION_DB_HOST": "localhost",

"AUTH_DB_NAME": "test-auth",
"USER_DB_NAME": "test-user",
Expand All @@ -51,6 +54,7 @@
"STAT_DB_NAME": "test-stat",
"NOTIFICATIONS_DB_NAME": "test-notifications",
"PROJECT_DB_NAME": "test-project",
"RECOGNITION_DB_NAME": "recognition",

"S3_REGION": "us-east-1",
"S3_BUCKET": "hackillinois-upload-2019",
Expand Down
1 change: 1 addition & 0 deletions container/env.template
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ MAIL_DB_HOST=
EVENT_DB_HOST=
STAT_DB_HOST=
NOTIFICATIONS_DB_HOST=
RECOGNITION_DB_HOST=

# Set the oauth client id and secret for your GitHub, Google, and Linkedin applications
GITHUB_CLIENT_ID=
Expand Down
139 changes: 139 additions & 0 deletions documentation/docs/reference/services/Recognition.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,139 @@
Recognition
=====


GET /recognition/
---------------------

Returns a list of all recognitions.

Response format:
```
{
"recognitions": [
{
"id": "81855ad8681d0d86d1e91e00167939cb",
"name": "Example Recognition 10",
"description": "This is a description",
"presenter": "Example presenter",
"recognitionId": "81855ad8681d0d86d1e91e00167939cb",
"recipients": [
{
"type": "PROJECT",
"typeId": "52fdfc072182654f163f5f0f9a621d72"
}
],
"tags": [
"Data Science",
"Mobile"
]
},
{
"id": "9566c74d10037c4d7bbb0407d1e2c649",
"name": "Best Computer Security",
"description": "Good mastery of safe coding practices",
"presenter": "HackIllinois",
"recognitionId": "52fdfc072182654f163f5f0f9a621d72",
"recipients": [
{
"type": "INDIVIDUAL",
"typeId": "github09829234"
}
],
"tags": [
"Security",
"Virus"
]
}
]
}
```

POST /recognition/
-----------

Creates an recognition with the requested fields. Returns the created recognition.

Request format:
```
{
"name": "Example Recognition 10",
"description": "This is a description",
"presenter": "Example presenter",
"recognitionId": "81855ad8681d0d86d1e91e00167939cb",
"tags": ["Data Science", "Mobile"],
"recipients": [
{
"type": "ALL"
}
]
}
```

Response format:
```
{
"name": "Example Recognition 10",
"description": "This is a description",
"presenter": "Example presenter",
"recognitionId": "81855ad8681d0d86d1e91e00167939cb",
"tags": ["Data Science", "Mobile"],
"recipients": [
{
"type": "ALL"
}
]
}
```

DELETE /recognition/RECOGNITIONID/
-----------

Endpoint to delete an recognition with name `RECOGNITIONID`

Response format:
```
{
"name": "Example Recognition 10",
"description": "This is a description",
"presenter": "Example presenter",
"recognitionId": "81855ad8681d0d86d1e91e00167939cb",
"tags": ["Data Science", "Mobile"],
"recipients": [
{
"type": "ALL"
}
]
}
```


GET /recognition/filter/?key=value
---------------------

Returns all recognitions, filtered with the given key-value pairs.

Response format:
```
{
"recognitions": [
{
"id": "81855ad8681d0d86d1e91e00167939cb",
"name": "Example Recognition 10",
"description": "This is a description",
"presenter": "Example presenter",
"recognitionId": "81855ad8681d0d86d1e91e00167939cb",
"recipients": [
{
"type": "PROJECT",
"typeId": "52fdfc072182654f163f5f0f9a621d72"
}
],
"tags": [
"Data Science",
"Mobile"
]
}
]
}
```
8 changes: 8 additions & 0 deletions gateway/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ var EVENT_SERVICE string
var STAT_SERVICE string
var NOTIFICATIONS_SERVICE string
var PROJECT_SERVICE string
var RECOGNITION_SERVICE string


func Initialize() error {

Expand Down Expand Up @@ -111,6 +113,12 @@ func Initialize() error {
return err
}

RECOGNITION_SERVICE, err = cfg_loader.Get("RECOGNITION_SERVICE")

if err != nil {
return err
}

port_str, err := cfg_loader.Get("GATEWAY_PORT")

if err != nil {
Expand Down
36 changes: 36 additions & 0 deletions gateway/services/recognition.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
package services

import (
"net/http"

"github.com/HackIllinois/api/gateway/config"
"github.com/HackIllinois/api/gateway/middleware"
"github.com/HackIllinois/api/gateway/models"
"github.com/arbor-dev/arbor"
"github.com/justinas/alice"
)

const RecognitionFormat string = "JSON"

var RecognitionRoutes = arbor.RouteCollection{
arbor.Route{
"GetAllRecognitions",
"GET",
"/recognition/",
alice.New(middleware.IdentificationMiddleware).ThenFunc(GetRecognition).ServeHTTP,
},
arbor.Route{
"CreateRecognition",
"POST",
"/recognition/",
alice.New(middleware.AuthMiddleware([]models.Role{models.AdminRole}), middleware.IdentificationMiddleware).ThenFunc(CreateRecognition).ServeHTTP,
},
}

func GetRecognition(w http.ResponseWriter, r *http.Request) {
arbor.GET(w, config.RECOGNITION_SERVICE+r.URL.String(), RecognitionFormat, "", r)
}

func CreateRecognition(w http.ResponseWriter, r *http.Request) {
arbor.POST(w, config.RECOGNITION_SERVICE+r.URL.String(), RecognitionFormat, "", r)
}
2 changes: 2 additions & 0 deletions gateway/services/services.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ func Initialize() error {
"stat": config.STAT_SERVICE,
"notifications": config.NOTIFICATIONS_SERVICE,
"project": config.PROJECT_SERVICE,
"recognition": config.RECOGNITION_SERVICE,
}

return nil
Expand Down Expand Up @@ -65,6 +66,7 @@ func RegisterAPIs() arbor.RouteCollection {
Routes = append(Routes, StatRoutes...)
Routes = append(Routes, NotificationsRoutes...)
Routes = append(Routes, ProjectRoutes...)
Routes = append(Routes, RecognitionRoutes...)
Routes = append(Routes, HealthRoutes...)
Routes = append(Routes, ReloadRoutes...)
return Routes
Expand Down
Empty file removed log/access.log
Empty file.
2 changes: 2 additions & 0 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import (
"github.com/HackIllinois/api/services/stat"
"github.com/HackIllinois/api/services/upload"
"github.com/HackIllinois/api/services/user"
"github.com/HackIllinois/api/services/recognition"
)

var SERVICE_ENTRYPOINTS = map[string](func()){
Expand All @@ -34,6 +35,7 @@ var SERVICE_ENTRYPOINTS = map[string](func()){
"stat": stat.Entry,
"notifications": notifications.Entry,
"project": project.Entry,
"recognition": recognition.Entry,
}

func StartAll() {
Expand Down
1 change: 1 addition & 0 deletions scripts/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ $REPO_ROOT/bin/hackillinois-api --service event &
$REPO_ROOT/bin/hackillinois-api --service stat &
$REPO_ROOT/bin/hackillinois-api --service notifications &
$REPO_ROOT/bin/hackillinois-api --service project &
$REPO_ROOT/bin/hackillinois-api --service recognition &

$REPO_ROOT/bin/hackillinois-api --service gateway &

Expand Down
41 changes: 41 additions & 0 deletions services/recognition/config/config.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
package config

import (
"os"

"github.com/HackIllinois/api/common/configloader"
)

var RECOGNITION_DB_HOST string
var RECOGNITION_DB_NAME string

var RECOGNITION_PORT string


func Initialize() error {
cfg_loader, err := configloader.Load(os.Getenv("HI_CONFIG"))

if err != nil {
return err
}

RECOGNITION_DB_HOST, err = cfg_loader.Get("RECOGNITION_DB_HOST")

if err != nil {
return err
}

RECOGNITION_DB_NAME, err = cfg_loader.Get("RECOGNITION_DB_NAME")

if err != nil {
return err
}

RECOGNITION_PORT, err = cfg_loader.Get("RECOGNITION_PORT")

if err != nil {
return err
}

return nil
}
Loading