You've already forked openaccounting-server
mirror of
https://github.com/openaccounting/oa-server.git
synced 2025-12-09 00:50:59 +13:00
initial commit
This commit is contained in:
50
core/server.go
Normal file
50
core/server.go
Normal file
@@ -0,0 +1,50 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"github.com/openaccounting/oa-server/core/api"
|
||||
"github.com/openaccounting/oa-server/core/auth"
|
||||
"github.com/openaccounting/oa-server/core/model"
|
||||
"github.com/openaccounting/oa-server/core/model/db"
|
||||
"github.com/openaccounting/oa-server/core/model/types"
|
||||
"github.com/openaccounting/oa-server/core/util"
|
||||
"log"
|
||||
"net/http"
|
||||
"os"
|
||||
"strconv"
|
||||
//"fmt"
|
||||
)
|
||||
|
||||
func main() {
|
||||
//filename is the path to the json config file
|
||||
var config types.Config
|
||||
file, err := os.Open("./config.json")
|
||||
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
||||
decoder := json.NewDecoder(file)
|
||||
err = decoder.Decode(&config)
|
||||
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
||||
connectionString := config.User + ":" + config.Password + "@/" + config.Database
|
||||
|
||||
db, err := db.NewDB(connectionString)
|
||||
|
||||
bc := &util.StandardBcrypt{}
|
||||
|
||||
model.NewModel(db, bc, config)
|
||||
auth.NewAuthService(db, bc)
|
||||
|
||||
app, err := api.Init()
|
||||
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
||||
log.Fatal(http.ListenAndServeTLS(":"+strconv.Itoa(config.Port), config.CertFile, config.KeyFile, app.MakeHandler()))
|
||||
}
|
||||
Reference in New Issue
Block a user