-
Notifications
You must be signed in to change notification settings - Fork 8
/
main.go
43 lines (37 loc) · 863 Bytes
/
main.go
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
package main
import (
"database/sql"
"os"
"github.com/dascr/dascr-board/api"
"github.com/dascr/dascr-board/config"
"github.com/dascr/dascr-board/database"
"github.com/dascr/dascr-board/logger"
)
var (
db *sql.DB
err error
// Debug will hold global debug flag
Debug bool = false
)
func main() {
// Generate uploads directory
if err := os.MkdirAll("./uploads", os.ModePerm); err != nil {
logger.Panicf("Unable to create uploads directory: %+v", err)
}
// Setup DB
dbconfig := &config.DBConfig{
Driver: "sqlite3",
Filename: "./dascr.db",
}
if db, err = database.SetupDB(dbconfig); err != nil {
logger.Panicf("Unable to create database: %+v", err)
}
// API Config
APIConfig := &config.APIConfig{
IP: config.MustGet("API_IP"),
Port: config.MustGet("API_PORT"),
}
// Setup API
a := api.SetupAPI(db, APIConfig)
a.Start()
}