Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature Advisor and corresponding APIs #34

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .env.dev
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ HOST=0.0.0.0
PORT=3000
TRANSPORT_PORT=5000

#GLOBAL
GLOBAL_PREFIX_V1=matrix-core/api/v1

#SWAGGER
SWAGGER_PATH=swagger
SWAGGER_TITLE=
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@
},
"homepage": "https://github.com/QuantaVerse/matrix-core#readme",
"volta": {
"node": "14.15.3",
"node": "14.15.4",
"npm": "6.14.10"
}
}
24 changes: 12 additions & 12 deletions scripts/dev/pg_init.sql
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
DO
$do$
BEGIN
IF NOT EXISTS (SELECT FROM pg_catalog.pg_roles WHERE rolname = 'admin') THEN
CREATE ROLE admin WITH
LOGIN
SUPERUSER
CREATEDB
CREATEROLE
INHERIT
REPLICATION
CONNECTION LIMIT -1
PASSWORD 'admin@123';
GRANT pg_execute_server_program, pg_monitor, pg_read_all_settings, pg_read_all_stats, pg_read_server_files, pg_signal_backend TO admin;
END IF;
IF NOT EXISTS (SELECT FROM pg_catalog.pg_roles WHERE rolname = 'admin') THEN
CREATE ROLE admin WITH
LOGIN
SUPERUSER
CREATEDB
CREATEROLE
INHERIT
REPLICATION
CONNECTION LIMIT -1
PASSWORD 'admin@123';
GRANT pg_execute_server_program, pg_monitor, pg_read_all_settings, pg_read_all_stats, pg_read_server_files, pg_signal_backend TO admin;
END IF;
END
$do$;

Expand Down
2 changes: 1 addition & 1 deletion src/app.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { HealthCheckResult } from "@nestjs/terminus/dist/health-check/health-che
import { AppService } from "./app.service";
import { CustomLoggerService } from "./shared/services/logger.service";

@Controller()
@Controller("app/v1")
export class AppController {
constructor(
private readonly _appService: AppService,
Expand Down
3 changes: 3 additions & 0 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@ async function bootstrap() {
const configService = app.select(SharedModule).get(ConfigService);
const loggerService = await app.select(SharedModule).resolve(CustomLoggerService);

// set global prefix
app.setGlobalPrefix(configService.globalPrefixV1);

// common logger middleware
app.useLogger(loggerService);
// HTTP request logger middleware
Expand Down
2 changes: 1 addition & 1 deletion src/modules/advisor.sim/advisor.sim.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { Controller, Get } from "@nestjs/common";
import { CustomLoggerService } from "../../shared/services/logger.service";
import { AdvisorSimService } from "./advisor.sim.service";

@Controller("advisor/simulation")
@Controller("advisor-sim/v1")
export class AdvisorSimController {
constructor(private readonly simulationService: AdvisorSimService, private logger: CustomLoggerService) {
this.logger.setContext(AdvisorSimController.name);
Expand Down
2 changes: 1 addition & 1 deletion src/modules/advisor/advisor.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { Controller, Get } from "@nestjs/common";
import { CustomLoggerService } from "../../shared/services/logger.service";
import { AdvisorService } from "./advisor.service";

@Controller("advisor")
@Controller("advisor/v1")
export class AdvisorController {
constructor(private readonly advisorService: AdvisorService, private logger: CustomLoggerService) {
this.logger.setContext(AdvisorController.name);
Expand Down
6 changes: 6 additions & 0 deletions src/modules/advisor/advisor.service.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,13 @@
import { Injectable } from "@nestjs/common";

import { CustomLoggerService } from "../../shared/services/logger.service";

@Injectable()
export class AdvisorService {
constructor(private _logger: CustomLoggerService) {
this._logger.setContext(AdvisorService.name);
}

getHello(): string {
return "Hello World!";
}
Expand Down
4 changes: 4 additions & 0 deletions src/shared/services/config.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,10 @@ export class ConfigService {
return getEnvironmentEnum(this.get("NODE_ENV") || "development");
}

public get globalPrefixV1(): string {
return this.get("GLOBAL_PREFIX_V1");
}

public get swaggerConfig(): ISwaggerConfigInterface {
return {
path: this.get("SWAGGER_PATH") || "swagger",
Expand Down