Rename the module, proto service, and all identifiers from simple_bank/ SimpleBank to api_tmpl/ApiTmpl, and regenerate the gRPC/gateway/swagger/ mock code accordingly. - Scrub real secrets (SMTP password, auth token secret) from api.env/ api_test.env, untrack them, and add api.env.example/api_test.env.example - Remove committed build artifacts (tmp/main, tmp/build-errors.log, dbml-error.log) and gitignore them going forward - Fix Dockerfile paths (build target, migrations copy) that referenced a stale project layout - Rewrite README to match the actual cmd/ + internal/ structure and add a "using this as a template" section
44 lines
1.3 KiB
Go
44 lines
1.3 KiB
Go
// Package gapi implements the gRPC server for the API Template application.
|
|
package gapi
|
|
|
|
import (
|
|
"github.com/FernandoJVideira/api_tmpl/internal/auth"
|
|
"github.com/FernandoJVideira/api_tmpl/internal/config"
|
|
db "github.com/FernandoJVideira/api_tmpl/internal/db/sqlc"
|
|
"github.com/FernandoJVideira/api_tmpl/internal/service"
|
|
"github.com/FernandoJVideira/api_tmpl/internal/worker"
|
|
"github.com/FernandoJVideira/api_tmpl/pb"
|
|
)
|
|
|
|
// Server serves gRPC requests for our service.
|
|
type Server struct {
|
|
pb.UnimplementedApiTmplServer // Embedding for forward compatibility
|
|
config config.Config
|
|
store db.Store
|
|
tokenMaker auth.Maker
|
|
taskDistributor worker.TaskDistributor
|
|
userService service.UserService
|
|
authService service.AuthService
|
|
}
|
|
|
|
// NewServer creates a new gRPC server instance.
|
|
func NewServer(
|
|
config config.Config,
|
|
store db.Store,
|
|
taskDistributor worker.TaskDistributor,
|
|
tokenMaker auth.Maker,
|
|
userService service.UserService,
|
|
authService service.AuthService,
|
|
) (*Server, error) {
|
|
server := &Server{
|
|
config: config,
|
|
store: store,
|
|
tokenMaker: tokenMaker,
|
|
taskDistributor: taskDistributor,
|
|
userService: userService,
|
|
authService: authService,
|
|
}
|
|
|
|
return server, nil
|
|
}
|