-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathconfig.rkt
75 lines (53 loc) · 2.13 KB
/
config.rkt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
#lang racket/base
;;;
;;; CONFIGURATION
;;;
; This file contains settings that may differ between development, testing and
; actual deployment.
;;; DATABASES
; Our code can run on two different databases: sqlite and postgreql.
; The advantage of sqlite is that it requires no setup; it simply
; stores everything in a local file. The disadvantage is that
; it has a very small set of features. For someone who just wants to
; try the racket-stories app on their own computer, sqlite
; will work out of the box.
; The real racket-stories.com uses a postgresql database.
; Postgreql on the other hand needs a bit of setup:
; a server process (that handles multiple databases, users,
; authentication etc) must be started.
; During development a local postgresql server will be practical
; to use.
(provide (all-defined-out))
;; Requirements
(require racket/format racket/match racket/runtime-path
"deployment.rkt" "parameters.rkt" "secret.rkt" "structs.rkt")
;;; Sqlite
(define-runtime-path sqlite-db "../dbs/racket-stories-sqlite.db")
; no user / password
(define-runtime-path sqlite-db-dir "../dbs")
;;; Postgresql
(define (database-name)
(match the-deployment
[(development) "racket-stories-development"]
[(testing) "racket-stories-testing"]
[(staging) "racket-stories-staging"]
[(production) "racket-stories"]
[else "racket-stories-development"]))
(define (database-user)
(match the-deployment
[(or (staging) (production)) (decrypt "3c05c524ae")]
[(or (development) (testing)) "rs"]))
(define (database-password)
(match the-deployment
[(or (staging) (production)) (decrypt "3b1cc134b544d84e19f85b9975f9cf87")]
[(or (development) (testing)) "rs"]))
(define (database-server)
(match the-deployment
[(or (staging) (production))
(decrypt (~a "2a149f32b84c874b02ad5cd07cfa95c43fdad09b67c55bd07e"
"6a3a9c6b971895ecda4cdc7def8871ee78ef46686170ee949d"))]
[(or (development) (testing)) "localhost"]))
(define (database-port)
(match the-deployment
[(or (staging) (production)) (string->number (decrypt "7c438277fc"))]
[(or (development) (testing)) 5432]))