Skip to content

Commit

Permalink
minor fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
cyri113 committed Feb 29, 2024
1 parent e97d2f1 commit 58eb60c
Show file tree
Hide file tree
Showing 4 changed files with 55 additions and 33 deletions.
2 changes: 1 addition & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
"jest.enable": true
"jest.enable": false
}
6 changes: 3 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@ RUN apk add --update --no-cache python3 make g++

COPY package*.json ./

RUN npm i
RUN npm i --force

COPY . .

RUN npm run build

FROM development AS production
FROM node:alpine AS production

ARG NODE_ENV=production
ENV NODE_ENV=${NODE_ENV}
Expand All @@ -22,7 +22,7 @@ WORKDIR /usr/src/app

COPY package*.json ./

RUN npm i --production
RUN npm i --production --force

COPY . .

Expand Down
20 changes: 13 additions & 7 deletions apps/event-store/src/event-store.service.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Injectable } from '@nestjs/common';
import { InjectConnection, InjectModel } from '@nestjs/mongoose';
import { Connection, Model } from 'mongoose';
import { Event } from './schemas/event.schema';
import { Event, EventSchema } from './schemas/event.schema';

@Injectable()
export class EventStoreService {
Expand All @@ -17,13 +17,19 @@ export class EventStoreService {
event_data: any,
): Promise<Event> {
const dbName = `tg:${chat_id}`;
this.connection.useDb(dbName);
const db = this.connection.useDb(dbName, { useCache: true });

const createdEvent = await this.eventModel.create({
timestamp,
event_type,
event_data,
});
if (!db.models[this.eventModel.collection.name]) {
db.model(this.eventModel.collection.name, EventSchema);
}

const createdEvent = await db
.model(this.eventModel.collection.name)
.create({
timestamp,
event_type,
event_data,
});
return createdEvent;
}
}
60 changes: 38 additions & 22 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ services:
retries: 2
start_period: 30s


rabbitmq:
container_name: rabbitmq
image: rabbitmq:3.12.12-management
Expand All @@ -31,30 +30,47 @@ services:
- RABBITMQ_DEFAULT_USER=guest
- RABBITMQ_DEFAULT_PASS=guest
healthcheck:
test: ["CMD" ,"wget", "http://localhost:7474"]
test: rabbitmq-diagnostics -q ping
interval: 1m30s
timeout: 10s
retries: 2
start_period: 30s

# telegram:
# build:
# context: .
# dockerfile: Dockerfile
# target: development
# command: nest start telegram
# ports:
# - 3000:3000
# env_file:
# - .env
# volumes:
# - .:/usr/src/app
# - ./node_modules:/usr/src/app/node_modules
# depends_on:
# # neo4j:
# # condition: service_healthy
# rabbitmq:
# condition: service_healthy
bot:
container_name: bot
build:
context: .
dockerfile: Dockerfile
target: development
command: npm run start:dev bot
restart: unless-stopped
env_file:
- .env
volumes:
- .:/usr/src/app
- ./node_modules:/usr/src/app/node_modules
depends_on:
rabbitmq:
condition: service_healthy

event-store:
container_name: event-store
build:
context: .
dockerfile: Dockerfile
target: development
command: npm run start:dev event-store
restart: unless-stopped
env_file:
- .env
volumes:
- .:/usr/src/app
- ./node_modules:/usr/src/app/node_modules
depends_on:
mongodb:
condition: service_healthy
rabbitmq:
condition: service_healthy

volumes:
mongo_data:
volumes:
mongo_data:

0 comments on commit 58eb60c

Please sign in to comment.