Skip to content

Commit

Permalink
✨ Feat: elasticsearch initialize
Browse files Browse the repository at this point in the history
#
  • Loading branch information
ks1ksi committed Sep 11, 2023
1 parent d817b6a commit 87c68ab
Show file tree
Hide file tree
Showing 7 changed files with 174 additions and 1 deletion.
33 changes: 32 additions & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ services:

db:
# image: ankane/pgvector
build:
build:
context: .
dockerfile: Dockerfile.pg
ports:
Expand All @@ -35,7 +35,38 @@ services:
volumes:
- redis-data:/data

es:
image: elasticsearch:8.9.2
environment:
- discovery.type=single-node
- ELASTIC_PASSWORD=changeme
- bootstrap.memory_lock=true
- "ES_JAVA_OPTS=-Xms512m -Xmx512m"
ports:
- "9200:9200"
- "9300:9300"
volumes:
- elastic-data:/usr/share/elasticsearch/data
networks:
- elastic

kibana:
image: kibana:8.9.2
ports:
- "5601:5601"
depends_on:
- es
networks:
- elastic

volumes:
elastic-data:
driver: local
redis-data:
driver: local
db-data:
driver: local

networks:
elastic:
driver: bridge
95 changes: 95 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
"@nestjs/common": "^10.2.4",
"@nestjs/config": "^3.0.1",
"@nestjs/core": "^10.2.4",
"@nestjs/elasticsearch": "^10.0.1",
"@nestjs/jwt": "^10.1.1",
"@nestjs/passport": "^10.0.1",
"@nestjs/platform-express": "^10.2.4",
Expand Down
2 changes: 2 additions & 0 deletions src/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import { PrismaService } from './prisma/prisma.service';
import { UserModule } from './user/user.module';
import { TagModule } from './tag/tag.module';
import { CollectionModule } from './collection/collection.module';
import { SearchModule } from './search/search.module';

@Module({
imports: [
Expand All @@ -19,6 +20,7 @@ import { CollectionModule } from './collection/collection.module';
UserModule,
TagModule,
CollectionModule,
SearchModule,
],
controllers: [AppController],
providers: [AppService, PrismaService],
Expand Down
22 changes: 22 additions & 0 deletions src/search/search.module.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import { Module } from '@nestjs/common';
import { ConfigModule, ConfigService } from '@nestjs/config';
import { ElasticsearchModule } from '@nestjs/elasticsearch';

@Module({
imports: [
ConfigModule,
ElasticsearchModule.registerAsync({
imports: [ConfigModule],
useFactory: async (configService: ConfigService) => ({
node: configService.get('ELASTICSEARCH_NODE'),
auth: {
username: configService.get('ELASTICSEARCH_USERNAME'),
password: configService.get('ELASTICSEARCH_PASSWORD'),
},
}),
inject: [ConfigService],
}),
],
exports: [ElasticsearchModule],
})
export class SearchModule {}
18 changes: 18 additions & 0 deletions src/search/search.service.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import { Test, TestingModule } from '@nestjs/testing';
import { SearchService } from './search.service';

describe('SearchService', () => {
let service: SearchService;

beforeEach(async () => {
const module: TestingModule = await Test.createTestingModule({
providers: [SearchService],
}).compile();

service = module.get<SearchService>(SearchService);
});

it('should be defined', () => {
expect(service).toBeDefined();
});
});
4 changes: 4 additions & 0 deletions src/search/search.service.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
import { Injectable } from '@nestjs/common';

@Injectable()
export class SearchService {}

0 comments on commit 87c68ab

Please sign in to comment.