Skip to content

Commit

Permalink
updated changes
Browse files Browse the repository at this point in the history
  • Loading branch information
kasyap1234 committed Apr 9, 2024
1 parent f0e3f23 commit 20b438f
Show file tree
Hide file tree
Showing 10 changed files with 41 additions and 31 deletions.
1 change: 0 additions & 1 deletion .env
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,3 @@ APP_NAME=MyApp
API_DOMAIN=myapi.example.com
WEBSITE_DOMAIN=mywebsite.example.com
DATABASE_URL=your_database_connection_url
export GIN_MODE=release
18 changes: 13 additions & 5 deletions auth/auth_handlers.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import (
"github.com/supertokens/supertokens-golang/supertokens"
)

// InitSuperTokens initializes SuperTokens with the provided configuration
func InitSuperTokens(router *gin.Engine, apiBasePath, websiteBasePath string) error {
// Initialize SuperTokens
err := supertokens.Init(supertokens.TypeInput{
Expand All @@ -35,10 +34,19 @@ func InitSuperTokens(router *gin.Engine, apiBasePath, websiteBasePath string) er

// Attach SuperTokens middleware to the router
router.Use(func(c *gin.Context) {
supertokens.Middleware(http.HandlerFunc(func(rw http.ResponseWriter, r *http.Request) {
// Your middleware logic here
})).ServeHTTP(c.Writer, c.Request)
c.Abort()
supertokens.Middleware(http.HandlerFunc(
func(rw http.ResponseWriter, r *http.Request) {
if r.Method == http.MethodPost && r.URL.Path == "/auth/signup" {
// Handle signup logic
rw.Write([]byte("Handling signup logic"))
} else if r.Method == http.MethodPost && r.URL.Path == "/auth/signin" {
// Handle signin logic
rw.Write([]byte("Handling signin logic"))
} else {
c.Next() // Proceed to the next middleware/handler
}
})).ServeHTTP(c.Writer, c.Request)
c.Abort() // Ensure that the chain is not continued unless Next is explicitly called
})

return nil
Expand Down
18 changes: 0 additions & 18 deletions collections/company_collection.go

This file was deleted.

1 change: 0 additions & 1 deletion collections/question_collection.go

This file was deleted.

Binary file modified eduhub_backend_golang
Binary file not shown.
1 change: 0 additions & 1 deletion handlers/company_handlers.go
Original file line number Diff line number Diff line change
@@ -1 +0,0 @@
package handlers
15 changes: 15 additions & 0 deletions handlers/question_handlers.go
Original file line number Diff line number Diff line change
@@ -1 +1,16 @@
package handlers

import "github.com/gin-gonic/gin"

func GetQuestions(c *gin.Context) {

}
func AddQuestion(c *gin.Context) {

}
func UpdateQuestion(c *gin.Context) {

}
func DeleteQuestion(c *gin.Context) {

}
5 changes: 0 additions & 5 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@ func main() {
log.Fatal("Error loading .env file")
}

// Create a Gin router
gin.SetMode(gin.ReleaseMode)
router := gin.New()

// Allow all origins (CORS)
Expand All @@ -35,9 +33,6 @@ func main() {
log.Fatal("Error initializing SuperTokens:", err)
}
log.Println("SuperTokens initialized")
router.POST("/auth/signup")
router.POST("/auth/signin")

// Start the server
router.Run(":8080")
}
5 changes: 5 additions & 0 deletions models/company.go
Original file line number Diff line number Diff line change
@@ -1 +1,6 @@
package model

type Company struct {
Name string `json: "name" bson : "name"`
Url string `json: "Url" bson: "url"`
}
8 changes: 8 additions & 0 deletions models/question.go
Original file line number Diff line number Diff line change
@@ -1 +1,9 @@
package model

type Question struct {
QuetionID string `json: "questionID" bson :"questionID"`
Company Company `json : "company" bson: "company"`
Title string `json: "Title" bson: "Title"`
Text string `json: "Text" bson: "Text"`
Answer string `json: "Answer" bson: "Answer"`
}

0 comments on commit 20b438f

Please sign in to comment.