Skip to content

Commit

Permalink
feat: add api
Browse files Browse the repository at this point in the history
  • Loading branch information
ugnmura committed Jan 6, 2024
1 parent 4ba1467 commit 6466cce
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 0 deletions.
22 changes: 22 additions & 0 deletions api/api.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package api

import (
"net/http"
"io/fs"
"github.com/SushiWaUmai/prince/frontend"
)

func CreateAPI() {
assetsFs, err := fs.Sub(frontend.Assets(), "build")
if err != nil {
panic(err)
}


http.Handle("/", http.FileServer(http.FS(assetsFs)))

err = http.ListenAndServe(":3000", nil)
if err != nil {
panic(err)
}
}
10 changes: 10 additions & 0 deletions frontend/assets.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package frontend

import "embed"

//go:embed build/*

Check failure on line 5 in frontend/assets.go

View workflow job for this annotation

GitHub Actions / build-and-test

pattern build/*: no matching files found

Check failure on line 5 in frontend/assets.go

View workflow job for this annotation

GitHub Actions / build-and-test

pattern build/*: no matching files found
var assets embed.FS

func Assets() embed.FS {
return assets
}
1 change: 1 addition & 0 deletions frontend/src/routes/+layout.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export const prerender = true;
3 changes: 3 additions & 0 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (

"go.mau.fi/whatsmeow/store/sqlstore"

// "github.com/SushiWaUmai/prince/api"
"github.com/SushiWaUmai/prince/client"
_ "github.com/SushiWaUmai/prince/commands"
"github.com/SushiWaUmai/prince/env"
Expand All @@ -16,6 +17,8 @@ import (
)

func main() {
// api.CreateAPI()

dbLog := waLog.Stdout("Database", "DEBUG", true)
// Make sure you add appropriate DB connector imports, e.g. github.com/mattn/go-sqlite3 for SQLite
container, err := sqlstore.New("sqlite3", "file:./data/auth.db?_foreign_keys=on", dbLog)
Expand Down

0 comments on commit 6466cce

Please sign in to comment.