first commit
This commit is contained in:
		
							
								
								
									
										45
									
								
								cmd/main.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										45
									
								
								cmd/main.go
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,45 @@
 | 
			
		||||
package main
 | 
			
		||||
 | 
			
		||||
import (
 | 
			
		||||
	configs "learnsteam/cslms-api/configs"
 | 
			
		||||
	_ "learnsteam/cslms-api/docs"
 | 
			
		||||
	"learnsteam/cslms-api/internal/database"
 | 
			
		||||
	"learnsteam/cslms-api/internal/helpers"
 | 
			
		||||
	"learnsteam/cslms-api/internal/routers"
 | 
			
		||||
 | 
			
		||||
	"log"
 | 
			
		||||
	"net/http"
 | 
			
		||||
 | 
			
		||||
	"github.com/apex/gateway"
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
// @title Learnsteam CodingSchool API
 | 
			
		||||
// @version 1.0
 | 
			
		||||
// @description Learnsteam CodingSchool API
 | 
			
		||||
 | 
			
		||||
// @contact.name Jay Sheen
 | 
			
		||||
// @contact.email sheen@jongyeob.com
 | 
			
		||||
 | 
			
		||||
// @securityDefinitions.apikey Bearer
 | 
			
		||||
// @in header
 | 
			
		||||
// @name Authorization
 | 
			
		||||
 | 
			
		||||
func main() {
 | 
			
		||||
	Init()
 | 
			
		||||
	Run()
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func Init() {
 | 
			
		||||
	database.Init()
 | 
			
		||||
	routers.Init()
 | 
			
		||||
 | 
			
		||||
	database.AutoMigrate()
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func Run() {
 | 
			
		||||
	if helpers.InLambda() {
 | 
			
		||||
		log.Fatal(gateway.ListenAndServe(configs.PORT, routers.Router))
 | 
			
		||||
	} else {
 | 
			
		||||
		log.Fatal(http.ListenAndServe(configs.PORT, routers.Router))
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
		Reference in New Issue
	
	Block a user