@@ -129,8 +129,6 @@ func main() {
129129
130130 defer temporalClient .Close ()
131131
132- usersHandler := handler .NewUsers (temporalClient , * cfg )
133-
134132 r .Route ("/tenant" , func (r chi.Router ) {
135133 if os .Getenv ("ENABLE_JWT_AUTH" ) == "true" {
136134 pubKey , _ := util .GetRawPublicKey ()
@@ -139,16 +137,37 @@ func main() {
139137
140138 r .Use (jwtauth .Verifier (tokenAuth ))
141139 r .Use (util .Authenticator ())
140+ } else {
141+ // TO-DO Handle different type of auth or no auth at all
142+ // right now just exit with error
143+ log .Fatalln ("Enable jwt auth" )
142144 }
143145
144- // TO-DO Add middleware if we don't authenticate with JWT
145- // https://app.plane.so/crocoder/browse/DXTA-307/
146-
147146 r .Post ("/teams" , handler .CreateTeam )
148147 r .Post ("/teams/{team_id}/members/{member_id}" , handler .AddMemberToTeam )
149148 r .Post ("/members" , handler .CreateMember )
150149 })
151150
151+ temporalHandler := handler .NewTemporalHandler (temporalClient , * cfg )
152+
153+ r .Route ("/onboarding" , func (r chi.Router ) {
154+ if os .Getenv ("ENABLE_JWT_AUTH" ) == "true" {
155+ pubKey , _ := util .GetRawPublicKey ()
156+
157+ tokenAuth := util .CreateAuthVerifier (pubKey )
158+
159+ r .Use (jwtauth .Verifier (tokenAuth ))
160+ r .Use (util .Authenticator ())
161+ } else {
162+ // TO-DO Handle different type of auth or no auth at all
163+ // right now just exit with error
164+ log .Fatalln ("Enable jwt auth" )
165+ }
166+
167+ r .Post ("/databases" , temporalHandler .CreateTenantDB )
168+ r .Post ("/github-installation" , temporalHandler .GithubInstallation )
169+ })
170+
152171 r .Get ("/health" , func (w http.ResponseWriter , r * http.Request ) {
153172 w .Write ([]byte (`OK` ))
154173 })
@@ -157,7 +176,7 @@ func main() {
157176 w .Write ([]byte (`OK` ))
158177 })
159178
160- r .Get ("/users-count" , usersHandler .UsersCount )
179+ r .Get ("/users-count" , temporalHandler .UsersCount )
161180
162181 go func () {
163182 log .Printf ("Listening on %s\n " , srv .Addr )
0 commit comments