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
|
pub const App = struct {
allocator: std.mem.Allocator,
pool: *pg.Pool,
// templates: []mustache.Template,
pub fn init(allocator: std.mem.Allocator) !App {
var env_map = try std.process.getEnvMap(allocator);
defer env_map.deinit();
const pool = try pg.Pool.init(allocator, .{
.size = 5,
.connect = .{
// .port = 5432,
.unix_socket = env_map.get("PGSQL_SOCKET") orelse "/tmp/pg1/.s.PGSQL.5432",
},
.auth = .{
.username = "teamdraft_website",
.database = "teamdraft",
.password = env_map.get("PGSQL_PASSWORD") orelse "teamdraft",
.timeout = 10_000,
},
});
return .{
.allocator = allocator,
.pool = pool,
};
}
pub fn deinit(self: *App) void {
self.pool.deinit();
}
};
const mustache = @import("mustache");
const pg = @import("pg");
const std = @import("std");
|