Skip to content
Snippets Groups Projects
Commit 5e5ef00d authored by Ivan Alglave's avatar Ivan Alglave
Browse files

added mongodb with docker image and integration in nest server

parent 1d2be97e
No related branches found
No related tags found
1 merge request!1added mongodb with docker image and integration in nest server
services:
mongo:
image: mongo
container_name: mongo
ports:
- 27017:27017
restart: always
......@@ -27,7 +27,9 @@
"dependencies": {
"@nestjs/common": "^9.0.0",
"@nestjs/core": "^9.0.0",
"@nestjs/mongoose": "^9.2.1",
"@nestjs/platform-express": "^9.0.0",
"mongoose": "^6.7.2",
"reflect-metadata": "^0.1.13",
"rimraf": "^3.0.2",
"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 { AppController } from './app.controller';
import { AppService } from './app.service';
import { MongooseModule } from '@nestjs/mongoose';
import { mongodb } from './config';
@Module({
imports: [],
controllers: [AppController],
providers: [AppService],
imports: [MongooseModule.forRoot(mongodb.uri)],
controllers: [],
providers: [],
})
export class AppModule {}
import { Injectable } from '@nestjs/common';
@Injectable()
export class AppService {
getHello(): string {
return 'Hello World!';
}
}
......@@ -2,6 +2,11 @@ export interface IServerConfig {
port: number;
}
export interface IMongodbConfig {
uri: string;
}
export interface IConfig {
server: IServerConfig;
mongodb: IMongodbConfig;
}
{
"server": {
"port": 0
"port": 3001
},
"mongodb": {
"uri": "mongodb://localhost:27017/internship-manager"
}
}
......@@ -4,4 +4,5 @@ import { IConfig } from './config.model';
const config = _config as IConfig;
export const server = config.server;
export const mongodb = config.mongodb;
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