diff --git a/docker/docker-compose.yml b/docker/docker-compose.yml new file mode 100644 index 0000000000000000000000000000000000000000..7c91d0d324da4bba37d81a79634ce1ce3cd02393 --- /dev/null +++ b/docker/docker-compose.yml @@ -0,0 +1,7 @@ +services: + mongo: + image: mongo + container_name: mongo + ports: + - 27017:27017 + restart: always diff --git a/package.json b/package.json index ef426afae28ccf8b1079d47341fc821a1eadf75d..4ba4e23546bbd69c1acc379b3b5dc215221e0e95 100644 --- a/package.json +++ b/package.json @@ -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" diff --git a/src/app.controller.spec.ts b/src/app.controller.spec.ts deleted file mode 100644 index d22f3890a380cea30641cfecc329b5c794ef5fb2..0000000000000000000000000000000000000000 --- a/src/app.controller.spec.ts +++ /dev/null @@ -1,22 +0,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!'); - }); - }); -}); diff --git a/src/app.controller.ts b/src/app.controller.ts deleted file mode 100644 index cce879ee622146012901c9adb47ef40c0fd3a555..0000000000000000000000000000000000000000 --- a/src/app.controller.ts +++ /dev/null @@ -1,12 +0,0 @@ -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(); - } -} diff --git a/src/app.module.ts b/src/app.module.ts index 86628031ca2a10fe172fe824f69d1720c44b43ce..92af588a597dd86698840699a99e1371eaa77f43 100644 --- a/src/app.module.ts +++ b/src/app.module.ts @@ -1,10 +1,10 @@ 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 {} diff --git a/src/app.service.ts b/src/app.service.ts deleted file mode 100644 index 927d7cca0badb13577152bf8753ce3552358f53b..0000000000000000000000000000000000000000 --- a/src/app.service.ts +++ /dev/null @@ -1,8 +0,0 @@ -import { Injectable } from '@nestjs/common'; - -@Injectable() -export class AppService { - getHello(): string { - return 'Hello World!'; - } -} diff --git a/src/config/config.model.ts b/src/config/config.model.ts index 18c0caeba7f84378cc56d6b3d2ad57b5a4878071..79984c4772b4ffd39b85c626dd4b79773b210239 100644 --- a/src/config/config.model.ts +++ b/src/config/config.model.ts @@ -2,6 +2,11 @@ export interface IServerConfig { port: number; } +export interface IMongodbConfig { + uri: string; +} + export interface IConfig { server: IServerConfig; + mongodb: IMongodbConfig; } diff --git a/src/config/config.template.json b/src/config/config.template.json index 88fb6118efe29a8f3815767df9fb60654b4ffabf..ee6bb8331d52b839ede08f6ab08f39349591a7f5 100644 --- a/src/config/config.template.json +++ b/src/config/config.template.json @@ -1,5 +1,8 @@ { "server": { - "port": 0 + "port": 3001 + }, + "mongodb": { + "uri": "mongodb://localhost:27017/internship-manager" } } diff --git a/src/config/index.ts b/src/config/index.ts index 3e77fb1e9461a81fd1014c97592f3721b37a51fc..3bf48c8fc881bf8611016389c8321c7cfef1f121 100644 --- a/src/config/index.ts +++ b/src/config/index.ts @@ -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;