Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions .github/workflows/docker-deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
on:
push:
branches:
- main
- dev
pull_request:
branches:
- main
- dev
jobs:
deploy:
runs-on: ubuntu-latest
steps:

# indhu yen nu therla
- name: Checkout Code
uses: actions/checkout@v3

- name: Login to Docker Hub
run: echo "${{ secrets.DOCKERHUB_PASSWORD }}" | docker login -u "${{ secrets.DOCKERHUB_USERNAME }}" --password-stdin

- name: Build Docker Image for Auth service
run: docker build -t muruga21/auth-service -f Dockerfile.auth .

- name: Push Docker Image of Auth Service
run: docker push muruga21/auth-service
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
.env
/.env
18 changes: 18 additions & 0 deletions .vscode/c_cpp_properties.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"configurations": [
{
"name": "linux-gcc-x64",
"includePath": [
"${workspaceFolder}/**"
],
"compilerPath": "/usr/bin/gcc",
"cStandard": "${default}",
"cppStandard": "${default}",
"intelliSenseMode": "linux-gcc-x64",
"compilerArgs": [
""
]
}
],
"version": 4
}
24 changes: 24 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{
"version": "0.2.0",
"configurations": [
{
"name": "C/C++ Runner: Debug Session",
"type": "cppdbg",
"request": "launch",
"args": [],
"stopAtEntry": false,
"externalConsole": false,
"cwd": "/home/muruga/muruga/letstry/neighborly/neighbourly",
"program": "/home/muruga/muruga/letstry/neighborly/neighbourly/build/Debug/outDebug",
"MIMode": "gdb",
"miDebuggerPath": "gdb",
"setupCommands": [
{
"description": "Enable pretty-printing for gdb",
"text": "-enable-pretty-printing",
"ignoreFailures": true
}
]
}
]
}
59 changes: 59 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
{
"C_Cpp_Runner.cCompilerPath": "gcc",
"C_Cpp_Runner.cppCompilerPath": "g++",
"C_Cpp_Runner.debuggerPath": "gdb",
"C_Cpp_Runner.cStandard": "",
"C_Cpp_Runner.cppStandard": "",
"C_Cpp_Runner.msvcBatchPath": "C:/Program Files/Microsoft Visual Studio/VR_NR/Community/VC/Auxiliary/Build/vcvarsall.bat",
"C_Cpp_Runner.useMsvc": false,
"C_Cpp_Runner.warnings": [
"-Wall",
"-Wextra",
"-Wpedantic",
"-Wshadow",
"-Wformat=2",
"-Wcast-align",
"-Wconversion",
"-Wsign-conversion",
"-Wnull-dereference"
],
"C_Cpp_Runner.msvcWarnings": [
"/W4",
"/permissive-",
"/w14242",
"/w14287",
"/w14296",
"/w14311",
"/w14826",
"/w44062",
"/w44242",
"/w14905",
"/w14906",
"/w14263",
"/w44265",
"/w14928"
],
"C_Cpp_Runner.enableWarnings": true,
"C_Cpp_Runner.warningsAsError": false,
"C_Cpp_Runner.compilerArgs": [],
"C_Cpp_Runner.linkerArgs": [],
"C_Cpp_Runner.includePaths": [],
"C_Cpp_Runner.includeSearch": [
"*",
"**/*"
],
"C_Cpp_Runner.excludeSearch": [
"**/build",
"**/build/**",
"**/.*",
"**/.*/**",
"**/.vscode",
"**/.vscode/**"
],
"C_Cpp_Runner.useAddressSanitizer": false,
"C_Cpp_Runner.useUndefinedSanitizer": false,
"C_Cpp_Runner.useLeakSanitizer": false,
"C_Cpp_Runner.showCompilationTime": false,
"C_Cpp_Runner.useLinkTimeOptimization": false,
"C_Cpp_Runner.msvcSecureNoWarnings": false
}
18 changes: 18 additions & 0 deletions Dockerfile.auth
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
FROM golang:1.24.1 AS builder

WORKDIR /app

COPY go.mod go.sum ./
RUN go mod tidy

COPY . .

RUN CGO_ENABLED=0 GOOS=linux go build -o auth-service ./cmd/auth

#production
FROM alpine:latest
WORKDIR /root

COPY --from=builder /app/auth-service .
EXPOSE 5000
CMD [ "./auth-service" ]
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
# neighbourly
# neighbourly


1 change: 0 additions & 1 deletion backend/config/DatabaseSetup.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ func ConnectDB() error {
log.Fatal(err)
return err
}

ctx, cancel = context.WithTimeout(context.Background(), 5*time.Second)
defer cancel()
err = Client.Ping(ctx, readpref.Primary())
Expand Down
2 changes: 2 additions & 0 deletions backend/controllers/serviceProvider.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ type Service struct {
Time string `json:"time"`
Description string `json:"description"`
Status string `json:"status"`
Seekername string `json:"seekername"`
Seekerphone string `json:"Seekerphone"`
}

func ViewServices (c * gin.Context){
Expand Down
1 change: 1 addition & 0 deletions backend/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ require (
github.com/xdg-go/pbkdf2 v1.0.0 // indirect
github.com/xdg-go/scram v1.1.2 // indirect
github.com/xdg-go/stringprep v1.0.4 // indirect
github.com/yelinaung/eng-name v0.0.0-20141214053408-d6af0256d2c0 // indirect
github.com/youmark/pkcs8 v0.0.0-20181117223130-1be2e3e5546d // indirect
golang.org/x/arch v0.8.0 // indirect
golang.org/x/crypto v0.23.0 // indirect
Expand Down
2 changes: 2 additions & 0 deletions backend/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,8 @@ github.com/xdg-go/scram v1.1.2 h1:FHX5I5B4i4hKRVRBCFRxq1iQRej7WO3hhBuJf+UUySY=
github.com/xdg-go/scram v1.1.2/go.mod h1:RT/sEzTbU5y00aCK8UOx6R7YryM0iF1N2MOmC3kKLN4=
github.com/xdg-go/stringprep v1.0.4 h1:XLI/Ng3O1Atzq0oBs3TWm+5ZVgkq2aqdlvP9JtoZ6c8=
github.com/xdg-go/stringprep v1.0.4/go.mod h1:mPGuuIYwz7CmR2bT9j4GbQqutWS1zV24gijq1dTyGkM=
github.com/yelinaung/eng-name v0.0.0-20141214053408-d6af0256d2c0 h1:ZUHUPeDkXqtVFMhwNVIrIHwJHAaXGXnvV9AYYW6xmxE=
github.com/yelinaung/eng-name v0.0.0-20141214053408-d6af0256d2c0/go.mod h1:QH/uGb7Ua5lon/ULhm9V2sYK3fwocdHPlDva927j3tU=
github.com/youmark/pkcs8 v0.0.0-20181117223130-1be2e3e5546d h1:splanxYIlg+5LfHAM6xpdFEAYOk8iySO56hMFq6uLyA=
github.com/youmark/pkcs8 v0.0.0-20181117223130-1be2e3e5546d/go.mod h1:rHwXgn7JulP+udvsHwJoVG1YGAP6VLg4y9I5dyZdqmA=
github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY=
Expand Down
12 changes: 6 additions & 6 deletions backend/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,14 @@ import (
)

func init() {
err := godotenv.Load();
err := godotenv.Load()
if err != nil {
panic("Error loading .env file");
panic("Error loading .env file")
}
fmt.Println("Environment variables loaded successfully");
fmt.Println("Environment variables loaded successfully")
}

func main() {
r := routes.SetupRouter();
r.Run();
}
r := routes.SetupRouter()
r.Run()
}
3 changes: 3 additions & 0 deletions backend/middlewares/auth.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ func AuthMiddleware() gin.HandlerFunc{
"error": true,
"message": "Authorization header is missing",
})
c.Abort();
return
}

Expand All @@ -42,6 +43,7 @@ func AuthMiddleware() gin.HandlerFunc{
"error": true,
"message": "Error decoding token: " + err.Error(),
})
c.Abort();
return
}

Expand All @@ -55,6 +57,7 @@ func AuthMiddleware() gin.HandlerFunc{
"error": true,
"message": "Invalid token",
})
c.Abort();
return
}

Expand Down
12 changes: 12 additions & 0 deletions cmd/auth/main.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package main

import (
"net/http"

"github.com/muruga21/neighbourly/internal/service"
)

func main() {
http.HandleFunc("/signup", service.HandleSignup)
http.ListenAndServe(":5000", nil)
}
Empty file added cmd/service_provider/main.go
Empty file.
21 changes: 21 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
version: '3.3'

services:
auth-services:
image: muruga21/auth-service
container_name: auth-service
ports:
- "5000:5000"
depends_on:
- redis
environment:
- REDIS_HOST=redis
- REDIS_PORT=6379

redis:
image: redis:latest
container_name: redis
restart: always
ports:
- "6379:6379"
command: ["redis-server", "--appendonly", "yes"]
9 changes: 9 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
module github.com/muruga21/neighbourly

go 1.24.1

require (
github.com/cespare/xxhash/v2 v2.2.0 // indirect
github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f // indirect
github.com/redis/go-redis/v9 v9.7.3 // indirect
)
6 changes: 6 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
github.com/cespare/xxhash/v2 v2.2.0 h1:DC2CZ1Ep5Y4k3ZQ899DldepgrayRUGE6BBZ/cd9Cj44=
github.com/cespare/xxhash/v2 v2.2.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs=
github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f h1:lO4WD4F/rVNCu3HqELle0jiPLLBs70cWOduZpkS1E78=
github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f/go.mod h1:cuUVRXasLTGF7a8hSLbxyZXjz+1KgoB3wDUb6vlszIc=
github.com/redis/go-redis/v9 v9.7.3 h1:YpPyAayJV+XErNsatSElgRZZVCwXX9QzkKYNvO7x0wM=
github.com/redis/go-redis/v9 v9.7.3/go.mod h1:bGUrSggJ9X9GUmZpZNEOQKaANxSGgOEBRltRTZHSvrA=
30 changes: 30 additions & 0 deletions internal/service/auth.service.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package service

import (
"context"
"encoding/json"
"fmt"
"net/http"

"github.com/redis/go-redis/v9"
)

func HandleSignup(w http.ResponseWriter, r *http.Request) {
client := redis.NewClient(&redis.Options{
Addr: "localhost:6379",
Password: "", // No password set
DB: 0, // Use default DB
Protocol: 2, // Connection protocol
})
ctx := context.Background()

err := client.Set(ctx, "foo", "bar", 0).Err()
if err != nil {
panic(err)
}

val, err := client.Get(ctx, "foo").Result()

fmt.Println(client)
json.NewEncoder(w).Encode(map[string]string{"error": "false", "message": val})
}
Loading