Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Release v2.1.0 #172

Merged
merged 50 commits into from
Jun 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
50 commits
Select commit Hold shift + click to select a range
75d968e
[GH-80] fix(Book): segregate post and put responsabilities
pablojvritx Dec 10, 2023
019b4e4
[GH-80] fix(Book): segregate post and put responsabilities (#111)
pablojvritx Dec 10, 2023
7788fc6
[GH-112] fix(test) fix post put book unit tests segregation
pablojvritx Dec 10, 2023
fa7cf70
[GH-112] fix(test) fix post put book unit tests segregation (#113)
pablojvritx Dec 10, 2023
3be920b
[GH-102] chore: update environment variables config
pablojvritx Dec 9, 2023
0d035f5
[GH-102] chore: update environment variables config (#114)
pablojvritx Dec 10, 2023
7497988
[GH-115] chore: update node version
pablojvritx Dec 11, 2023
6abb789
[GH-115] chore: update node version (#116)
pablojvritx Dec 11, 2023
fa47c0a
[GH-117] feat(Book) optimize book update with PATCH instead of PUT
pablojvritx Dec 11, 2023
41294dc
[GH-117] refactor(App): add index files
pablojvritx Dec 11, 2023
b66f8e0
[GH-117] feat(Book): optimize book update with PATCH instead of PUT (…
pablojvritx Dec 11, 2023
19b59df
[GH-119] fix OAS3 spec and newman routine
pablojvritx Dec 11, 2023
6d8ca7f
[GH-119] doc: fix OAS3 spec and newman routine (#120)
pablojvritx Dec 11, 2023
0a815c2
[GH-127] fix(Test): merge lcov.info
pablojvritx Dec 15, 2023
0dcc10c
[GH-127] fix(Test): merge lcov.info (#128)
vinjatovix Dec 15, 2023
10f0443
[GH-122] feat(Plugin): add encryption adapter
pablojvritx Dec 14, 2023
75e98fe
[GH-122] feat(Plugin): add encryption adapter (#129)
vinjatovix Dec 15, 2023
6119d80
[GH-38] doc(User): add OAS3 specs
pablojvritx Dec 14, 2023
c4f5a0c
[GH-38] feat(User): add value objects
pablojvritx Dec 14, 2023
284b738
[GH-38] feat(User): add MongoAuthRepository
pablojvritx Dec 14, 2023
af19022
[GH-38] feat(User): add use cases
pablojvritx Dec 14, 2023
49ac910
[GH-38] feat(User): add controllers
pablojvritx Dec 14, 2023
6336633
[GH-38] feat(User): add routes
pablojvritx Dec 14, 2023
4cbd826
[GH-38] fix(Book): fix flaky tests
pablojvritx Dec 15, 2023
e9fe8e7
[GH-38] feat(User): add auth (#125)
pablojvritx Dec 15, 2023
6233509
[GH-132] Prepare release v1.5.0
pablojvritx Dec 15, 2023
50ffd6e
[GH-132] Prepare release v1.5.0 (#133)
pablojvritx Dec 15, 2023
43e84f5
Sync 'origin/main' into develop
pablojvritx Dec 25, 2023
11fa280
[GH-130] feat(Mongo): add connection retry
pablojvritx Dec 17, 2023
8087c7f
[GH-130] feat(Book): protect routes
pablojvritx Dec 24, 2023
fa43e53
[GH-130] feat(Book): protect routes (#140)
vinjatovix Dec 25, 2023
ed49d8a
[GH-136] chore: update project dependencies
pablojvritx Dec 25, 2023
b6286a5
[GH-136] chore: update project dependencies (#141)
vinjatovix Dec 25, 2023
1996854
[GH-137] Prepare release v2.0.0
pablojvritx Dec 25, 2023
845ae35
[GH-137] Prepare release v2.0.0 (#142)
vinjatovix Dec 25, 2023
158ffba
Sync 'origin/main' into develop
pablojvritx Dec 25, 2023
158e011
[GH-144] refactor(test): deprecate toThrowError in favor of toThrow
pablojvritx Dec 25, 2023
0b09525
[GH-144] refactor(test): deprecate toThrowError in favor of toThrow (…
pablojvritx Dec 25, 2023
0ee7f0e
[GH-148] feat(Author): add author crud (#149)
pablojvritx Jun 2, 2024
f5f88bf
[GH-150] feat(apiErrorHandler): update logger error messages with use…
vinjatovix Jun 2, 2024
62d4b77
[GH-152] feat(logger): update logger info messages with username (#154)
vinjatovix Jun 2, 2024
0c90ced
[GH-153] fix(logger): fix uncomplete logger.errors (#155)
vinjatovix Jun 2, 2024
7a1f82e
[GH-156] feat(book): populate and filter book fields by qs (#157)
vinjatovix Jun 3, 2024
a74f620
[GH-158] feat(db): update mongodb to version 6 (#159)
pablojvritx Jun 3, 2024
7def083
[GH-161] feat(db): add replicaSet to local mongo docker
pablojvritx Jun 4, 2024
54f020d
[GH-161] feat(db): add replicaSet to local mongo docker (#162)
pablojvritx Jun 4, 2024
ca07a6a
[GH-163] fix(db): fix collision including ref document _id (#164)
vinjatovix Jun 4, 2024
830a854
[GH-165] feat(Book,Author,User): add metadata value object to documen…
pablojvritx Jun 6, 2024
c92ae13
[GH-169] chore: update pre-commit hook to check package json version …
vinjatovix Jun 6, 2024
7f69d9d
[GH-166] doc(Author): update openApi spec (#171)
pablojvritx Jun 6, 2024
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
1 change: 1 addition & 0 deletions .env.test
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,4 @@ MONGO_DB=test
MONGO_USERNAME=localUser
MONGO_PASSWORD=localPassword
JWT_SECRET=secret
MONGO_REPLICA_SET=rs0
1 change: 1 addition & 0 deletions .env_example
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,4 @@ MONGO_URL=localhost:27017
MONGO_DB=ts-api
MONGO_USERNAME=localUser
MONGO_PASSWORD=localPassword
MONGO_REPLICA_SET=rs0
2 changes: 1 addition & 1 deletion .github/workflows/build_matrix.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ jobs:

strategy:
matrix:
node-version: [20.x,21.x]
node-version: [20.x, 21.x]
steps:
- uses: actions/checkout@v1
- name: Use Node.js ${{ matrix.node-version }}
Expand Down
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -137,3 +137,5 @@ dist
test-report.xml
debug.json
config/*.env

migrate-mongo-config.js
11 changes: 11 additions & 0 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -1,4 +1,15 @@
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"

LAST_TAG=$(git describe --tags --abbrev=0)

CURRENT_VERSION=$(node -p "require('./package.json').version")

if [ "$LAST_TAG" = "v$CURRENT_VERSION" ]; then
npm --no-git-tag-version version minor
git add package.json package-lock.json

echo "Bumped version to $(node -p "require('./package.json').version")"
fi

npm run pre-commit
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Usa la imagen base con Node.js
FROM node:18
FROM node:20

# Establece el directorio de trabajo
WORKDIR /app
Expand Down
16 changes: 13 additions & 3 deletions docker/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
version: "3.7"
version: '3.7'

services:
ts-api-mongo:
Expand All @@ -9,6 +9,7 @@ services:
ports:
- 27017:27017
volumes:
- ./mongo/mongo-init.js:/docker-entrypoint-initdb.d/init.js:ro
- ts_api_mongo_data:/data/db:delegated
environment:
MONGO_INITDB_DATABASE: ts-api
Expand All @@ -17,11 +18,20 @@ services:
MONGO_USERNAME: localUser
MONGO_PASSWORD: localPassword
healthcheck:
test: ["CMD", "mongo", "--eval", "db.adminCommand('ping')"]
interval: 60s
test: |
if echo "rs.initiate({_id:'rs0',members:[{_id:0,host:'localhost:27017'}]}).ok" | mongosh -u root -p rootPassword --quiet | grep -q 1; then
exit 0
elif echo "rs.status().ok" | mongosh -u root -p rootPassword --quiet | grep -q 1; then
exit 0
else
exit 1
fi
interval: 10s
start_period: 30s
timeout: 10s
retries: 3
command:
['--replSet', 'rs0', '--bind_ip_all', '--keyFile', '/data/replica.key']

volumes:
ts_api_mongo_data:
7 changes: 4 additions & 3 deletions docker/mongo/Dockerfile_mongo
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
FROM mongo:5.0.0
RUN apt-get update && apt-get install -y curl iputils-ping
COPY ./mongo-init.js /docker-entrypoint-initdb.d/
FROM mongo:7.0.11
RUN openssl rand --base64 768 > /data/replica.key
RUN chmod 400 /data/replica.key
RUN chown 999:999 /data/replica.key
9 changes: 8 additions & 1 deletion docker/mongo/scripts/restoreDB.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ PASSWORD=$2
# Required variables
DOCKER_NAME=ts-api-mongo
DUMP_USER=tsApiDev
DUMP_DB=ts-api-dev
DUMP_DB=ts-api
RESTORE_HOST=localhost
RESTORE_PORT=27017
RESTORE_USER=root
Expand Down Expand Up @@ -43,6 +43,13 @@ docker exec -it "$DOCKER_NAME" mongodump --uri="mongodb+srv://$DUMP_USER:$PASSWO
print " $ENV_DUMP dump completed"
sleep 1

print " Dropping existing collections in local database $DUMP_DB"
docker exec -it "$DOCKER_NAME" mongosh --host "$RESTORE_HOST" --port "$RESTORE_PORT" --username "$RESTORE_USER" --password "$RESTORE_PASSWORD" --eval "use $DUMP_DB" --eval "db.dropDatabase()"

sleep 1

print " Restoring $ENV_DUMP dump to local database $DUMP_DB"

docker exec -it "$DOCKER_NAME" mongorestore --host "$RESTORE_HOST" --port "$RESTORE_PORT" --username "$RESTORE_USER" --password "$RESTORE_PASSWORD" --drop "/data/dump/$ENV_DUMP"

docker restart "$DOCKER_NAME"
Expand Down
34 changes: 34 additions & 0 deletions migrations/2.1.0/20240604204522-add_metadata_to_collections.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
module.exports = {
async up(db, client) {
const session = client.startSession();
const user = 'adminServiceUser';
const now = new Date();
const collections = ['books', 'authors', 'users'];
try {
await session.withTransaction(async () => {
await Promise.all(
collections.map(async (collection) => {
await db.collection(collection).updateMany(
{},
[
{
$set: {
metadata: {
createdAt: now,
createdBy: user,
updatedAt: now,
updatedBy: user
}
}
}
],
{ session }
);
})
);
});
} finally {
session.endSession();
}
}
};
37 changes: 37 additions & 0 deletions migrations/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
import { database, config, up as migrationUp } from 'migrate-mongo';
import { buildLogger } from '../src/Contexts/shared/plugins/logger.plugin';
import { envs } from '../src/config/plugins/envs.plugin';
import { version } from '../package.json';

const logger = buildLogger('Migrations');

const user = envs.MONGO_USERNAME;
const password = encodeURIComponent(envs.MONGO_PASSWORD);
const host = envs.MONGO_URL;
const rs = `?replicaSet=${envs.MONGO_REPLICA_SET}`;
const databaseName = envs.MONGO_DB;
const connectionString = `mongodb://${user}:${password}@${host}/${databaseName}${rs}`;

config.set({
mongodb: {
url: connectionString
},
migrationsDir: `migrations/${version}`,
changelogCollectionName: 'changelog'
});

logger.info(`Migrations version: ${version}`);

const up = async () => {
const { db, client } = await database.connect();
try {
const migrated = await migrationUp(db, client);
migrated.forEach((fileName) => logger.info(`Migrated: ${fileName}`));
} catch (error) {
logger.error((error as Error).message);
} finally {
await client.close();
}
};

export default { up };
Loading
Loading