-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
35 lines (30 loc) · 1.38 KB
/
main.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
package main
import (
"github.com/cemalunal/sample-internship-management-api/api"
"github.com/cemalunal/sample-internship-management-api/db"
_assigneeRepository "github.com/cemalunal/sample-internship-management-api/repository"
_candidateRepository "github.com/cemalunal/sample-internship-management-api/repository"
_assigneeService "github.com/cemalunal/sample-internship-management-api/service"
_candidateService "github.com/cemalunal/sample-internship-management-api/service"
"github.com/gorilla/mux"
"log"
"os"
)
func main() {
log.SetFlags(log.LstdFlags | log.Lshortfile)
mongodbUri := os.Getenv("MONGODB_URI")
if mongodbUri == "" {
log.Println("MONGODB_URI is not set, using default connection string mongodb://localhost:27017")
mongodbUri = "mongodb://localhost:27017"
}
client := db.Connect(mongodbUri)
database := client.Database("Company")
assigneesCollection := database.Collection("Assignees")
candidatesCollection := database.Collection("Candidates")
assigneeRepository := _assigneeRepository.MongoDBAssigneeRepository(assigneesCollection)
candidateRepository := _candidateRepository.MongoDBCandidateRepository(candidatesCollection)
assigneeService := _assigneeService.AssigneeService(assigneeRepository)
candidateService := _candidateService.CandidateService(candidateRepository, assigneeRepository)
r := mux.NewRouter()
api.Api(r, assigneeService, candidateService)
}