feat: Add Coder Daemon to serve the API (#18)

* feat: Add v1 schema types

This adds compatibility for sharing data with Coder v1. Since the tables are the same, all CRUD operations should function as expected.

* Add license table

* feat: Add Coder Daemon to serve the API

coderd is a public package which will be consumed by v1 to support running both at the same time. The frontend will need to be compiled and statically served as part of this eventually.

* Fix initial migration

* Move to /api/v2

* Increase peer disconnectedTimeout to reduce flakes on slow machines

* Reduce timeout again

* Fix version for pion/ice
This commit is contained in:
Kyle Carberry
2022-01-13 16:55:28 -06:00
committed by GitHub
parent 4308f169d6
commit afc2fa3b62
7 changed files with 291 additions and 25 deletions

31
coderd/coderd.go Normal file
View File

@ -0,0 +1,31 @@
package coderd
import (
"net/http"
"cdr.dev/slog"
"github.com/coder/coder/database"
"github.com/go-chi/chi"
"github.com/go-chi/render"
)
// Options are requires parameters for Coder to start.
type Options struct {
Logger slog.Logger
Database database.Store
}
// New constructs the Coder API into an HTTP handler.
func New(options *Options) http.Handler {
r := chi.NewRouter()
r.Route("/api/v2", func(r chi.Router) {
r.Get("/", func(w http.ResponseWriter, r *http.Request) {
render.JSON(w, r, struct {
Message string `json:"message"`
}{
Message: "👋",
})
})
})
return r
}