Hospify Core is a backend service. It provides REST API for Hospify
- Install
postgresql
(prefer v10) - Install
golang
, set up path (Unix only, google for Windows)
# .bash_profile
export GOPATH="/your/go/path" # /Users/<username>/Documents/go
export PATH=$PATH:$GOROOT/bin
export PATH=$PATH:$GOPATH/bin
- Install
redis
- Install Docker
# make root dir and cd to new dir
$ mkdir hospify-dev && cd hospify-dev # or any name you want
# clone projects
$ git clone [email protected]:leovinh/hospify-master.git
$ git clone [email protected]:leovinh/hospify-core.git
# pwd: hospify-master
$ cp db/dbconf.yml.example db/dbconf.yml # edit datatabase config for migration in dbconf.yml
$ goose up
# pwd: hospify-core
# cuz we will run in host network mode so we must edit config.go
$ cp config/config.go.example config/config.go
# pwd: hospify-dev
$ docker build --rm -t hospify-image-dev -f hospify-core/Dockerfile .
# Create volume to backup resource
$ docker volume create --name HospifyDevResource
# test run
docker run --net=host --env-file hospify-core/.env.beta -it --rm --name hospify-dev hospify-image-dev
# run in detach mode
# Maping resources dir
$ docker run -v HospifyDevResource:/go/src/hospify-core/resources -d --net=host -it --rm --name hospify-dev hospify-image-dev
- Clone project in go source
$GOPATH/src
git clone [email protected]:leovinh/hospify-master.git
git clone [email protected]:leovinh/hospify-core.git
- Copy the configurations in hospify-core project
cp config/config.go.example config/config.go
Migration data
cd hospify-master
go get bitbucet.org/liamstask/goose/cmd/goose
cp db/dbconf.yml.example db/dbconf.yml
goose up
- Install and run app hospify-core
go get
go run main.go
- Build executable binary file
go build
./hospify-core
go build
# Run as a daemonize process
./startup <start,stop,restart>
- Auth
- Hotel
- Room
- Guest
- Booking
- Folio
- Response
- Company
- User
- Marketing Channel
- Marketing Source
- Payment
...
// init is invoked before main()
func init() {
// loads values from .env into the system
if err := godotenv.Load(); err != nil {
log.Print("No .env file found")
}
}
func main() {
conf := config.New()
if config.GetAppMode() == gin.ReleaseMode {
logrus.SetLevel(logrus.WarnLevel)
} else {
logrus.SetLevel(logrus.DebugLevel)
}
logrus.AddHook(filename.NewHook())
logrus.SetFormatter(&logrus.TextFormatter{
FullTimestamp: true,
ForceColors: true,
DisableLevelTruncation: true,
})
logrus.Info("API say Halo :D")
// PSQL
cf := resource.ResourceConfig{
PostgreSQLLogger: config.GetAppMode() != gin.ReleaseMode,
IsEnablePostgres: true,
// to use variable from .env
PostgreSQLDatabase: "postgres://" + conf.Psql.DbUser + ":" + conf.Psql.DbPwd + "@" + conf.Psql.DbHost + ":" + conf.Psql.DbPort + "/" + conf.Psql.DbName + "?sslmode=disable",
IsEnableRedis: config.IsEnableRedis(),
RedisPrefix: config.GetRedisKeyPrefix(),
RedisDBURI: config.GetRedisDBURI(),
}
- Find/create guest
- Get booking count
- Checking room info
- Nomal: checking room id (if room client send Room.ID)
- CMS: find mapped room type, auto assign room for, booking if posible, find company
- Create booking
- Update hotel booking count
- Create occupancy forecast
- Create folio
- Create charges
Copyright (c) Hospify Ltd. All rights reserved.