Skip to content

Commit

Permalink
refactor: removed unused code (apache#6243)
Browse files Browse the repository at this point in the history
  • Loading branch information
klesh committed Oct 13, 2023
1 parent 9279092 commit 62f71ad
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 12 deletions.
13 changes: 4 additions & 9 deletions backend/server/api/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,26 +56,21 @@ Alternatively, you may downgrade back to the previous DevLake version.
// @license.name Apache-2.0
// @host localhost:8080
// @BasePath /
func CreateApiService() {
func CreateApiService(router *gin.Engine) {
// Get configuration
v := config.GetConfig()
// Initialize services
services.Init()
// Set gin mode
gin.SetMode(v.GetString("MODE"))
// Create a gin router
router := gin.Default()
if router == nil {
router = gin.Default()
}

// For both protected and unprotected routes
router.GET("/ping", ping.Get)
router.GET("/version", version.Get)
router.GET("/userinfo", func(ctx *gin.Context) {
shared.ApiOutputSuccess(ctx, gin.H{
"user": ctx.Request.Header.Get("X-Forwarded-User"),
"email": ctx.Request.Header.Get("X-Forwarded-Email"),
"logoutURI": config.GetConfig().GetString("LOGOUT_URI"),
}, http.StatusOK)
})

// Endpoint to proceed database migration
router.GET("/proceed-db-migration", func(ctx *gin.Context) {
Expand Down
2 changes: 1 addition & 1 deletion backend/server/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,5 +30,5 @@ func main() {
if encryptionSecret == "" {
panic("ENCRYPTION_SECRET must be set in environment variable or .env file")
}
api.CreateApiService()
api.CreateApiService(nil)
}
2 changes: 1 addition & 1 deletion backend/server/services/remote/plugin/plugin_impl.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ func newPlugin(info *models.PluginInfo, invoker bridge.Invoker) (*remotePluginIm
}
openApiSpec, err := doc.GenerateOpenApiSpec(info)
if err != nil {
return nil, errors.Default.Wrap(err, fmt.Sprintf("Couldn't generate OpenAPI spec for plugin %s", info.Name))
panic(err)
}
scripts := make([]plugin.MigrationScript, 0)
for _, script := range info.MigrationScripts {
Expand Down
2 changes: 1 addition & 1 deletion backend/test/helper/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ func ConnectLocalServer(t *testing.T, clientConfig *LocalClientConfig) *DevlakeC
cfg.Set("PLUGIN_DIR", throwawayDir)
cfg.Set("LOGGING_DIR", throwawayDir)
go func() {
initService.Do(api.CreateApiService)
initService.Do(func() { api.CreateApiService(nil) })
}()
req, err2 := http.NewRequest(http.MethodGet, fmt.Sprintf("%s/proceed-db-migration", addr), nil)
require.NoError(t, err2)
Expand Down

0 comments on commit 62f71ad

Please sign in to comment.