-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' of https://github.com/spuxx1701/potber-api
- Loading branch information
Showing
11 changed files
with
168 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import { registerAs } from '@nestjs/config'; | ||
|
||
export const appConfig = registerAs('application', () => ({ | ||
port: parseInt(process.env.APP_PORT, 10) || 3000, | ||
metricsPort: parseInt(process.env.APP_METRICS_PORT, 10) || 9100, | ||
clientUrl: process.env.APP_CLIENT_URL ?? 'https://potber.de', | ||
apiUrl: process.env.APP_API_URL ?? 'https://api.potber.de', | ||
auth: { | ||
jwtSecret: process.env, | ||
}, | ||
})); | ||
|
||
export type AppConfig = typeof appConfig; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,14 @@ | ||
import { CorsOptions } from '@nestjs/common/interfaces/external/cors-options.interface'; | ||
import { registerAs } from '@nestjs/config'; | ||
|
||
export const corsConfig: CorsOptions = { | ||
allowedHeaders: ['content-type', 'authorization'], | ||
methods: ['GET', 'POST', 'PUT', 'PATCH', 'DELETE', 'OPTIONS'], | ||
credentials: true, | ||
}; | ||
export const corsConfig = registerAs( | ||
'cors', | ||
(): CorsOptions => ({ | ||
allowedHeaders: ['content-type', 'authorization'], | ||
origin: (process.env.CORS_ALLOWED_ORIGINS ?? '').split(','), | ||
methods: ['GET', 'POST', 'PUT', 'PATCH', 'DELETE', 'OPTIONS'], | ||
credentials: true, | ||
}), | ||
); | ||
|
||
export type CorsConfig = typeof corsConfig; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import { createTestContainer } from 'test/container'; | ||
import { MonitoringDummyController } from './monitoring.dummy-controller'; | ||
|
||
describe('Monitoring | Dummy controller', () => { | ||
let controller: MonitoringDummyController; | ||
|
||
beforeEach(async () => { | ||
const container = await createTestContainer({ | ||
controllers: [MonitoringDummyController], | ||
}); | ||
|
||
controller = container.module.get<MonitoringDummyController>( | ||
MonitoringDummyController, | ||
); | ||
}); | ||
|
||
it('should build', () => { | ||
expect(controller).toBeInstanceOf(MonitoringDummyController); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import { Controller } from '@nestjs/common'; | ||
|
||
/** | ||
* This is an empty controller that is used to disable the default /metrics route. | ||
* /metrics should not be available within the application context, but instead | ||
* will be exposed on a different node process. | ||
*/ | ||
@Controller() | ||
export class MonitoringDummyController {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import { Module } from '@nestjs/common'; | ||
import { PrometheusModule } from '@willsoto/nestjs-prometheus'; | ||
|
||
/** | ||
* The external monitoring module does not define any metrics itself, and instead | ||
* only exposed the /metrics route. The module will be served on a seperate process | ||
* and listens to another port. | ||
*/ | ||
@Module({ | ||
imports: [ | ||
PrometheusModule.register({ | ||
defaultMetrics: { | ||
enabled: true, | ||
}, | ||
}), | ||
], | ||
}) | ||
export class MonitoringExternalModule {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import { Module } from '@nestjs/common'; | ||
import { PrometheusModule } from '@willsoto/nestjs-prometheus'; | ||
import { MonitoringDummyController } from './monitoring.dummy-controller'; | ||
|
||
/** | ||
* The internal monitoring module does not expose a /metrics route, but defines and | ||
* collects metrics from the application. It is included into the main application module. | ||
*/ | ||
@Module({ | ||
imports: [ | ||
PrometheusModule.register({ | ||
controller: MonitoringDummyController, | ||
}), | ||
], | ||
}) | ||
export class MonitoringInteralModule {} |