Skip to content

Commit

Permalink
Merge pull request #4 from moevm/db-module
Browse files Browse the repository at this point in the history
Add neo4j module
  • Loading branch information
jonx8 authored Nov 14, 2024
2 parents dcd0fb4 + 18a9803 commit 17e2079
Show file tree
Hide file tree
Showing 17 changed files with 199 additions and 112 deletions.
5 changes: 0 additions & 5 deletions Makefile

This file was deleted.

7 changes: 4 additions & 3 deletions docker-compose.yaml
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
version: "3.9"

services:
backend:
image: nosql-spb-backend
container_name: backend
build: .
build:
context: server
dockerfile: Dockerfile
ports:
- "127.0.0.1:8080:8080"
environment:
Expand All @@ -28,6 +28,7 @@ services:
container_name: db
environment:
NEO4J_AUTH: neo4j/password
NEO4J_PLUGINS: '["apoc"]'
restart: always
networks:
- nosql-spb-net
Expand Down
4 changes: 4 additions & 0 deletions server/.dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
node_modules/
dist/
Dockerfile
.dockerignore
4 changes: 2 additions & 2 deletions server/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM node:20.15.1-alpine AS builder
FROM node:22.10-alpine AS builder


WORKDIR /app
Expand All @@ -8,7 +8,7 @@ RUN npm install
COPY . .
RUN npm run build

FROM node:20.15.1-alpine
FROM node:22.10-alpine

WORKDIR /app
COPY --from=builder --chown=node:node /app/package*.json ./
Expand Down
2 changes: 0 additions & 2 deletions server/Makefile

This file was deleted.

134 changes: 82 additions & 52 deletions server/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 server/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
},
"dependencies": {
"@nestjs/common": "^10.0.0",
"@nestjs/config": "^3.3.0",
"@nestjs/core": "^10.0.0",
"@nestjs/platform-express": "^10.0.0",
"nest-neo4j": "^0.3.1",
Expand Down
22 changes: 0 additions & 22 deletions server/src/app.controller.spec.ts

This file was deleted.

12 changes: 5 additions & 7 deletions server/src/app.controller.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
import { Controller, Get } from '@nestjs/common';
import { AppService } from './app.service';
import {Controller, Get} from '@nestjs/common';

@Controller()
export class AppController {
constructor(private readonly appService: AppService) {}

@Get()
getHello(): string {
return this.appService.getHello();
}
@Get("/hello")
getHello() {
return "Hello World!";
}
}
27 changes: 17 additions & 10 deletions server/src/app.module.ts
Original file line number Diff line number Diff line change
@@ -1,19 +1,26 @@
import { Module } from '@nestjs/common';
import { ConfigModule, ConfigService } from '@nestjs/config';
import { AppController } from './app.controller';
import { AppService } from './app.service';
import { Neo4jModule } from 'nest-neo4j'
import { Neo4jModule } from './modules/neo4j/neo4j.module';
import { Neo4jConfig } from './modules/neo4j/neo4j-config.interface';

@Module({
imports: [
Neo4jModule.forRoot({
scheme: 'neo4j',
host: 'localhost',
port: 7687,
username: 'neo4j',
password: 'neo'
})
ConfigModule.forRoot({}),
Neo4jModule.forRootAsync({
imports: [ConfigModule],
inject: [ConfigService],
useFactory: (configService: ConfigService): Neo4jConfig => ({
scheme: configService.get('NEO4J_SCHEME'),
host: configService.get('NEO4J_HOST'),
port: configService.get('NEO4J_PORT'),
username: configService.get('NEO4J_USERNAME'),
password: configService.get('NEO4J_PASSWORD'),
database: configService.get('NEO4J_DB'),
}),
}),
],
controllers: [AppController],
providers: [AppService],
providers: [],
})
export class AppModule {}
8 changes: 0 additions & 8 deletions server/src/app.service.ts

This file was deleted.

3 changes: 2 additions & 1 deletion server/src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { AppModule } from './app.module';

async function bootstrap() {
const app = await NestFactory.create(AppModule);
await app.listen(process.env.PORT ?? 3000);
await app.listen(8080);
}

bootstrap();
8 changes: 8 additions & 0 deletions server/src/modules/neo4j/neo4j-config.interface.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
export interface Neo4jConfig {
scheme: string;
host: string;
port: number | string;
username: string;
password: string;
database?: string;
}
2 changes: 2 additions & 0 deletions server/src/modules/neo4j/neo4j.constants.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export const NEO4J_CONFIG = 'NEO4J_CONGIG';
export const NEO4J_DRIVER = 'NEO4J_DRIVER';
Loading

0 comments on commit 17e2079

Please sign in to comment.