fix linter warnings

one method to add handlers
This commit is contained in:
lukas 2021-09-21 10:45:52 +02:00
parent b10fbd6142
commit 334c54be4a
11 changed files with 37 additions and 20 deletions

View File

@ -97,6 +97,7 @@ module.exports = {
rules: { rules: {
"@typescript-eslint/no-explicit-any": "error", "@typescript-eslint/no-explicit-any": "error",
"@typescript-eslint/explicit-function-return-type": "error", "@typescript-eslint/explicit-function-return-type": "error",
"@typescript-eslint/no-shadow": "warn",
// General // General
'comma-dangle': [1, 'never'], // allow or disallow trailing commas 'comma-dangle': [1, 'never'], // allow or disallow trailing commas
@ -182,7 +183,7 @@ module.exports = {
'no-catch-shadow': 1, // disallow the catch clause parameter name being the same as a variable in the outer scope (off by default in the node environment) 'no-catch-shadow': 1, // disallow the catch clause parameter name being the same as a variable in the outer scope (off by default in the node environment)
'no-delete-var': 1, // disallow deletion of variables 'no-delete-var': 1, // disallow deletion of variables
'no-label-var': 1, // disallow labels that share a name with a variable 'no-label-var': 1, // disallow labels that share a name with a variable
'no-shadow': 1, // disallow declaration of variables already declared in the outer scope // 'no-shadow': 1, // disallow declaration of variables already declared in the outer scope
'no-shadow-restricted-names': 1, // disallow shadowing of names such as arguments 'no-shadow-restricted-names': 1, // disallow shadowing of names such as arguments
'no-undef': 2, // disallow use of undeclared variables unless mentioned in a /*global */ block 'no-undef': 2, // disallow use of undeclared variables unless mentioned in a /*global */ block
'no-undefined': 0, // disallow use of undefined variable (off by default) 'no-undefined': 0, // disallow use of undefined variable (off by default)

9
apiGo/api/API.go Normal file
View File

@ -0,0 +1,9 @@
package api
func AddHandlers() {
addVideoHandlers()
addSettingsHandlers()
addTagHandlers()
addActorsHandlers()
addTvshowHandlers()
}

View File

@ -7,7 +7,7 @@ import (
"openmediacenter/apiGo/database" "openmediacenter/apiGo/database"
) )
func AddActorsHandlers() { func addActorsHandlers() {
saveActorsToDB() saveActorsToDB()
getActorsFromDB() getActorsFromDB()
} }

View File

@ -11,7 +11,7 @@ import (
"strings" "strings"
) )
func AddSettingsHandlers() { func addSettingsHandlers() {
saveSettingsToDB() saveSettingsToDB()
getSettingsFromDB() getSettingsFromDB()
reIndexHandling() reIndexHandling()

View File

@ -7,7 +7,7 @@ import (
"openmediacenter/apiGo/database" "openmediacenter/apiGo/database"
) )
func AddTvshowHandlers() { func addTvshowHandlers() {
// do not add handlers if tvshows not enabled // do not add handlers if tvshows not enabled
if config.GetConfig().Features.DisableTVSupport { if config.GetConfig().Features.DisableTVSupport {
return return

View File

@ -7,7 +7,7 @@ import (
"regexp" "regexp"
) )
func AddTagHandlers() { func addTagHandlers() {
getFromDB() getFromDB()
addToDB() addToDB()
deleteFromDB() deleteFromDB()

View File

@ -11,7 +11,7 @@ import (
"strconv" "strconv"
) )
func AddVideoHandlers() { func addVideoHandlers() {
getVideoHandlers() getVideoHandlers()
loadVideosHandlers() loadVideosHandlers()
addToVideoHandlers() addToVideoHandlers()

View File

@ -55,7 +55,10 @@ func callHandler(ctx *apicontext, handler func(ctx Context), writer http.Respons
} }
} }
func ServerInit() { func ServerInit(port uint16) error {
// initialize auth service and add corresponding auth routes // initialize auth service and add corresponding auth routes
InitOAuth() InitOAuth()
fmt.Printf("OpenMediacenter server up and running on port %d\n", port)
return http.ListenAndServe(fmt.Sprintf(":%d", port), nil)
} }

View File

@ -2,19 +2,19 @@ package main
import ( import (
"fmt" "fmt"
"log"
"net/http"
"openmediacenter/apiGo/api" "openmediacenter/apiGo/api"
api2 "openmediacenter/apiGo/api/api" api2 "openmediacenter/apiGo/api/api"
"openmediacenter/apiGo/config" "openmediacenter/apiGo/config"
"openmediacenter/apiGo/database" "openmediacenter/apiGo/database"
"openmediacenter/apiGo/static" "openmediacenter/apiGo/static"
"openmediacenter/apiGo/videoparser" "openmediacenter/apiGo/videoparser"
"os"
"os/signal"
) )
func main() { func main() {
fmt.Println("init OpenMediaCenter server") fmt.Println("init OpenMediaCenter server")
port := 8081 const port uint16 = 8081
config.Init() config.Init()
@ -25,19 +25,25 @@ func main() {
database.InitDB() database.InitDB()
defer database.Close() defer database.Close()
api.AddVideoHandlers() api.AddHandlers()
api.AddSettingsHandlers()
api.AddTagHandlers()
api.AddActorsHandlers()
api.AddTvshowHandlers()
videoparser.SetupSettingsWebsocket() videoparser.SetupSettingsWebsocket()
// add the static files // add the static files
static.ServeStaticFiles() static.ServeStaticFiles()
api2.ServerInit() // init api
errc := make(chan error, 1)
go func() {
errc <- api2.ServerInit(port)
}()
fmt.Printf("OpenMediacenter server up and running on port %d\n", port) sigs := make(chan os.Signal, 1)
log.Fatal(http.ListenAndServe(fmt.Sprintf(":%d", port), nil)) signal.Notify(sigs, os.Interrupt)
select {
case err := <-errc:
fmt.Printf("failed to serve: %v\n", err)
case sig := <-sigs:
fmt.Printf("terminating server: %v\n", sig)
}
} }

View File

@ -14,7 +14,6 @@ import {DefaultTags} from '../../types/GeneralTypes';
import {FontAwesomeIcon} from '@fortawesome/react-fontawesome'; import {FontAwesomeIcon} from '@fortawesome/react-fontawesome';
import {faSortDown} from '@fortawesome/free-solid-svg-icons'; import {faSortDown} from '@fortawesome/free-solid-svg-icons';
// eslint-disable-next-line no-shadow
export enum SortBy { export enum SortBy {
date, date,
likes, likes,

View File

@ -97,7 +97,6 @@ function generalAPICall<T>(
* API nodes definitions * API nodes definitions
*/ */
// eslint-disable-next-line no-shadow
export enum APINode { export enum APINode {
Login = 'login', Login = 'login',
Settings = 'settings', Settings = 'settings',