Skip to content

Commit

Permalink
Merge pull request #9 from sanriodev/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
sanriodev authored Sep 12, 2024
2 parents 0cd817f + 1963e75 commit 232a274
Show file tree
Hide file tree
Showing 20 changed files with 600 additions and 100 deletions.
7 changes: 7 additions & 0 deletions .env
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
APP_PORT=3000
APP_ENV=development

MONGO_URI=localhost
MONGO_PORT=27017
MONGO_USERNAME=matteo
MONGO_PASSWORD=matteo
4 changes: 2 additions & 2 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ services:
command:
- --config
- /etc/mongo/mongo.conf
expose:
- 27017
ports:
- 27017:27017
healthcheck:
test:
[
Expand Down
217 changes: 216 additions & 1 deletion package-lock.json

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

2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,15 @@
"@nestjs/common": "^10.4.1",
"@nestjs/config": "^3.2.3",
"@nestjs/core": "^10.0.0",
"@nestjs/mongoose": "^10.0.10",
"@nestjs/platform-express": "^10.0.0",
"@nestjs/schedule": "^4.1.0",
"@nestjs/swagger": "^7.4.0",
"class-transformer": "^0.5.1",
"class-validator": "^0.14.1",
"joi": "^17.13.3",
"modbus-serial": "^8.0.17",
"mongoose": "^8.6.1",
"reflect-metadata": "^0.2.0",
"rxjs": "^7.8.1"
},
Expand Down
5 changes: 3 additions & 2 deletions src/app.module.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import { Module } from '@nestjs/common';
import { AppController } from './app.controller';
import { AppService } from './app.service';
import { ModbusReaderModule } from './modules/modbus-reader/modbus-reader.module';
import { AppConfigModule } from './config/config.module';
import { MongoDatabaseProviderModule } from './config/database/mongo/provider/mongo-provider.module';
import { ModbusReaderModule } from './modules/modbus-reader/modbus-reader.module';

@Module({
imports: [ModbusReaderModule, AppConfigModule],
imports: [AppConfigModule, MongoDatabaseProviderModule, ModbusReaderModule],
controllers: [AppController],
providers: [AppService],
})
Expand Down
7 changes: 3 additions & 4 deletions src/config/configuration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@ import { registerAs } from '@nestjs/config';

export default registerAs('app', () => ({
port: process.env.APP_PORT,
botToken: process.env.BOT_TOKEN,
publicKey: process.env.APP_PUBLIC_KEY,
clientId: process.env.CLIENT_ID,
serverId: process.env.SERVER_ID,
url: process.env.APP_URL,
name: process.env.APP_NAME,
env: process.env.NODE_ENV,
}));
29 changes: 29 additions & 0 deletions src/config/database/mongo/config/config.module.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import * as Joi from 'joi';
import { Module } from '@nestjs/common';
import { ConfigModule, ConfigService } from '@nestjs/config';
import configuration from './configuration';
import { MongoConfigService } from './config.service';
/**
* Import and provide app configuration related classes.
*
* @module
*/
const ENV = process.env.NODE_ENV;
@Module({
imports: [
ConfigModule.forRoot({
load: [configuration],
envFilePath: !ENV ? '.env' : `.env.${ENV}`,
validationSchema: Joi.object({
MONGO_URI: Joi.string().default('localhost'),
MONGO_PORT: Joi.number().default(27017),
MONGO_USERNAME: Joi.string(),
MONGO_PASSWORD: Joi.string(),
MONGO_DATABASE: Joi.string().default(null),
}),
}),
],
providers: [ConfigService, MongoConfigService],
exports: [ConfigService, MongoConfigService],
})
export class MongoConfigModule {}
Loading

0 comments on commit 232a274

Please sign in to comment.