feat: Prototype - Stub APIs for /projects and /workspaces endpoints by bryphe-coder · Pull Request #30 · coder/coder · GitHub
Skip to content

feat: Prototype - Stub APIs for /projects and /workspaces endpoints - #30

Closed
bryphe-coder wants to merge 3 commits into
mainfrom
bryphe/prototype/initial-apis
Closed

feat: Prototype - Stub APIs for /projects and /workspaces endpoints#30
bryphe-coder wants to merge 3 commits into
mainfrom
bryphe/prototype/initial-apis

Conversation

@bryphe-coder

@bryphe-coder bryphe-coder commented Jan 19, 2022

Copy link
Copy Markdown
Contributor

This adds some very simple, hardcoded endpoints for the /projects and /workspaces - just enough test data to exercise the flow in the UI:

		// Projects endpoint
		r.Route("/projects", func(r chi.Router) {
			r.Route("/{organization}", func(r chi.Router) {
				// TODO: Authentication
				// TODO: User extraction
				// TODO: Extract organization and add to context
				r.Get("/", api.projectService.getProjects)
				r.Post("/", api.projectService.createProject)

				r.Get("/{projectId}", api.projectService.getProjectById)
				// TODO: Get project by id
			})
		})

		// Workspaces endpoint
		r.Route("/workspaces", func(r chi.Router) {
			r.Route("/{organization}", func(r chi.Router) {
				r.Get("/", api.workspaceService.getWorkspaces)
				r.Get("/{workspaceId}", api.workspaceService.getWorkspaceById)
			})
		})		

With this, I can use the develop.sh script and get a server that sends data back for those APIs:
image

In order to facilitate this, I brought in the xjson library... which then required several other additional libraries:

  • srverr
  • validate
  • longid
  • buildmode

...and some external libraries:

  • github.com/asaskevich/govalidator
  • github.com/go-playground/validator/v10
  • k8s.io/utils

There's a couple possible next steps:

  • This might be completely superceded by work @kylecarbs is doing - so it's fine if this goes away and replaced by a more robust set of APIs! We can still discuss the types and make sure we have parity on the API surface.
  • We could merge this as scaffolding to build out the API routes - there's a lot left to be plumbed and connected to the actual provisioners.

Related to #23

@bryphe-coder
bryphe-coder marked this pull request as draft January 19, 2022 05:10
@codecov

codecov Bot commented Jan 19, 2022

Copy link
Copy Markdown

@bryphe-coder bryphe-coder self-assigned this Jan 19, 2022

@kylecarbs kylecarbs left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll add these routes soon! I think stubbing the frontend is a wonderful way to handle it for now.

@bryphe-coder

Copy link
Copy Markdown
Contributor Author

@kylecarbs
kylecarbs deleted the bryphe/prototype/initial-apis branch January 29, 2022 15:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants