Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
90 commits
Select commit Hold shift + click to select a range
6c1a8f7
chore(env): add .env.example and install dotenv for environment varia…
mcarenashd Sep 26, 2025
29a2d7d
chore(env): update .env.example with new environment variables
mcarenashd Sep 26, 2025
949f1a9
chore(config): add tsconfig.json with strict TypeScript settings for …
olgararo Sep 26, 2025
ebfab8a
chore(config): add src folder
olgararo Sep 26, 2025
04bb783
Merge pull request #1 from Codigo-Inmersion/feature/models
gemayc Sep 26, 2025
5f6ef3b
refactor(project): move backend folders into src and setup MySQL data…
gemayc Sep 29, 2025
5d48cc4
Merge pull request #2 from Codigo-Inmersion/learn
gemayc Sep 29, 2025
41a5480
feat(api): add Article and User Authentication controllers
gemayc Sep 30, 2025
836ce78
feat(auth): add user registration and login with email normalization …
gemayc Sep 30, 2025
34fb979
Merge pull request #19 from Codigo-Inmersion/feature/controllers
gemayc Sep 30, 2025
ca1193c
feat: Add article routes
mcarenashd Sep 30, 2025
435bb8f
feat: Add auth routes
mcarenashd Sep 30, 2025
4fec50e
Merge pull request #21 from Codigo-Inmersion/feature/routes
mcarenashd Sep 30, 2025
db0f3df
fix: use declare keyword in Sequelize models to prevent field shadowing
mcarenashd Sep 30, 2025
a197145
chore: remove dist folder from repository and add to .gitignore
mcarenashd Sep 30, 2025
ec4c258
add dist folder to .gitignore
mcarenashd Sep 30, 2025
2230391
Merge pull request #22 from Codigo-Inmersion/feature/routes
gemayc Sep 30, 2025
72f424f
feat: implement JWT authentication and authorization
gemayc Sep 30, 2025
df43b33
Merge pull request #23 from Codigo-Inmersion/feature/jwt
gemayc Sep 30, 2025
03aec71
feat(auth): add user model, JWT auth, validators and middlewares
mcarenashd Oct 1, 2025
ee94677
feat(auth): enforce unique username and require minimum 8-char password
mcarenashd Oct 1, 2025
e98339c
Merge pull request #24 from Codigo-Inmersion/feature/userValidators
gemayc Oct 1, 2025
7f7cd77
feat(articles): add validator for POST and PUT requests
gemayc Oct 1, 2025
764d980
Merge branch 'develop' of https://github.com/Codigo-Inmersion/codigo-…
gemayc Oct 1, 2025
df6f217
add validators
gemayc Oct 1, 2025
44ad037
Merge pull request #25 from Codigo-Inmersion/feature/ArticleValidators
gemayc Oct 1, 2025
30d0d3a
feat(articles): Restrict article creation to admin role
mcarenashd Oct 1, 2025
86d33b1
Merge pull request #26 from Codigo-Inmersion/feature/routes
mcarenashd Oct 1, 2025
6d9775c
fix: reorder router
mcarenashd Oct 1, 2025
e2ba1f0
Merge pull request #27 from Codigo-Inmersion/feature/routes
mcarenashd Oct 1, 2025
6bc70ed
feat setup test
gemayc Oct 1, 2025
130d258
feat(test): Add user auth tests and configure Jest for TS/ESM
mcarenashd Oct 2, 2025
75dd85f
Merge pull request #28 from Codigo-Inmersion/feature/authTest
gemayc Oct 2, 2025
37edb6f
merge with develop
gemayc Oct 2, 2025
8f0159c
chore(test): configure TypeScript for the testing environment
gemayc Oct 2, 2025
a9b01e5
chore(test): create test database, sync it and update Jest configurat…
gemayc Oct 2, 2025
3956b86
Merge pull request #29 from Codigo-Inmersion/feature/articleTest
mcarenashd Oct 2, 2025
8bbe666
fix(articles): validate requests before controllers to prevent 500 er…
gemayc Oct 2, 2025
416224f
test: implement POST request tests for article creation and validation
gemayc Oct 3, 2025
445d0e2
feat(auth): update AuthController logic and error handling
gemayc Oct 6, 2025
3d27617
Merge pull request #30 from Codigo-Inmersion/feature/articleTest
mcarenashd Oct 6, 2025
bc33536
feature: Add forgot password feature
mcarenashd Oct 6, 2025
29c0c7b
Merge branch 'develop' of https://github.com/Codigo-Inmersion/codigo-…
mcarenashd Oct 6, 2025
7c08c4c
Merge pull request #31 from Codigo-Inmersion/feature/authTest
gemayc Oct 6, 2025
414bf53
fix: return only token when login and register
mcarenashd Oct 6, 2025
6d1b282
feat(auth, article): modify AuthController and ArticleController logi…
gemayc Oct 6, 2025
9cceae4
Merge pull request #32 from Codigo-Inmersion/feature/articleTest
mcarenashd Oct 6, 2025
71e25fc
Merge branch 'develop' of https://github.com/Codigo-Inmersion/codigo-…
mcarenashd Oct 6, 2025
94307ed
Fix tests issues
mcarenashd Oct 6, 2025
717e1eb
Update test requirements
mcarenashd Oct 6, 2025
9e04c03
Merge pull request #33 from Codigo-Inmersion/feature/authTest
gemayc Oct 6, 2025
523962d
fix(test): update error handling in article creation test
gemayc Oct 6, 2025
2909e03
test(api): add CRUD method tests with authentication
gemayc Oct 7, 2025
511d31c
fix(controller): adjust logic in ArticleController
gemayc Oct 7, 2025
cf8bc83
feat: refactor article model - split into tables, tests, and validators
gemayc Oct 7, 2025
5dcb8ef
Merge branch 'develop' into feature/articleTest
mcarenashd Oct 7, 2025
790890d
Merge pull request #34 from Codigo-Inmersion/feature/articleTest
mcarenashd Oct 7, 2025
5f2a095
chore(routes): testing article creation routes
gemayc Oct 9, 2025
5f7a4ae
Merge pull request #35 from Codigo-Inmersion/feature/articleTest
mcarenashd Oct 9, 2025
0db9e14
feat(api): add route to identify authenticated user
gemayc Oct 9, 2025
cd4459a
Merge pull request #36 from Codigo-Inmersion/feature/articleTest
mcarenashd Oct 9, 2025
ea3d111
change in routes
gemayc Oct 10, 2025
ecd30d2
Merge pull request #37 from Codigo-Inmersion/feature/articleTest
mcarenashd Oct 10, 2025
bb2366b
build(docker): add Dockerfile and docker-compose to containerize API
gemayc Oct 10, 2025
42c62bb
chore(docker): initial Docker image push to Docker Hub from VS Code
gemayc Oct 12, 2025
eb5d98f
ci: build & push docker image on develop/main
gemayc Oct 13, 2025
7ed824e
Merge pull request #39 from Codigo-Inmersion/feature/docker
mcarenashd Oct 13, 2025
73bb1ec
feat: new user controller for admin
olgararo Oct 13, 2025
061df61
Merge branch 'develop' into feature/endpoints_dashboard
olgararo Oct 13, 2025
d8c3e2b
feat(articles): add like and unlike functionality
mcarenashd Oct 13, 2025
95706ae
remove alter true form app.ts
mcarenashd Oct 13, 2025
f1d0bb5
Merge pull request #40 from Codigo-Inmersion/feature/like_counter
gemayc Oct 13, 2025
126ffa7
fix: user routes imports for new endpoints
olgararo Oct 13, 2025
94d2551
Merge branch 'develop' into feature/endpoints_dashboard
olgararo Oct 13, 2025
ed96675
fix(app.ts): add /users for routes
olgararo Oct 13, 2025
63cd24c
feat(docker): TiDB TLS + compose para nube; ignorar dumps/certs y act…
gemayc Oct 13, 2025
c030fea
chore: delete accidental backend.sql and ignore *.sql
gemayc Oct 13, 2025
20075de
chore(docker): add comments to docker-compose.yml for clarity
gemayc Oct 13, 2025
457d707
merge: keep TLS-aware db_connection (TiDB support) and unified logging
gemayc Oct 13, 2025
9e30e00
feat(likes): align Like interface with model and associations
gemayc Oct 13, 2025
b4f8846
feat(infra): Docker + TiDB TLS y columna 'likes' (imagen en compose, …
gemayc Oct 13, 2025
cbe2d4e
Merge pull request #42 from Codigo-Inmersion/feature/docker
mcarenashd Oct 14, 2025
f8e0010
Merge branch 'develop' into feature/endpoints_dashboard
olgararo Oct 14, 2025
9b5b757
Merge pull request #41 from Codigo-Inmersion/feature/endpoints_dashboard
mcarenashd Oct 14, 2025
4ccf476
change in appfix(app): resolve issue in app.ts related to initializa…
gemayc Oct 14, 2025
98024f6
chore(db, docker): update database connection settings and improve Do…
gemayc Oct 14, 2025
ca3a4b0
chore(compose): update docker-compose for testing purposes
gemayc Oct 14, 2025
86fc332
Merge pull request #43 from Codigo-Inmersion/feature/docker
mcarenashd Oct 15, 2025
83ff399
update docker-compose
gemayc Oct 15, 2025
2d82ade
Merge pull request #44 from Codigo-Inmersion/feature/docker
mcarenashd Oct 16, 2025
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
12 changes: 12 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
node_modules
dist
coverage
.tmp
.cache
.git
.gitignore
Dockerfile*
docker-compose*
.env
.env.*
.env.docker
36 changes: 36 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# .env que utliza la base de datos local MYSQL

DB_NAME=
DB_USER=
DB_PASS=
DB_HOST=
DB_PORT=
DB_DIALECT=
DB_SSL=false

PORT=
CORS_ORIGIN=

JWT_SECRET=
JWT_EXPIRES=

# .env.docker que utiliza una base de datos en la nuebe TIBD y que solo utilizamos en el docker-compose.yml

NODE_ENV=development

DB_NAME=
DB_USER=
DB_PASS=
DB_HOST=
DB_PORT=

DB_DIALECT=

DB_SSL=true
DB_SSL_CA_PATH=


PORT=
CORS_ORIGIN=
JWT_SECRET=
JWT_EXPIRES=
52 changes: 52 additions & 0 deletions .github/workflows/docker-publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
name: Build & Push Docker image

on:
push:
branches: [ "develop", "main" ] # se ejecuta cuando hay push a develop o main
workflow_dispatch: # permite lanzarlo a mano desde Actions

jobs:
docker:
runs-on: ubuntu-latest # VM Ubuntu donde corren los pasos

steps:
- name: Checkout
uses: actions/checkout@v4 # baja el código del repo (lee el Dockerfile)

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
# Buildx = builder moderno de Docker (mejor caché)

- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }} # <- secret con "gema284"
password: ${{ secrets.DOCKERHUB_TOKEN }} # <- secret con tu access token

- name: Choose tags
id: vars
shell: bash
run: |
REPO="${{ secrets.DOCKERHUB_USERNAME }}/codigo-abisal-server-api"
SHA="${GITHUB_SHA::7}" # commit corto (tag inmutable)
BR="${GITHUB_REF_NAME}" # nombre de la rama (develop o main)

# develop -> :dev y :SHA
TAGS="$REPO:dev,$REPO:$SHA"

# main -> :main y :SHA
if [ "$BR" = "main" ]; then
TAGS="$REPO:main,$REPO:$SHA"
fi

echo "tags=$TAGS" >> "$GITHUB_OUTPUT"

- name: Build & Push
uses: docker/build-push-action@v6
with:
context: . # carpeta con tu Dockerfile (raíz)
file: ./Dockerfile # ruta al Dockerfile
push: true # construye y SUBE la imagen a Docker Hub
tags: ${{ steps.vars.outputs.tags }}
cache-from: type=gha
cache-to: type=gha,mode=max
13 changes: 12 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,15 @@
node_modules
.env
.env.test
.DS_Store
.DS_Store
dist
.env.docker

# Certificados / claves
certs/*.pem
certs/*.key

# Dumps y backups
*.sql
*.sql.gz
*.dump
39 changes: 39 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# ========= Etapa 1: dependencias de producción =========
FROM node:20-alpine AS deps
WORKDIR /app
COPY package*.json ./
RUN npm ci --omit=dev
# Comentario:
# - 'npm ci' instala exactamente lo que hay en package-lock.
# - '--omit=dev' deja solo deps de producción (más pequeño).

# ========= Etapa 2: compilar TypeScript a dist/ =========
FROM node:20-alpine AS builder
WORKDIR /app
COPY package*.json ./
RUN npm ci # aquí sí instalamos devDependencies (ts, tipos, etc.)
COPY tsconfig.json ./
COPY src ./src
RUN npm run build # genera dist/app.js (coincide con tu package.json)

# ========= Etapa 3: imagen final para ejecutar =========
FROM node:20-alpine AS runner
ENV NODE_ENV=production
WORKDIR /app

# Copiamos lo mínimo necesario para correr
COPY --from=deps /app/node_modules ./node_modules
COPY --from=builder /app/dist ./dist
COPY package*.json ./

# Copiamos el certificado de TiDB dentro de la imagen
COPY certs ./certs

# Seguridad: no correr como root
RUN addgroup -S app && adduser -S app -G app
RUN chown -R app:app /app
USER app

EXPOSE 8000
# Muy importante: en Render se usa process.env.PORT automáticamente
CMD ["node", "dist/app.js"]
Empty file removed app.ts
Empty file.
Empty file removed controllers/.gitkeep
Empty file.
Empty file removed database/.gitkeep
Empty file.
41 changes: 41 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
services:

# mysql: // todo esto lo he comentado porque esta es la BD MYSQL que yo tenia en local ahora ya no la necesito la he echo en la nube
# image: mysql:8.4
# container_name: mysql-abisal
# environment:
# - MYSQL_ROOT_PASSWORD=alba2005 # contraseña del root
# - MYSQL_DATABASE=abisal_app # base de datos que se crea al iniciar
# - MYSQL_USER=app # usuario normal (NO root)
# - MYSQL_PASSWORD=alba2005 # contraseña app
# ports:
# - "3307:3306" # mapeo externo (puedes dejarlo o quitarlo)
# volumes:
# - mysql_data:/var/lib/mysql
# healthcheck:
# test: ["CMD", "mysqladmin", "ping", "-h", "localhost"]
# interval: 10s
# timeout: 5s
# retries: 10

api:
# build:
# context: .
# dockerfile: Dockerfile // cuando se construye la imagen desde local ya no lo necesito la tengo en dockerhub ahora pongo:
container_name: abisal-api
platform: linux/amd64
image: gema284/codigo-abisal-server-api:dev
env_file: .env.docker
# environment:
# - DB_HOST=mysql
ports:
- "8000:8000"
# depends_on:
# mysql:
# condition: service_healthy
# volumes:
# - ./certs/tidb-ca.pem:/app/certs/tidb-ca.pem:ro//este lo que quitado ahora porque lo he metido en la imagen dockerfile

# volumes:

# mysql_data:// este lo quito porque apuntaba a la BD local de docker
33 changes: 33 additions & 0 deletions jest.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@


// 1) Exporto en ESM porque tu proyecto es ESM (type: module / NodeNext)
export default {
// 2) Preset de ts-jest para ESM
preset: "ts-jest/presets/default-esm",

// 3) Entorno de Node
testEnvironment: "node",

// 4) Fuerzo a ts-jest a ESM explícito
transform: {
"^.+\\.tsx?$": [
"ts-jest",
{
useESM: true,
tsconfig: "./tsconfig.json"
}
]
},

// 5) Trata .ts como módulos ESM
extensionsToTreatAsEsm: [".ts"],

// 6) Arreglo común: si importas con sufijo .js en código TS,
// mapea a la ruta sin .js para que Jest lo resuelva bien.
moduleNameMapper: {
"^(\\.{1,2}/.*)\\.js$": "$1"
},
setupFilesAfterEnv: ["<rootDir>/test/jest.setup.ts"],
// 7) Dónde están tus tests
testMatch: ["**/test/**/*.test.ts"]
};
Empty file removed models/.gitkeep
Empty file.
Loading
Loading