Skip to content

Instantly share code, notes, and snippets.

@khaosdoctor
Created July 9, 2017 01:47
Show Gist options
  • Save khaosdoctor/4321d2d1b6cc401144f938c6c52c266a to your computer and use it in GitHub Desktop.
Save khaosdoctor/4321d2d1b6cc401144f938c6c52c266a to your computer and use it in GitHub Desktop.
Example script for medium post
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