This commit is contained in:
2022-11-22 13:46:44 +08:00
parent 4784078dc7
commit bfe739e442
3 changed files with 10 additions and 3 deletions

View File

@@ -55,7 +55,7 @@ var (
func init() {
var err error
DB, err = sql.Open("postgres", "postgres://itsc@localhost:5432/itsc?sslmode=disable")
DB, err = sql.Open("postgres", os.Getenv("POSTGRES_CONNSTR"))
if err != nil {
log.Fatal(err)
}
@@ -63,6 +63,7 @@ func init() {
if len(os.Args) > 1{
if os.Args[1] == "install" {
install()
os.Exit(0)
}
}

View File

@@ -46,7 +46,12 @@ var wsUpgrader = websocket.Upgrader{
func main() {
r := gin.Default()
r.Use(func(c *gin.Context) {
group := r.Group("/")
group.StaticFile("/", "./web/build/index.html")
group.Static("/web", "./web/build")
group.Use(func(c *gin.Context) {
c.Next()
if len(c.Errors) > 0 {
c.JSON(-1, gin.H{
@@ -56,7 +61,7 @@ func main() {
}
})
api := r.Group("/api")
api := group.Group("/api")
api.GET("/timetables", func(c *gin.Context) {
timetables := make([]*db.Timetable, 0)

View File

@@ -2,6 +2,7 @@
"name": "web",
"version": "0.1.0",
"private": true,
"homepage": "/web",
"dependencies": {
"@emotion/react": "^11.10.5",
"@emotion/styled": "^11.10.5",