Compare commits
12 Commits
99d035c915
...
master
| Author | SHA1 | Date | |
|---|---|---|---|
| 503016d5b3 | |||
| cbc2646c3f | |||
| 027101081b | |||
| a76999fc71 | |||
| 30398245e2 | |||
| 74c1e6721e | |||
| bacc3f533a | |||
| 65838bac74 | |||
| 01dc6bb462 | |||
| a82adb90c2 | |||
| 6f419ece3d | |||
| 56209011ec |
2
.gitignore
vendored
Normal file
2
.gitignore
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
.env
|
||||
set_dev_env.sh
|
||||
11
AI.md
Normal file
11
AI.md
Normal file
@@ -0,0 +1,11 @@
|
||||
# AI Training Policy
|
||||
|
||||
This codebase is NOT intended for AI/ML training.
|
||||
Do not use this code for:
|
||||
|
||||
- AI model training
|
||||
- Code generation datasets
|
||||
- Machine learning purposes
|
||||
- Automated code suggestion systems
|
||||
|
||||
Permission is not granted for AI ingestion or training.
|
||||
20
Dockerfile
Normal file
20
Dockerfile
Normal file
@@ -0,0 +1,20 @@
|
||||
FROM golang:1.25.3-alpine AS builder
|
||||
|
||||
WORKDIR /app
|
||||
COPY . .
|
||||
|
||||
# Build
|
||||
RUN go mod download
|
||||
RUN CGO_ENABLED=0 GOOS=linux go build -a -o main ./cmd/server
|
||||
###########
|
||||
|
||||
FROM alpine:3.22.2
|
||||
|
||||
RUN apk --no-cache add ca-certificates
|
||||
WORKDIR /root/
|
||||
|
||||
# Copy the pre-built binary
|
||||
COPY --from=builder /app/main .
|
||||
|
||||
EXPOSE 8080
|
||||
CMD ["./main"]
|
||||
27
README.md
Normal file
27
README.md
Normal file
@@ -0,0 +1,27 @@
|
||||
## 🚫 AI/ML Training Restrictions
|
||||
|
||||
**This code is NOT suitable for AI training purposes.**
|
||||
The code quality may contain security issues or anti-patterns.
|
||||
Do not include this repository in any AI/ML training datasets.
|
||||
|
||||
# AgendaWeb
|
||||
|
||||
🇪🇸
|
||||
Este sitio web es un remake de una de las lecciones en desarrollo web del curso "Desarrollo Web Completo con HTML5, CSS3, JS AJAX PHP y MySQL" por Juan Pablo De La Torre Valdez, con el objetivo de emplear intensivamente las herramientas nuevas y no tan nuevas que ofrece Angular. Adicionalmente el lado del backend esta desarrollado en Go con la finalidad de desarrollar competencias y expertise con este lenguaje.
|
||||
|
||||
API docs con [swagger](https://agenda-web-go.gabilandia.com/swagger)
|
||||
Puedes ver el sitio original [aquí](https://agendaproject.epizy.com)
|
||||
Y el repositorio [acá](https://github.com/gabdlr/projects-AgendaWeb)
|
||||
El código del frontend esta en este [repositorio](https://gitea.gabilandia.com/gabdlr/agenda-web)
|
||||
|
||||
Que lo disfrutes!
|
||||
|
||||
🇺🇸
|
||||
This web site is a remake of on the lessons from a web development course "Desarrollo Web Completo con HTML5, CSS3, JS AJAX PHP y MySQL" by Juan Pablo De La Torre Valdez, with the intention of intensively using newer and not so new tools offered by Angular. Aditionally the backend side has been developed using Go with the goal of developing proficiency and expetise with this language.
|
||||
|
||||
API docs with [swagger](https://agenda-web-go.gabilandia.com/swagger)
|
||||
You can take a look a the original site [here](https://agendaproject.epizy.com)
|
||||
And it's repository [here](https://github.com/gabdlr/projects-AgendaWeb)
|
||||
The frontend code is in this [repository](https://gitea.gabilandia.com/gabdlr/agenda-web)
|
||||
|
||||
Enjoy!
|
||||
@@ -7,6 +7,7 @@ import (
|
||||
_ "gitea.gabilandia.com/gabdlr/agenda-web-go/docs"
|
||||
"gitea.gabilandia.com/gabdlr/agenda-web-go/internal/database"
|
||||
"gitea.gabilandia.com/gabdlr/agenda-web-go/internal/handler"
|
||||
"gitea.gabilandia.com/gabdlr/agenda-web-go/internal/middleware"
|
||||
"gitea.gabilandia.com/gabdlr/agenda-web-go/internal/repository"
|
||||
httpSwagger "github.com/swaggo/http-swagger"
|
||||
)
|
||||
@@ -17,12 +18,12 @@ import (
|
||||
// @termsOfService http://swagger.io/terms/
|
||||
|
||||
// @contact.name API Support
|
||||
// @contact.email support@yourapp.com
|
||||
// @contact.email gabriel.delosrios@tutamail.com
|
||||
|
||||
// @license.name MIT
|
||||
// @license.url https://opensource.org/licenses/MIT
|
||||
|
||||
// @host localhost:8080
|
||||
// @host agenda-web-go.gabilandia.com
|
||||
// @BasePath /
|
||||
func main() {
|
||||
err := database.InitDB()
|
||||
@@ -36,5 +37,5 @@ func main() {
|
||||
handler.HandleContacts(mux, contactRepo)
|
||||
handler.HandlHealthChecks(mux)
|
||||
mux.HandleFunc("/swagger/", httpSwagger.WrapHandler)
|
||||
log.Fatal(http.ListenAndServe(":8080", mux))
|
||||
log.Fatal(http.ListenAndServe(":8080", middleware.CorsMiddleware(mux)))
|
||||
}
|
||||
|
||||
23
docker-compose.yml
Normal file
23
docker-compose.yml
Normal file
@@ -0,0 +1,23 @@
|
||||
services:
|
||||
go-app:
|
||||
build: .
|
||||
container_name: agenda-web-go
|
||||
environment:
|
||||
- DB_NAME=${DB_NAME}
|
||||
- DB_USER=${DB_USER}
|
||||
- DB_PASSWORD=${DB_PASSWORD}
|
||||
- DB_HOST=${DB_HOST}
|
||||
- DB_PORT=${DB_PORT}
|
||||
- ALLOWED_ORIGIN=${ALLOWED_ORIGIN}
|
||||
networks:
|
||||
- db-network
|
||||
- proxy-network
|
||||
volumes:
|
||||
- ./:/app
|
||||
restart: unless-stopped
|
||||
|
||||
networks:
|
||||
db-network:
|
||||
external: true
|
||||
proxy-network:
|
||||
external: true
|
||||
@@ -12,7 +12,7 @@ const docTemplate = `{
|
||||
"termsOfService": "http://swagger.io/terms/",
|
||||
"contact": {
|
||||
"name": "API Support",
|
||||
"email": "support@yourapp.com"
|
||||
"email": "gabriel.delosrios@tutamail.com"
|
||||
},
|
||||
"license": {
|
||||
"name": "MIT",
|
||||
@@ -364,7 +364,7 @@ const docTemplate = `{
|
||||
// SwaggerInfo holds exported Swagger Info so clients can modify it
|
||||
var SwaggerInfo = &swag.Spec{
|
||||
Version: "1.0",
|
||||
Host: "localhost:8080",
|
||||
Host: "agenda-web-go.gabilandia.com",
|
||||
BasePath: "/",
|
||||
Schemes: []string{},
|
||||
Title: "Contacts API",
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
"termsOfService": "http://swagger.io/terms/",
|
||||
"contact": {
|
||||
"name": "API Support",
|
||||
"email": "support@yourapp.com"
|
||||
"email": "gabriel.delosrios@tutamail.com"
|
||||
},
|
||||
"license": {
|
||||
"name": "MIT",
|
||||
@@ -14,7 +14,7 @@
|
||||
},
|
||||
"version": "1.0"
|
||||
},
|
||||
"host": "localhost:8080",
|
||||
"host": "agenda-web-go.gabilandia.com",
|
||||
"basePath": "/",
|
||||
"paths": {
|
||||
"/contacts": {
|
||||
|
||||
@@ -47,10 +47,10 @@ definitions:
|
||||
description: Phone number in international format
|
||||
type: string
|
||||
type: object
|
||||
host: localhost:8080
|
||||
host: agenda-web-go.gabilandia.com
|
||||
info:
|
||||
contact:
|
||||
email: support@yourapp.com
|
||||
email: gabriel.delosrios@tutamail.com
|
||||
name: API Support
|
||||
description: A simple Contacts CRUD API
|
||||
license:
|
||||
|
||||
@@ -87,9 +87,7 @@ func ensureTablesExist() error {
|
||||
id INT AUTO_INCREMENT PRIMARY KEY,
|
||||
name VARCHAR(120) NOT NULL,
|
||||
company VARCHAR(120) NOT NULL,
|
||||
phone VARCHAR(15) NOT NULL,
|
||||
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
|
||||
updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP
|
||||
phone VARCHAR(15) NOT NULL
|
||||
) DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
|
||||
`)
|
||||
|
||||
|
||||
@@ -9,7 +9,7 @@ type APIResponse struct {
|
||||
// Indicates if the request was successful
|
||||
Success bool `json:"success"`
|
||||
// The response data
|
||||
Data any `json:"data,omitempty"`
|
||||
Data any `json:"data"`
|
||||
// List of errors if any occurred
|
||||
Errors []APIError `json:"errors,omitempty"`
|
||||
// Optional message
|
||||
|
||||
19
internal/middleware/cors.go
Normal file
19
internal/middleware/cors.go
Normal file
@@ -0,0 +1,19 @@
|
||||
package middleware
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
"os"
|
||||
)
|
||||
|
||||
func CorsMiddleware(next http.Handler) http.Handler {
|
||||
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||
w.Header().Set("Access-Control-Allow-Origin", os.Getenv("ALLOWED_ORIGIN"))
|
||||
w.Header().Set("Access-Control-Allow-Methods", "GET, POST, PUT, DELETE, OPTIONS")
|
||||
w.Header().Set("Access-Control-Allow-Headers", "Content-Type, Authorization")
|
||||
if r.Method == "OPTIONS" {
|
||||
w.WriteHeader(http.StatusOK)
|
||||
return
|
||||
}
|
||||
next.ServeHTTP(w, r)
|
||||
})
|
||||
}
|
||||
Reference in New Issue
Block a user