mirror of
https://github.com/coder/coder.git
synced 2025-07-03 16:13:58 +00:00
feat: Add project API endpoints (#51)
* feat: Add project models * Add project query functions * Add organization parameter query * Add project URL parameter parse * Add project create and list endpoints * Add test for organization provided * Remove unimplemented routes * Decrease conn timeout * Add test for UnbiasedModulo32 * Fix expected value * Add single user endpoint * Add query for project versions * Fix linting errors * Add comments * Add test for invalid archive * Check unauthenticated endpoints * Add check if no change happened * Ensure context close ends listener * Fix parallel test run * Test empty * Fix organization param comment
This commit is contained in:
@ -20,6 +20,9 @@ type Options struct {
|
||||
|
||||
// New constructs the Coder API into an HTTP handler.
|
||||
func New(options *Options) http.Handler {
|
||||
projects := &projects{
|
||||
Database: options.Database,
|
||||
}
|
||||
users := &users{
|
||||
Database: options.Database,
|
||||
}
|
||||
@ -44,6 +47,25 @@ func New(options *Options) http.Handler {
|
||||
r.Get("/{user}/organizations", users.userOrganizations)
|
||||
})
|
||||
})
|
||||
r.Route("/projects", func(r chi.Router) {
|
||||
r.Use(
|
||||
httpmw.ExtractAPIKey(options.Database, nil),
|
||||
)
|
||||
r.Get("/", projects.allProjects)
|
||||
r.Route("/{organization}", func(r chi.Router) {
|
||||
r.Use(httpmw.ExtractOrganizationParam(options.Database))
|
||||
r.Get("/", projects.allProjectsForOrganization)
|
||||
r.Post("/", projects.createProject)
|
||||
r.Route("/{project}", func(r chi.Router) {
|
||||
r.Use(httpmw.ExtractProjectParameter(options.Database))
|
||||
r.Get("/", projects.project)
|
||||
r.Route("/versions", func(r chi.Router) {
|
||||
r.Get("/", projects.projectVersions)
|
||||
r.Post("/", projects.createProjectVersion)
|
||||
})
|
||||
})
|
||||
})
|
||||
})
|
||||
})
|
||||
r.NotFound(site.Handler().ServeHTTP)
|
||||
return r
|
||||
|
Reference in New Issue
Block a user