Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 3 commits into from

Conversation

bryphe-coder
Copy link
Contributor

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

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
Copy link

codecov bot commented Jan 19, 2022

Codecov Report

Merging #30 (6726f40) into main (4dc6e35) will decrease coverage by 2.58%.
The diff coverage is 60.47%.

Impacted file tree graph

@@            Coverage Diff             @@
##             main      #30      +/-   ##
==========================================
- Coverage   71.01%   68.43%   -2.59%     
==========================================
  Files          18       49      +31     
  Lines         138     2116    +1978     
  Branches        7        7              
==========================================
+ Hits           98     1448    +1350     
- Misses         36      568     +532     
- Partials        4      100      +96     
Flag Coverage Δ
unittest-go-macos-latest 63.71% <60.47%> (?)
unittest-go-ubuntu-latest 67.79% <60.47%> (?)
unittest-go-windows-latest 63.11% <60.47%> (?)
unittest-js 71.01% <ø> (ø)
Impacted Files Coverage Δ
srverr/errors.go 0.00% <0.00%> (ø)
xjson/json.go 15.00% <15.00%> (ø)
srverr/wrap.go 33.33% <33.33%> (ø)
xjson/duration.go 70.00% <70.00%> (ø)
longid/id.go 75.65% <75.65%> (ø)
validate/struct.go 85.16% <85.16%> (ø)
validate/validator.go 88.23% <88.23%> (ø)
validate/devurl.go 100.00% <100.00%> (ø)
validate/numeric.go 100.00% <100.00%> (ø)
validate/user.go 100.00% <100.00%> (ø)
... and 21 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 4dc6e35...6726f40. Read the comment docs.

@bryphe-coder bryphe-coder self-assigned this Jan 19, 2022
Copy link
Member

@kylecarbs kylecarbs left a comment

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
Contributor Author

We have real data now, so this is no longer necessary 🥳

@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