diff --git a/client_web/src/Config/backend.routes.ts b/client_web/src/Config/backend.routes.ts index f98a48e..f1165bc 100644 --- a/client_web/src/Config/backend.routes.ts +++ b/client_web/src/Config/backend.routes.ts @@ -42,9 +42,14 @@ const auth = { health: `${endpoint}/auth/health`, } +const workflow = { + create: `${endpoint}/workflow/create`, +} + export { instance, instanceWithAuth, root, - auth + auth, + workflow } diff --git a/client_web/src/Pages/Workflows/CreateWorkflow.tsx b/client_web/src/Pages/Workflows/CreateWorkflow.tsx index 415dddb..f598472 100644 --- a/client_web/src/Pages/Workflows/CreateWorkflow.tsx +++ b/client_web/src/Pages/Workflows/CreateWorkflow.tsx @@ -7,6 +7,8 @@ import { normalizeName } from "@/Pages/Workflows/CreateWorkflow.utils"; // Import types correctly import { About, Service, Action, Reaction, Workflow, Parameter } from "@/types"; import {toast} from "react-toastify"; +import {instanceWithAuth} from "@/Config/backend.routes"; +import {workflow as workflowRoute} from "@/Config/backend.routes"; const { Title, Text } = Typography; const { Panel } = Collapse; @@ -238,43 +240,59 @@ const CreateWorkflow: React.FC = () => { const workflow: Workflow = { name: workflowName, description: workflowDescription, - actions: selectedActions.map(action => { - const actionDef = about?.server.services + service: about?.server.services.find(service => + service.actions.some(action => action.name === selectedActions[0]?.name) + )?.name ?? "unknown", + events: + [ + ...selectedActions.map(action => { + const actionDef = about?.server.services .flatMap((s: Service) => s.actions) .find((a: Action) => a.name === action.name); - return { - name: action.name, - parameters: Object.entries(action.parameters || {}).map(([name, value]) => { - const paramDef = actionDef?.parameters.find((p: Parameter) => p.name === name); - return { - name, - type: paramDef?.type || 'string', - value - }; - }) - }; - }), - reactions: selectedReactions.map(reaction => { - const reactionDef = about?.server.services - .flatMap((s: Service) => s.reactions) - .find((r: Reaction) => r.name === reaction.name); - - return { - name: reaction.name, - parameters: Object.entries(reaction.parameters || {}).map(([name, value]) => { - const paramDef = reactionDef?.parameters.find((p: Parameter) => p.name === name); - return { - name, - type: paramDef?.type || 'string', - value - }; - }) - }; + return { + name: action.name, + type: 'action' as "action", + description: action.description, + parameters: Object.entries(action.parameters || {}).map(([name, value]) => { + const paramDef = actionDef?.parameters.find((p: Parameter) => p.name === name); + return { + name, + type: paramDef?.type || 'string', + value + }; + }) + } + }), + ...selectedReactions.map(reaction => { + const reactionDef = about?.server.services + .flatMap((s: Service) => s.reactions) + .find((r: Reaction) => r.name === reaction.name); + + return { + name: reaction.name, + type: 'reaction' as "reaction", + description: reaction.description, + parameters: Object.entries(reaction.parameters || {}).map(([name, value]) => { + const paramDef = reactionDef?.parameters.find((p: Parameter) => p.name === name); + return { + name, + type: paramDef?.type || 'string', + value + }; + }) + }; + }) + ] + } + instanceWithAuth.post(workflowRoute.create, workflow) + .then(() => { + toast.success("Workflow successfully published") + //TODO: Go to /workflow/{id} }) - }; - - toast.error("API not connected yet"); + .catch((error) => { + console.error(error); + }); }; const handleFoldAllActions = () => { diff --git a/client_web/src/types.ts b/client_web/src/types.ts index c550305..8965467 100644 --- a/client_web/src/types.ts +++ b/client_web/src/types.ts @@ -46,22 +46,16 @@ export interface WorkflowParameter { export interface WorkflowDefinition { name: string; + type: "action" | "reaction"; + description: string; parameters: WorkflowParameter[]; } -export interface WorkflowAction extends WorkflowDefinition { - -} - -export interface WorkflowReaction extends WorkflowDefinition { - -} - export type Workflow = { name: string; + service: string; description: string; - actions: WorkflowAction[]; - reactions: WorkflowReaction[]; + events: WorkflowDefinition[]; }; export interface WorkflowItem { diff --git a/server/config.json b/server/config.json index a2a0f5c..e145ef1 100644 --- a/server/config.json +++ b/server/config.json @@ -6,6 +6,6 @@ "swagger": true, "cors_origins": [ "https://localhost:8081", - "http://example.com" + "http://localhost:8080" ] } diff --git a/server/docs/docs.go b/server/docs/docs.go index f4d5647..e414698 100644 --- a/server/docs/docs.go +++ b/server/docs/docs.go @@ -47,11 +47,46 @@ const docTemplate = `{ } } }, - "/login": { + "/auth/health": { + "get": { + "description": "Validate the token and return 200 if valid, 401 if expired or invalid", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "auth" + ], + "summary": "Check if the JWT is valid", + "responses": { + "200": { + "description": "OK", + "schema": { + "type": "object", + "additionalProperties": { + "type": "string" + } + } + }, + "401": { + "description": "Unauthorized", + "schema": { + "type": "object", + "additionalProperties": { + "type": "string" + } + } + } + } + } + }, + "/auth/login": { "post": { "description": "Authenticate a user and return a JWT token", "consumes": [ - "application/x-www-form-urlencoded" + "application/json" ], "produces": [ "application/json" @@ -62,18 +97,13 @@ const docTemplate = `{ "summary": "Login a user", "parameters": [ { - "type": "string", - "description": "Email", - "name": "email", - "in": "formData", - "required": true - }, - { - "type": "string", - "description": "Password", - "name": "password", - "in": "formData", - "required": true + "description": "Login", + "name": "Login", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/models.LoginRequest" + } } ], "responses": { @@ -98,6 +128,61 @@ const docTemplate = `{ } } }, + "/auth/register": { + "post": { + "description": "Create a new user and return a JWT token", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "auth" + ], + "summary": "Register a user", + "parameters": [ + { + "description": "Register", + "name": "Register", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/models.RegisterRequest" + } + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "type": "object", + "additionalProperties": { + "type": "string" + } + } + }, + "409": { + "description": "Conflict", + "schema": { + "type": "object", + "additionalProperties": { + "type": "string" + } + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "type": "object", + "additionalProperties": { + "type": "string" + } + } + } + } + } + }, "/ping": { "get": { "description": "ping", @@ -153,39 +238,68 @@ const docTemplate = `{ } } }, - "/register": { + "/workflow/create": { "post": { - "description": "Create a new user and return a JWT token", + "description": "Create a new workflow", "consumes": [ - "application/x-www-form-urlencoded" + "application/json" ], "produces": [ "application/json" ], "tags": [ - "auth" + "workflow" ], - "summary": "Register a user", + "summary": "Create a workflow", "parameters": [ { - "type": "string", - "description": "Email", - "name": "email", - "in": "formData", - "required": true - }, - { - "type": "string", - "description": "Username", - "name": "username", - "in": "formData", - "required": true + "description": "workflow", + "name": "workflow", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/models.Workflow" + } + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/models.Workflow" + } }, + "400": { + "description": "Bad Request", + "schema": { + "type": "object", + "additionalProperties": { + "type": "string" + } + } + } + } + } + }, + "/workflow/delete/{id}": { + "delete": { + "description": "Delete a workflow by ID", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "workflow" + ], + "summary": "Delete a workflow", + "parameters": [ { - "type": "string", - "description": "Password", - "name": "password", - "in": "formData", + "type": "integer", + "description": "workflow ID", + "name": "id", + "in": "path", "required": true } ], @@ -199,8 +313,17 @@ const docTemplate = `{ } } }, - "409": { - "description": "Conflict", + "400": { + "description": "Bad Request", + "schema": { + "type": "object", + "additionalProperties": { + "type": "string" + } + } + }, + "404": { + "description": "Not Found", "schema": { "type": "object", "additionalProperties": { @@ -219,6 +342,71 @@ const docTemplate = `{ } } } + }, + "/workflow/list": { + "get": { + "description": "List all workflows", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "workflow" + ], + "summary": "List workflows", + "responses": { + "200": { + "description": "OK", + "schema": { + "type": "array", + "items": { + "$ref": "#/definitions/models.Workflow" + } + } + } + } + } + } + }, + "definitions": { + "models.LoginRequest": { + "type": "object", + "required": [ + "email", + "password" + ], + "properties": { + "email": { + "type": "string" + }, + "password": { + "type": "string" + } + } + }, + "models.RegisterRequest": { + "type": "object", + "required": [ + "email", + "password", + "username" + ], + "properties": { + "email": { + "type": "string" + }, + "password": { + "type": "string" + }, + "username": { + "type": "string" + } + } + }, + "models.Workflow": { + "type": "object" } } }` diff --git a/server/docs/swagger.json b/server/docs/swagger.json index 006df19..6befab3 100644 --- a/server/docs/swagger.json +++ b/server/docs/swagger.json @@ -41,11 +41,46 @@ } } }, - "/login": { + "/auth/health": { + "get": { + "description": "Validate the token and return 200 if valid, 401 if expired or invalid", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "auth" + ], + "summary": "Check if the JWT is valid", + "responses": { + "200": { + "description": "OK", + "schema": { + "type": "object", + "additionalProperties": { + "type": "string" + } + } + }, + "401": { + "description": "Unauthorized", + "schema": { + "type": "object", + "additionalProperties": { + "type": "string" + } + } + } + } + } + }, + "/auth/login": { "post": { "description": "Authenticate a user and return a JWT token", "consumes": [ - "application/x-www-form-urlencoded" + "application/json" ], "produces": [ "application/json" @@ -56,18 +91,13 @@ "summary": "Login a user", "parameters": [ { - "type": "string", - "description": "Email", - "name": "email", - "in": "formData", - "required": true - }, - { - "type": "string", - "description": "Password", - "name": "password", - "in": "formData", - "required": true + "description": "Login", + "name": "Login", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/models.LoginRequest" + } } ], "responses": { @@ -92,6 +122,61 @@ } } }, + "/auth/register": { + "post": { + "description": "Create a new user and return a JWT token", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "auth" + ], + "summary": "Register a user", + "parameters": [ + { + "description": "Register", + "name": "Register", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/models.RegisterRequest" + } + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "type": "object", + "additionalProperties": { + "type": "string" + } + } + }, + "409": { + "description": "Conflict", + "schema": { + "type": "object", + "additionalProperties": { + "type": "string" + } + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "type": "object", + "additionalProperties": { + "type": "string" + } + } + } + } + } + }, "/ping": { "get": { "description": "ping", @@ -147,39 +232,68 @@ } } }, - "/register": { + "/workflow/create": { "post": { - "description": "Create a new user and return a JWT token", + "description": "Create a new workflow", "consumes": [ - "application/x-www-form-urlencoded" + "application/json" ], "produces": [ "application/json" ], "tags": [ - "auth" + "workflow" ], - "summary": "Register a user", + "summary": "Create a workflow", "parameters": [ { - "type": "string", - "description": "Email", - "name": "email", - "in": "formData", - "required": true - }, - { - "type": "string", - "description": "Username", - "name": "username", - "in": "formData", - "required": true + "description": "workflow", + "name": "workflow", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/models.Workflow" + } + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/models.Workflow" + } }, + "400": { + "description": "Bad Request", + "schema": { + "type": "object", + "additionalProperties": { + "type": "string" + } + } + } + } + } + }, + "/workflow/delete/{id}": { + "delete": { + "description": "Delete a workflow by ID", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "workflow" + ], + "summary": "Delete a workflow", + "parameters": [ { - "type": "string", - "description": "Password", - "name": "password", - "in": "formData", + "type": "integer", + "description": "workflow ID", + "name": "id", + "in": "path", "required": true } ], @@ -193,8 +307,17 @@ } } }, - "409": { - "description": "Conflict", + "400": { + "description": "Bad Request", + "schema": { + "type": "object", + "additionalProperties": { + "type": "string" + } + } + }, + "404": { + "description": "Not Found", "schema": { "type": "object", "additionalProperties": { @@ -213,6 +336,71 @@ } } } + }, + "/workflow/list": { + "get": { + "description": "List all workflows", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "workflow" + ], + "summary": "List workflows", + "responses": { + "200": { + "description": "OK", + "schema": { + "type": "array", + "items": { + "$ref": "#/definitions/models.Workflow" + } + } + } + } + } + } + }, + "definitions": { + "models.LoginRequest": { + "type": "object", + "required": [ + "email", + "password" + ], + "properties": { + "email": { + "type": "string" + }, + "password": { + "type": "string" + } + } + }, + "models.RegisterRequest": { + "type": "object", + "required": [ + "email", + "password", + "username" + ], + "properties": { + "email": { + "type": "string" + }, + "password": { + "type": "string" + }, + "username": { + "type": "string" + } + } + }, + "models.Workflow": { + "type": "object" } } } \ No newline at end of file diff --git a/server/docs/swagger.yaml b/server/docs/swagger.yaml index 4b9c056..4c7f76c 100644 --- a/server/docs/swagger.yaml +++ b/server/docs/swagger.yaml @@ -1,4 +1,30 @@ basePath: / +definitions: + models.LoginRequest: + properties: + email: + type: string + password: + type: string + required: + - email + - password + type: object + models.RegisterRequest: + properties: + email: + type: string + password: + type: string + username: + type: string + required: + - email + - password + - username + type: object + models.Workflow: + type: object host: localhost:8080 info: contact: @@ -28,22 +54,41 @@ paths: summary: About tags: - about - /login: + /auth/health: + get: + consumes: + - application/json + description: Validate the token and return 200 if valid, 401 if expired or invalid + produces: + - application/json + responses: + "200": + description: OK + schema: + additionalProperties: + type: string + type: object + "401": + description: Unauthorized + schema: + additionalProperties: + type: string + type: object + summary: Check if the JWT is valid + tags: + - auth + /auth/login: post: consumes: - - application/x-www-form-urlencoded + - application/json description: Authenticate a user and return a JWT token parameters: - - description: Email - in: formData - name: email - required: true - type: string - - description: Password - in: formData - name: password + - description: Login + in: body + name: Login required: true - type: string + schema: + $ref: '#/definitions/models.LoginRequest' produces: - application/json responses: @@ -62,6 +107,42 @@ paths: summary: Login a user tags: - auth + /auth/register: + post: + consumes: + - application/json + description: Create a new user and return a JWT token + parameters: + - description: Register + in: body + name: Register + required: true + schema: + $ref: '#/definitions/models.RegisterRequest' + produces: + - application/json + responses: + "200": + description: OK + schema: + additionalProperties: + type: string + type: object + "409": + description: Conflict + schema: + additionalProperties: + type: string + type: object + "500": + description: Internal Server Error + schema: + additionalProperties: + type: string + type: object + summary: Register a user + tags: + - auth /ping: get: consumes: @@ -98,27 +179,45 @@ paths: summary: Message tags: - publish/Message - /register: + /workflow/create: post: consumes: - - application/x-www-form-urlencoded - description: Create a new user and return a JWT token + - application/json + description: Create a new workflow parameters: - - description: Email - in: formData - name: email + - description: workflow + in: body + name: workflow required: true - type: string - - description: Username - in: formData - name: username - required: true - type: string - - description: Password - in: formData - name: password + schema: + $ref: '#/definitions/models.Workflow' + produces: + - application/json + responses: + "200": + description: OK + schema: + $ref: '#/definitions/models.Workflow' + "400": + description: Bad Request + schema: + additionalProperties: + type: string + type: object + summary: Create a workflow + tags: + - workflow + /workflow/delete/{id}: + delete: + consumes: + - application/json + description: Delete a workflow by ID + parameters: + - description: workflow ID + in: path + name: id required: true - type: string + type: integer produces: - application/json responses: @@ -128,8 +227,14 @@ paths: additionalProperties: type: string type: object - "409": - description: Conflict + "400": + description: Bad Request + schema: + additionalProperties: + type: string + type: object + "404": + description: Not Found schema: additionalProperties: type: string @@ -140,7 +245,24 @@ paths: additionalProperties: type: string type: object - summary: Register a user + summary: Delete a workflow tags: - - auth + - workflow + /workflow/list: + get: + consumes: + - application/json + description: List all workflows + produces: + - application/json + responses: + "200": + description: OK + schema: + items: + $ref: '#/definitions/models.Workflow' + type: array + summary: List workflows + tags: + - workflow swagger: "2.0" diff --git a/server/internal/controllers/auth.go b/server/internal/controllers/auth.go index 83b9488..61acd6e 100644 --- a/server/internal/controllers/auth.go +++ b/server/internal/controllers/auth.go @@ -2,7 +2,7 @@ package controllers import ( "AREA/internal/models" - "AREA/internal/pkg" + db "AREA/internal/pkg" "AREA/internal/utils" "github.com/gin-gonic/gin" "log" @@ -13,13 +13,12 @@ import ( // @Summary Login a user // @Description Authenticate a user and return a JWT token // @Tags auth -// @Accept x-www-form-urlencoded +// @Accept json // @Produce json -// @Param email json string true "email" -// @Param password json string true "password" +// @Param Login body models.LoginRequest true "Login" // @Success 200 {object} map[string]string // @Failure 401 {object} map[string]string -// @Router /login [post] +// @Router /auth/login [post] func Login(c *gin.Context) { var LoginData models.LoginRequest err := c.ShouldBindJSON(&LoginData) @@ -48,15 +47,13 @@ func Login(c *gin.Context) { // @Summary Register a user // @Description Create a new user and return a JWT token // @Tags auth -// @Accept x-www-form-urlencoded +// @Accept json // @Produce json -// @Param email json string true "email" -// @Param username json string true "username" -// @Param password json string true "password" +// @Param Register body models.RegisterRequest true "Register" // @Success 200 {object} map[string]string // @Failure 409 {object} map[string]string // @Failure 500 {object} map[string]string -// @Router /register [post] +// @Router /auth/register [post] func Register(c *gin.Context) { var RegisterData models.RegisterRequest err := c.ShouldBindJSON(&RegisterData) diff --git a/server/internal/controllers/workflow.go b/server/internal/controllers/workflow.go new file mode 100644 index 0000000..fe6ef79 --- /dev/null +++ b/server/internal/controllers/workflow.go @@ -0,0 +1,85 @@ +package controllers + +import ( + "AREA/internal/models" + "AREA/internal/pkg" + "github.com/gin-gonic/gin" + "net/http" + "strconv" +) + +// WorkflowCreate godoc +// @Summary Create a workflow +// @Description Create a new workflow +// @Tags workflow +// @Accept json +// @Produce json +// @Param workflow body models.Workflow true "workflow" +// @Success 200 {object} models.Workflow +// @Failure 400 {object} map[string]string +// @Router /workflow/create [post] +func WorkflowCreate(c *gin.Context) { + var workflow models.Workflow + err := c.BindJSON(&workflow) + if err != nil { + c.JSON(400, gin.H{"error": err.Error()}) + return + } + workflow.UserID, err = pkg.GetUserFromToken(c) + if err != nil { + return + } + pkg.DB.Create(&workflow) + c.JSON(200, gin.H{"workflow": workflow}) +} + +// WorkflowList godoc +// @Summary List workflows +// @Description List all workflows +// @Tags workflow +// @Accept json +// @Produce json +// @Success 200 {object} []models.Workflow +// @Router /workflow/list [get] +func WorkflowList(c *gin.Context) { + var workflows []models.Workflow + userID, err := pkg.GetUserFromToken(c) + if err != nil { + return + } + pkg.DB.Where("user_id = ?", userID).Find(&workflows) + c.JSON(200, gin.H{"workflows": workflows}) +} + +// WorkflowDelete godoc +// @Summary Delete a workflow +// @Description Delete a workflow by ID +// @Tags workflow +// @Accept json +// @Produce json +// @Param id path int true "workflow ID" +// @Success 200 {object} map[string]string +// @Failure 400 {object} map[string]string +// @Failure 404 {object} map[string]string +// @Failure 500 {object} map[string]string +// @Router /workflow/delete/{id} [delete] +func WorkflowDelete(c *gin.Context) { + idParam := c.Param("id") + workflowID, err := strconv.Atoi(idParam) + if err != nil { + c.JSON(http.StatusBadRequest, gin.H{"error": "Invalid workflow ID"}) + return + } + var workflow models.Workflow + result := pkg.DB.First(&workflow, workflowID) + if result.Error != nil { + c.JSON(http.StatusNotFound, gin.H{"error": "Workflow not found"}) + return + } + result = pkg.DB.Delete(&workflow) + if result.Error != nil { + c.JSON(http.StatusInternalServerError, gin.H{"error": "Failed to delete workflow"}) + return + } + c.JSON(http.StatusOK, gin.H{"message": "Workflow deleted successfully"}) +} diff --git a/server/internal/models/workflow.go b/server/internal/models/workflow.go index 7657e13..8cdc29c 100644 --- a/server/internal/models/workflow.go +++ b/server/internal/models/workflow.go @@ -23,5 +23,14 @@ type Workflow struct { Name string `json:"name"` Description string `json:"description"` Status WorkflowStatus `gorm:"type:enum('pending', 'processed', 'failed')" json:"status"` + IsActive bool `json:"is_active"` Events []Event `gorm:"many2many:workflow_events" json:"events"` } + +func (w *Workflow) BeforeCreate(tx *gorm.DB) (err error) { + if w.Status == "" { + w.Status = WorkflowStatusPending + } + w.IsActive = true + return +} diff --git a/server/internal/pkg/db.go b/server/internal/pkg/db.go index 8bc06d2..47f6b1e 100644 --- a/server/internal/pkg/db.go +++ b/server/internal/pkg/db.go @@ -1,4 +1,4 @@ -package db +package pkg import ( "AREA/internal/models" diff --git a/server/internal/pkg/request.go b/server/internal/pkg/request.go new file mode 100644 index 0000000..5a326ca --- /dev/null +++ b/server/internal/pkg/request.go @@ -0,0 +1,19 @@ +package pkg + +import ( + "bytes" + "fmt" + "github.com/gin-gonic/gin" + "io" +) + +func PrintRequestJSON(c *gin.Context) { + var requestBody bytes.Buffer + _, err := io.Copy(&requestBody, c.Request.Body) + if err != nil { + c.JSON(500, gin.H{"error": "Failed to read request body"}) + return + } + fmt.Println("Request JSON:", requestBody.String()) + c.Request.Body = io.NopCloser(bytes.NewBuffer(requestBody.Bytes())) +} diff --git a/server/internal/pkg/token.go b/server/internal/pkg/token.go new file mode 100644 index 0000000..1767c74 --- /dev/null +++ b/server/internal/pkg/token.go @@ -0,0 +1,21 @@ +package pkg + +import ( + "AREA/internal/models" + "AREA/internal/utils" + "errors" + "github.com/gin-gonic/gin" +) + +func GetUserFromToken(c *gin.Context) (uint, error) { + email, err := utils.VerifyToken(c) + if err != nil { + return 0, err + } + user := models.User{} + DB.Where("email = ?", email).First(&user) + if user.ID == 0 { + return 0, errors.New("User not found") + } + return user.ID, nil +} diff --git a/server/internal/routers/routers.go b/server/internal/routers/routers.go index 4ea5f34..2536527 100644 --- a/server/internal/routers/routers.go +++ b/server/internal/routers/routers.go @@ -32,6 +32,16 @@ func setUpAuthGroup(router *gin.Engine) { } } +func setUpWorkflowGroup(router *gin.Engine) { + workflow := router.Group("/workflow") + workflow.Use(middleware.AuthMiddleware()) + { + workflow.POST("/create", controllers.WorkflowCreate) + workflow.GET("/list", controllers.WorkflowList) + workflow.DELETE("/delete/:id", controllers.WorkflowDelete) + } +} + func SetupRouter() *gin.Engine { router := gin.Default() router.Use(middleware.ErrorHandlerMiddleware()) @@ -48,6 +58,7 @@ func SetupRouter() *gin.Engine { } setUpAuthGroup(router) setUpOauthGroup(router) + setUpWorkflowGroup(router) protected := router.Group("/") protected.Use(middleware.AuthMiddleware()) { diff --git a/server/main.go b/server/main.go index 5fe61e5..bfb0bef 100644 --- a/server/main.go +++ b/server/main.go @@ -3,7 +3,7 @@ package main import ( "AREA/internal/config" "AREA/internal/models" - "AREA/internal/pkg" + db "AREA/internal/pkg" "AREA/internal/routers" "fmt" "github.com/gin-gonic/gin"