Skip to content

Commit e1b26d0

Browse files
feat: add notification screen route
1 parent 500c1ab commit e1b26d0

File tree

3 files changed

+22
-15
lines changed

3 files changed

+22
-15
lines changed

cmd/api/api.go

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ func (app *application) mount() http.Handler {
125125
r.Use(app.RateLimiterMiddleware)
126126

127127
r.Use(cors.Handler(cors.Options{
128-
AllowedOrigins: []string{"https://khel.gocloudnepal.com", "http://localhost:3000"},
128+
AllowedOrigins: []string{"https://khel.gocloudnepal.com"},
129129
AllowedMethods: []string{"GET", "POST", "PUT", "DELETE", "OPTIONS", "PATCH"},
130130
AllowedHeaders: []string{"Accept", "Authorization", "Content-Type", "X-CSRF-Token"},
131131
ExposedHeaders: []string{"Link"},
@@ -134,7 +134,7 @@ func (app *application) mount() http.Handler {
134134
}))
135135

136136
//Set a timeout value on the request context (ctx), that will signal through ctx.Done() that the request has timed out and further processing should be stopped
137-
r.Use(middleware.Timeout(60 * time.Second))
137+
r.Use(middleware.Timeout(120 * time.Second))
138138

139139
r.Route("/v1", func(r chi.Router) {
140140
r.Get("/venue/{id}", app.getVenueDetailHandler)
@@ -451,11 +451,12 @@ func (app *application) run(mux http.Handler, cancel context.CancelFunc) error {
451451
}
452452

453453
srv := &http.Server{
454-
Addr: "0.0.0.0:" + port,
455-
Handler: mux,
456-
WriteTimeout: time.Second * 30,
457-
ReadTimeout: time.Second * 10,
458-
IdleTimeout: time.Minute,
454+
Addr: "0.0.0.0:" + port,
455+
Handler: mux,
456+
ReadHeaderTimeout: 5 * time.Second,
457+
ReadTimeout: 45 * time.Second,
458+
WriteTimeout: 120 * time.Second,
459+
IdleTimeout: 60 * time.Second,
459460
}
460461

461462
// Implementing graceful shutdown

cmd/api/main.go

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -84,13 +84,13 @@ func NewLogger() (*zap.SugaredLogger, error) {
8484
return logger.Sugar(), nil
8585
}
8686

87-
var version = "1.7.0"
87+
var version = "2.0.0"
8888

8989
// @title Khel API
9090
// @description API for Khel, a complete sport application.
9191

9292
// @contact.name fullstacksherpa
93-
// @contact.url https://www.fullstacksherpa.tech/
93+
// @contact.url https://khel.gocloudnepal.com/
9494
// @contact.email Ongchen10sherpa@gmail.com
9595

9696
// @license.name Apache 2.0
@@ -121,10 +121,13 @@ func main() {
121121
}
122122

123123
// Retrieve and convert maxOpenConns
124-
maxOpenConnsStr := os.Getenv("DB_MAX_OPEN_CONNS")
125-
maxOpenConns, err := strconv.Atoi(maxOpenConnsStr)
126-
if err != nil {
127-
log.Fatalf("Invalid value for DB_MAX_OPEN_CONNS: %v", err)
124+
maxOpenConns := 10
125+
if v := os.Getenv("DB_MAX_OPEN_CONNS"); v != "" {
126+
if n, err := strconv.Atoi(v); err == nil {
127+
maxOpenConns = n
128+
} else {
129+
log.Fatalf("Invalid DB_MAX_OPEN_CONNS: %v", err)
130+
}
128131
}
129132

130133
cfg := config{
@@ -312,5 +315,7 @@ func main() {
312315

313316
mux := app.mount()
314317

315-
logger.Fatal(app.run(mux, cancel))
318+
if err := app.run(mux, cancel); err != nil {
319+
logger.Fatal(err)
320+
}
316321
}

internal/notifications/booking_notifications.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,8 @@ func SendBookingNotification(ctx context.Context, push PushSender, store *storag
6363
"type": "booking",
6464
"event": string(event),
6565
"bookingId": bookingID,
66-
"screen": "user-bookings-screen", // / is already at client router.push(`/${data.screen}`);
66+
"screen": "settings", // / is already at client router.push(`/${data.screen}`);
67+
6768
},
6869
}
6970
msgs = append(msgs, msg)

0 commit comments

Comments
 (0)