short-d/short

View on GitHub
backend/dep/provider/routes.go

Summary

Maintainability
A
1 hr
Test Coverage
package provider

import (
    "github.com/short-d/app/fw/router"
    "github.com/short-d/app/fw/timer"
    "github.com/short-d/short/backend/app/adapter/facebook"
    "github.com/short-d/short/backend/app/adapter/github"
    "github.com/short-d/short/backend/app/adapter/google"
    "github.com/short-d/short/backend/app/adapter/request"
    "github.com/short-d/short/backend/app/adapter/routing"
    "github.com/short-d/short/backend/app/usecase/authenticator"
    "github.com/short-d/short/backend/app/usecase/feature"
    "github.com/short-d/short/backend/app/usecase/search"
    "github.com/short-d/short/backend/app/usecase/shortlink"
)

// WebFrontendURL represents the URL of the web frontend
type WebFrontendURL string

// SwaggerUIDir represents the root directory of Swagger UI static assets.
type SwaggerUIDir string

// OpenAPISpecPath represents the location of OpenAPI specification.
type OpenAPISpecPath string

// NewShortRoutes creates HTTP routes for Short API with WwwRoot to uniquely identify WwwRoot during dependency injection.
func NewShortRoutes(
    instrumentationFactory request.InstrumentationFactory,
    webFrontendURL WebFrontendURL,
    timer timer.Timer,
    shortLinkRetriever shortlink.Retriever,
    featureDecisionMakerFactory feature.DecisionMakerFactory,
    githubSSO github.SingleSignOn,
    facebookSSO facebook.SingleSignOn,
    googleSSO google.SingleSignOn,
    authenticator authenticator.Authenticator,
    search search.Search,
    swaggerUIDir SwaggerUIDir,
    openAPISpecPath OpenAPISpecPath,
) []router.Route {
    return routing.NewShort(
        instrumentationFactory,
        string(webFrontendURL),
        timer,
        shortLinkRetriever,
        featureDecisionMakerFactory,
        githubSSO,
        facebookSSO,
        googleSSO,
        authenticator,
        search,
        string(swaggerUIDir),
        string(openAPISpecPath),
    )
}