Created
July 9, 2017 01:47
-
-
Save khaosdoctor/4321d2d1b6cc401144f938c6c52c266a to your computer and use it in GitHub Desktop.
Example script for medium post
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
const FileNotFoundException = require('./shared/errors/FileNotFoundException') // Classe de erro de arquivo não encontrado | |
if (!require('fs').existsSync('.env')) { // Verifica se o arquivo de variáveis de ambiente existe | |
require('knoblr').error('O arquivo .env não existe, por favor crie um') // Loga o erro no console | |
throw new FileNotFoundException('.env') // Envia o erro para o usuário | |
} else { | |
require('dotenv').config({ // Carrega todas as variáveis de ambiente | |
silent: true | |
}) | |
if (['production', 'pre', 'stage'].includes(process.env.NODE_ENV)) { // Carrega newRelic somente em ambientes selecionados | |
require('newrelic') | |
} | |
require('./src/app')() // Executa o arquivo app.js | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment