Skip to content
Snippets Groups Projects
Unverified Commit 35a9e597 authored by Ivan Alglave's avatar Ivan Alglave Committed by GitHub
Browse files

Merge pull request #1 from ivanalglave/mongo-integration

added mongodb with docker image and integration in nest server
parents c182cdda 5e5ef00d
No related branches found
No related tags found
No related merge requests found
services:
mongo:
image: mongo
container_name: mongo
ports:
- 27017:27017
restart: always
...@@ -27,7 +27,9 @@ ...@@ -27,7 +27,9 @@
"dependencies": { "dependencies": {
"@nestjs/common": "^9.0.0", "@nestjs/common": "^9.0.0",
"@nestjs/core": "^9.0.0", "@nestjs/core": "^9.0.0",
"@nestjs/mongoose": "^9.2.1",
"@nestjs/platform-express": "^9.0.0", "@nestjs/platform-express": "^9.0.0",
"mongoose": "^6.7.2",
"reflect-metadata": "^0.1.13", "reflect-metadata": "^0.1.13",
"rimraf": "^3.0.2", "rimraf": "^3.0.2",
"rxjs": "^7.2.0" "rxjs": "^7.2.0"
......
import { Test, TestingModule } from '@nestjs/testing';
import { AppController } from './app.controller';
import { AppService } from './app.service';
describe('AppController', () => {
let appController: AppController;
beforeEach(async () => {
const app: TestingModule = await Test.createTestingModule({
controllers: [AppController],
providers: [AppService],
}).compile();
appController = app.get<AppController>(AppController);
});
describe('root', () => {
it('should return "Hello World!"', () => {
expect(appController.getHello()).toBe('Hello World!');
});
});
});
import { Controller, Get } from '@nestjs/common';
import { AppService } from './app.service';
@Controller()
export class AppController {
constructor(private readonly appService: AppService) {}
@Get()
getHello(): string {
return this.appService.getHello();
}
}
import { Module } from '@nestjs/common'; import { Module } from '@nestjs/common';
import { AppController } from './app.controller'; import { MongooseModule } from '@nestjs/mongoose';
import { AppService } from './app.service'; import { mongodb } from './config';
@Module({ @Module({
imports: [], imports: [MongooseModule.forRoot(mongodb.uri)],
controllers: [AppController], controllers: [],
providers: [AppService], providers: [],
}) })
export class AppModule {} export class AppModule {}
import { Injectable } from '@nestjs/common';
@Injectable()
export class AppService {
getHello(): string {
return 'Hello World!';
}
}
...@@ -2,6 +2,11 @@ export interface IServerConfig { ...@@ -2,6 +2,11 @@ export interface IServerConfig {
port: number; port: number;
} }
export interface IMongodbConfig {
uri: string;
}
export interface IConfig { export interface IConfig {
server: IServerConfig; server: IServerConfig;
mongodb: IMongodbConfig;
} }
{ {
"server": { "server": {
"port": 0 "port": 3001
},
"mongodb": {
"uri": "mongodb://localhost:27017/internship-manager"
} }
} }
...@@ -4,4 +4,5 @@ import { IConfig } from './config.model'; ...@@ -4,4 +4,5 @@ import { IConfig } from './config.model';
const config = _config as IConfig; const config = _config as IConfig;
export const server = config.server; export const server = config.server;
export const mongodb = config.mongodb;
export default config; export default config;
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment