Skip to content

Commit 28da475

Browse files
authored
Merge pull request #55 from raghavyuva/feat/develop
fix(docs):documentation build errors
2 parents 019d0e3 + a9384dd commit 28da475

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+3295
-104088
lines changed

.github/workflows/docs.yml

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
name: Deploy Docs
2+
3+
on:
4+
push:
5+
branches: [main]
6+
paths:
7+
- 'docs/**'
8+
- '.github/workflows/docs.yml'
9+
workflow_dispatch:
10+
11+
permissions:
12+
contents: read
13+
pages: write
14+
id-token: write
15+
16+
concurrency:
17+
group: pages
18+
cancel-in-progress: false
19+
20+
jobs:
21+
build:
22+
runs-on: ubuntu-latest
23+
steps:
24+
- name: Checkout
25+
uses: actions/checkout@v4
26+
with:
27+
fetch-depth: 0
28+
29+
- name: Setup Node
30+
uses: actions/setup-node@v4
31+
with:
32+
node-version: 20
33+
cache: yarn
34+
35+
- name: Setup Pages
36+
uses: actions/configure-pages@v4
37+
38+
- name: Install dependencies
39+
run: |
40+
cd docs
41+
yarn install --frozen-lockfile
42+
43+
- name: Build with VitePress
44+
run: |
45+
cd docs
46+
yarn docs:build
47+
48+
- name: Ensure CNAME exists
49+
run: |
50+
if [ ! -f docs/.vitepress/dist/CNAME ]; then
51+
cp docs/public/CNAME docs/.vitepress/dist/CNAME
52+
fi
53+
54+
- name: Upload artifact
55+
uses: actions/upload-pages-artifact@v3
56+
with:
57+
path: docs/.vitepress/dist
58+
59+
deploy:
60+
environment:
61+
name: github-pages
62+
url: ${{ steps.deployment.outputs.page_url }}
63+
needs: build
64+
runs-on: ubuntu-latest
65+
steps:
66+
- name: Deploy to GitHub Pages
67+
id: deployment
68+
uses: actions/deploy-pages@v4

.gitignore

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,8 @@ api/tmp
33
api/bin/
44
.env
55
data
6-
node_modules
6+
node_modules
7+
.cache
8+
dist
9+
docs/.vitepress/dist
10+
docs/.vitepress/cache

api/api/versions.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
{
44
"version": "v1",
55
"status": "active",
6-
"release_date": "2025-04-18T12:57:36.759014+05:30",
6+
"release_date": "2025-04-18T16:26:18.53547+05:30",
77
"end_of_life": "0001-01-01T00:00:00Z",
88
"changes": [
99
"Initial API version"

api/doc/openapi.json

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

api/internal/features/organization/controller/get_organization.go

Lines changed: 19 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -3,34 +3,33 @@ package controller
33
import (
44
"net/http"
55

6+
"github.com/go-fuego/fuego"
67
"github.com/raghavyuva/nixopus-api/internal/features/logger"
78
"github.com/raghavyuva/nixopus-api/internal/features/organization/types"
8-
"github.com/raghavyuva/nixopus-api/internal/utils"
9+
shared_types "github.com/raghavyuva/nixopus-api/internal/types"
910
)
1011

11-
// GetOrganization godoc
12-
// @Summary Get an organization
13-
// @Description Retrieves an organization by its ID.
14-
// @Tags organization
15-
// @Accept json
16-
// @Produce json
17-
// @Security BearerAuth
18-
// @Param id path string true "Organization ID"
19-
// @Success 200 {object} types.Organization "Success response with organization"
20-
// @Failure 400 {object} types.Response "Bad request"
21-
// @Failure 500 {object} types.Response "Internal server error"
22-
// @Router /organization/{id} [get]
23-
func (c *OrganizationsController) GetOrganization(w http.ResponseWriter, r *http.Request) {
24-
id := r.URL.Query().Get("id")
12+
func (c *OrganizationsController) GetOrganization(f fuego.ContextNoBody) (*shared_types.Response, error) {
13+
id := f.QueryParam("id")
2514
if err := c.validator.ValidateID(id, types.ErrMissingOrganizationID); err != nil {
2615
c.logger.Log(logger.Error, err.Error(), "")
27-
utils.SendErrorResponse(w, err.Error(), http.StatusBadRequest)
28-
return
16+
return nil, fuego.HTTPError{
17+
Err: err,
18+
Status: http.StatusBadRequest,
19+
}
2920
}
21+
3022
organization, err := c.service.GetOrganization(id)
3123
if err != nil {
32-
utils.SendErrorResponse(w, err.Error(), http.StatusInternalServerError)
33-
return
24+
return nil, fuego.HTTPError{
25+
Err: err,
26+
Status: http.StatusInternalServerError,
27+
}
3428
}
35-
utils.SendJSONResponse(w, "success", "Organization fetched successfully", organization)
29+
30+
return &shared_types.Response{
31+
Status: "success",
32+
Message: "Organization fetched successfully",
33+
Data: organization,
34+
}, nil
3635
}

api/internal/features/organization/controller/get_organizations.go

Lines changed: 13 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -3,26 +3,24 @@ package controller
33
import (
44
"net/http"
55

6+
"github.com/go-fuego/fuego"
67
"github.com/raghavyuva/nixopus-api/internal/features/logger"
7-
"github.com/raghavyuva/nixopus-api/internal/utils"
8+
shared_types "github.com/raghavyuva/nixopus-api/internal/types"
89
)
910

10-
// GetOrganizations godoc
11-
// @Summary Get all organizations
12-
// @Description Retrieves all organizations.
13-
// @Tags organization
14-
// @Accept json
15-
// @Produce json
16-
// @Security BearerAuth
17-
// @Success 200 {array} types.Organization "Success response with organizations"
18-
// @Failure 500 {object} types.Response "Internal server error"
19-
// @Router /organizations [get]
20-
func (c *OrganizationsController) GetOrganizations(w http.ResponseWriter, r *http.Request) {
11+
func (c *OrganizationsController) GetOrganizations(f fuego.ContextNoBody) (*shared_types.Response, error) {
2112
organizations, err := c.service.GetOrganizations()
2213
if err != nil {
2314
c.logger.Log(logger.Error, err.Error(), "")
24-
utils.SendErrorResponse(w, err.Error(), http.StatusInternalServerError)
25-
return
15+
return nil, fuego.HTTPError{
16+
Err: err,
17+
Status: http.StatusInternalServerError,
18+
}
2619
}
27-
utils.SendJSONResponse(w, "success", "Organizations fetched successfully", organizations)
20+
21+
return &shared_types.Response{
22+
Status: "success",
23+
Message: "Organizations fetched successfully",
24+
Data: organizations,
25+
}, nil
2826
}

api/internal/features/organization/controller/get_roles.go

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -8,16 +8,6 @@ import (
88
shared_types "github.com/raghavyuva/nixopus-api/internal/types"
99
)
1010

11-
// GetRoles godoc
12-
// @Summary Get all roles with permissions
13-
// @Description Retrieves all roles with their permissions in the database
14-
// @Tags organization
15-
// @Accept json
16-
// @Produce json
17-
// @Security BearerAuth
18-
// @Success 200 {array} types.Role "Success response with roles and permissions"
19-
// @Failure 500 {object} types.Response "Internal server error"
20-
// @Router /organizations/roles [get]
2111
func (c *OrganizationsController) GetRoles(f fuego.ContextNoBody) (*shared_types.Response, error) {
2212
c.logger.Log(logger.Info, "getting all roles with permissions", "")
2313

api/internal/features/organization/controller/init.go

Lines changed: 0 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ import (
1313
role_storage "github.com/raghavyuva/nixopus-api/internal/features/role/storage"
1414
shared_storage "github.com/raghavyuva/nixopus-api/internal/storage"
1515
shared_types "github.com/raghavyuva/nixopus-api/internal/types"
16-
"github.com/raghavyuva/nixopus-api/internal/utils"
1716
)
1817

1918
type OrganizationsController struct {
@@ -44,38 +43,6 @@ func NewOrganizationsController(
4443
}
4544
}
4645

47-
// parseAndValidate parses and validates the request body.
48-
//
49-
// This method attempts to parse the request body into the provided 'req' interface
50-
// using the controller's validator. If parsing fails, an error response is sent
51-
// and the method returns false. It also validates the parsed request object and
52-
// returns false if validation fails. If both operations are successful, it returns true.
53-
//
54-
// Parameters:
55-
//
56-
// w - the HTTP response writer to send error responses.
57-
// r - the HTTP request containing the body to parse.
58-
// req - the interface to populate with the parsed request body.
59-
//
60-
// Returns:
61-
//
62-
// bool - true if parsing and validation succeed, false otherwise.
63-
func (c *OrganizationsController) parseAndValidate(w http.ResponseWriter, r *http.Request, req interface{}) bool {
64-
if err := c.validator.ParseRequestBody(r, r.Body, req); err != nil {
65-
c.logger.Log(logger.Error, shared_types.ErrFailedToDecodeRequest.Error(), err.Error())
66-
utils.SendErrorResponse(w, shared_types.ErrFailedToDecodeRequest.Error(), http.StatusBadRequest)
67-
return false
68-
}
69-
70-
if err := c.validator.ValidateRequest(req); err != nil {
71-
c.logger.Log(logger.Error, err.Error(), err.Error())
72-
utils.SendErrorResponse(w, err.Error(), http.StatusBadRequest)
73-
return false
74-
}
75-
76-
return true
77-
}
78-
7946
// Notify sends a notification to the user for the given payload type.
8047
//
8148
// This method constructs a new NotificationPayload object with the given user and request data,

api/internal/routes.go

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -82,14 +82,16 @@ func (router *Router) Routes() {
8282
)
8383

8484
apiV1 := api.NewVersion(api.CurrentVersion)
85+
8586
healthGroup := fuego.Group(server, apiV1.Path+"/health")
8687
router.BasicRoutes(healthGroup)
8788

8889
notificationManager := notification.NewNotificationManager(router.app.Store.DB)
8990
notificationManager.Start()
9091
deployController := deploy.NewDeployController(router.app.Store, router.app.Ctx, l, notificationManager)
9192

92-
fuego.Post(server, "/webhook/", deployController.HandleGithubWebhook)
93+
webhookGroup := fuego.Group(server, apiV1.Path+"/webhook")
94+
fuego.Post(webhookGroup, "", deployController.HandleGithubWebhook)
9395

9496
router.WebSocketServer(server, deployController)
9597

@@ -120,18 +122,16 @@ func (router *Router) Routes() {
120122
return middleware.AuditMiddleware(next, router.app, l)
121123
})
122124

123-
apiV1Group := fuego.Group(server, apiV1.Path)
124-
125125
authProtectedGroup := fuego.Group(server, apiV1.Path+"/auth")
126126
router.AuthenticatedAuthRoutes(authProtectedGroup, authController)
127127

128128
userController := user.NewUserController(router.app.Store, router.app.Ctx, l)
129-
userGroup := fuego.Group(apiV1Group, "/user")
129+
userGroup := fuego.Group(server, apiV1.Path+"/user")
130130
router.UserRoutes(userGroup, userController)
131131

132132
domainController := domain.NewDomainsController(router.app.Store, router.app.Ctx, l, notificationManager)
133-
domainGroup := fuego.Group(apiV1Group, "/domain")
134-
domainsAllGroup := fuego.Group(apiV1Group, "/domains")
133+
domainGroup := fuego.Group(server, apiV1.Path+"/domain")
134+
domainsAllGroup := fuego.Group(server, apiV1.Path+"/domains")
135135
fuego.Use(domainGroup, func(next http.Handler) http.Handler {
136136
return middleware.RBACMiddleware(next, router.app, "domain")
137137
})
@@ -141,49 +141,49 @@ func (router *Router) Routes() {
141141
router.DomainRoutes(domainGroup, domainsAllGroup, domainController)
142142

143143
githubConnectorController := githubConnector.NewGithubConnectorController(router.app.Store, router.app.Ctx, l, notificationManager)
144-
githubConnectorGroup := fuego.Group(apiV1Group, "/github-connector")
144+
githubConnectorGroup := fuego.Group(server, apiV1.Path+"/github-connector")
145145
fuego.Use(githubConnectorGroup, func(next http.Handler) http.Handler {
146146
return middleware.RBACMiddleware(next, router.app, "github-connector")
147147
})
148148
router.GithubConnectorRoutes(githubConnectorGroup, githubConnectorController)
149149

150150
notifController := notificationController.NewNotificationController(router.app.Store, router.app.Ctx, l, notificationManager)
151-
notificationGroup := fuego.Group(apiV1Group, "/notification")
151+
notificationGroup := fuego.Group(server, apiV1.Path+"/notification")
152152
fuego.Use(notificationGroup, func(next http.Handler) http.Handler {
153153
return middleware.RBACMiddleware(next, router.app, "notification")
154154
})
155155
router.NotificationRoutes(notificationGroup, notifController)
156156

157157
organizationController := organization.NewOrganizationsController(router.app.Store, router.app.Ctx, l, notificationManager)
158-
organizationGroup := fuego.Group(apiV1Group, "/organizations")
158+
organizationGroup := fuego.Group(server, apiV1.Path+"/organizations")
159159
fuego.Use(organizationGroup, func(next http.Handler) http.Handler {
160160
return middleware.RBACMiddleware(next, router.app, "organization")
161161
})
162162
router.OrganizationRoutes(organizationGroup, organizationController)
163163

164164
fileManagerController := file_manager.NewFileManagerController(router.app.Ctx, l, notificationManager)
165-
fileManagerGroup := fuego.Group(apiV1Group, "/file-manager")
165+
fileManagerGroup := fuego.Group(server, apiV1.Path+"/file-manager")
166166
fuego.Use(fileManagerGroup, func(next http.Handler) http.Handler {
167167
return middleware.RBACMiddleware(next, router.app, "file-manager")
168168
})
169169
router.FileManagerRoutes(fileManagerGroup, fileManagerController)
170170

171-
deployGroup := fuego.Group(apiV1Group, "/deploy")
171+
deployGroup := fuego.Group(server, apiV1.Path+"/deploy")
172172
fuego.Use(deployGroup, func(next http.Handler) http.Handler {
173173
return middleware.RBACMiddleware(next, router.app, "deploy")
174174
})
175175
router.DeployRoutes(deployGroup, deployController)
176176

177177
auditController := audit.NewAuditController(router.app.Store.DB, router.app.Ctx, l)
178-
auditGroup := fuego.Group(apiV1Group, "/audit")
178+
auditGroup := fuego.Group(server, apiV1.Path+"/audit")
179179
fuego.Use(auditGroup, func(next http.Handler) http.Handler {
180180
return middleware.RBACMiddleware(next, router.app, "audit")
181181
})
182182
router.AuditRoutes(auditGroup, auditController)
183183

184184
updateService := update_service.NewUpdateService(router.app, &l, router.app.Ctx)
185185
updateController := update.NewUpdateController(updateService, &l)
186-
updateGroup := fuego.Group(apiV1Group, "/update")
186+
updateGroup := fuego.Group(server, apiV1.Path+"/update")
187187
router.UpdateRoutes(updateGroup, updateController)
188188

189189
server.Run()

docs/.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,5 @@
11
node_modules
2+
.cache
3+
dist
4+
.vitepress/dist/
5+
.vitepress/cache

0 commit comments

Comments
 (0)