Last active
April 15, 2021 03:55
-
-
Save ricardopadua/8c1a8f7e1c2648986b9d7177718f82ca to your computer and use it in GitHub Desktop.
sample configuration environment development for prologic-app (https://github.com/ricardopadua/prologic-api)
This file contains hidden or 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
{ | |
"typeorm": { | |
"type": "postgres", | |
"host": "localhost", | |
"port": 5432, | |
"username": "postgres", | |
"password": "postgres", | |
"database": "app_db_name", | |
"synchronize": true, | |
"logging": true, | |
"entities": ["src/domain/entities/**/*.ts"], | |
"migrations": ["src/infra/migrations/**/*.ts"], | |
"seeds": ["src/infra/seeds/**/*.ts"], | |
"subscribers": ["src/subscriber/**/*.ts"], | |
"cli": { | |
"entitiesDir": "src/domain/entities", | |
"migrationsDir": "src/infra/migrations", | |
"subscribersDir": "src/subscriber" | |
} | |
}, | |
"express": { | |
"port": 4510, | |
"bodyParserLimit": "2mb", | |
"message": "Server started!", | |
"secret": "my-secret-jwtwebtoken", | |
"morganFormat": "dev", | |
"staticRoute": "/public", | |
"staticFolder": "/public" | |
}, | |
"signaleConfig": { | |
"disabled": false, | |
"interactive": false, | |
"stream": "", | |
"displayFilename": true, | |
"displayTimestamp": true, | |
"displayDate": false | |
}, | |
"routingOptions": { | |
"cors": true, | |
"routePrefix": "/api", | |
"controllers": "/api/controllers/*.{js,ts}", | |
"middlewares": "/api/middlewares/*.{js,ts}", | |
"interceptors": "/api/interceptors/*.{js,ts}", | |
"validation": true, | |
"defaultErrorHandler": false, | |
"authorizationChecker": true | |
}, | |
"ioc": { | |
"childContainerBind": "127.0.0.1" | |
}, | |
"cryptography": { | |
"passwordDefault": "my-sample-password-default" | |
}, | |
"actuator": { | |
"basePath": "/management", | |
"infoGitMode": "full", | |
"infoBuildOptions": null, | |
"infoDateFormat": null, | |
"customEndpoints": [] | |
} | |
} |
This file contains hidden or 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
version: '3.4' | |
services: | |
prologic-api: | |
container_name: prologic-webapi | |
build: | |
context: . | |
dockerfile: ./Dockerfile | |
args: | |
- http_proxy | |
- https_proxy | |
- no_proxy | |
image: prologic/webapi:${PROLOGIC_WEBAPI_TAG} | |
ports: | |
- '8000:8000' | |
hostname: prologic-webapi | |
healthcheck: | |
test: ["CMD", "node", "healthcheck.js"] | |
interval: 10s | |
timeout: 5s | |
retries: 5 | |
depends_on: | |
- "prologic-db" | |
stdin_open: true | |
tty: true | |
prologic-db: | |
image: 'postgres:9.6.2' | |
container_name: prologic-db | |
environment: | |
POSTGRES_HOST: ${POSTGRES_HOST} | |
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD} | |
POSTGRES_DB: ${POSTGRES_DB} | |
POSTGRES_USER: ${POSTGRES_USER} | |
PGDATA: /tmp | |
ports: | |
- '5432:5432' | |
hostname: postgres-log | |
healthcheck: | |
test: ["CMD-SHELL", "pg_isready -U postgres"] | |
interval: 10s | |
timeout: 5s | |
retries: 5 | |
volumes: | |
- './docker-volumes/postgres:/var/lib/postgresql/data' |
This file contains hidden or 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
import config from 'config'; | |
import actuator, { InfoGitMode } from 'express-actuator'; | |
import { Action, RoutingControllersOptions } from 'routing-controllers'; | |
import path from 'path'; | |
import favicon from 'serve-favicon'; | |
// log configuration constant | |
const signale = { | |
object: { | |
disabled: config.get<boolean>('signaleConfig.disabled'), | |
interactive: config.get<boolean>('signaleConfig.interactive'), | |
stream: process.stdout, | |
}, | |
config: { | |
displayFilename: config.get<boolean>('signaleConfig.displayFilename'), | |
displayTimestamp: config.get<boolean>('signaleConfig.displayTimestamp'), | |
displayDate: config.get<boolean>('signaleConfig.displayDate') | |
} | |
}; | |
// express configuration constant | |
const express = { | |
port: config.get<number>('express.port'), | |
bodyParserLimit: config.get<string>('express.bodyParserLimit'), | |
message: config.get<string>('express.message'), | |
secret: config.get<string>('express.secret'), | |
morganFormat: config.get<string>('express.morganFormat'), | |
staticRoute: config.get<string>('express.staticRoute'), | |
staticFolder: path.join(__dirname.replace('/config',''),config.get<string>('express.staticFolder')), | |
faviconPath: favicon(path.join(__dirname.replace('/config',config.get<string>('express.staticFolder')), 'favicon.ico')) | |
}; | |
// typeorm configuration constant | |
const typeorm = { | |
type: config.get<"postgres" | "mysql" | "mariadb">('typeorm.type'), | |
host: config.get<string>('typeorm.host'), | |
port: config.get<number>('typeorm.port'), | |
username: config.get<string>('typeorm.username'), | |
password: config.get<string>('typeorm.password'), | |
database: config.get<string>('typeorm.database'), | |
synchronize: config.get<boolean>('typeorm.synchronize'), | |
logging: config.get<boolean>('typeorm.logging'), | |
entities: config.get<string[]>('typeorm.entities'), | |
migrations: config.get<string[]>('typeorm.migrations'), | |
seeds: config.get<string[]>('typeorm.seeds'), | |
subscribers: config.get<string[]>('typeorm.subscribers'), | |
cli: { | |
entitiesDir: config.get<string>('typeorm.cli.entitiesDir'), | |
migrationsDir: config.get<string>('typeorm.cli.migrationsDir'), | |
subscribersDir: config.get<string>('typeorm.cli.subscribersDir') | |
} | |
}; | |
// routing-controllers configuration constant | |
const routingOptions = (path: string, authorization: (action: Action, roles: string[]) => Promise<boolean>): RoutingControllersOptions => { | |
return { | |
cors: config.get<boolean>('routingOptions.cors'), | |
routePrefix: config.get<string>('routingOptions.routePrefix'), | |
controllers: [path + config.get<string>('routingOptions.controllers')], | |
middlewares: [path + config.get<string>('routingOptions.middlewares')], | |
interceptors: [path + config.get<string>('routingOptions.interceptors')], | |
validation: config.get<boolean>('routingOptions.validation'), | |
defaultErrorHandler: config.get<boolean>('routingOptions.defaultErrorHandler'), | |
authorizationChecker: authorization, | |
} | |
} | |
// IOC configuration constant | |
const ioc = { | |
childContainerBind: config.get<string>('ioc.childContainerBind') | |
}; | |
const cryptography = { | |
passwordDefault: config.get<string>('cryptography.passwordDefault') | |
}; | |
const actuatorOptions: actuator.Options = { | |
basePath: config.get<string>('actuator.basePath'), | |
infoGitMode: config.get<InfoGitMode>('actuator.infoGitMode'), | |
infoBuildOptions: config.get<Record<string, any>>('actuator.infoBuildOptions'), | |
infoDateFormat: config.get<null | string>('actuator.infoDateFormat'), | |
customEndpoints: config.get<any[]>('actuator.customEndpoints') | |
} | |
const environment = { | |
signale: signale, | |
express: express, | |
typeorm: typeorm, | |
ioc: ioc, | |
cryptography: cryptography, | |
routingOptions: (path: string, authorization: (action: Action, roles: string[]) => Promise<boolean>) => routingOptions(path, authorization), | |
actuatorOptions: actuatorOptions | |
} | |
export default environment; | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
typeorm configuration (https://www.npmjs.com/package/typeorm)
express configuration (https://www.npmjs.com/package/express)
signale log configuration (https://www.npmjs.com/package/signale)
routing-controllers configuration (https://www.npmjs.com/package/routing-controllers)
inversify configuration (https://www.npmjs.com/package/inversify)