Skip to content

Instantly share code, notes, and snippets.

View tarusharora's full-sized avatar
🎯
Focusing

Tarush Arora tarusharora

🎯
Focusing
View GitHub Profile
@tarusharora
tarusharora / app.js
Created December 28, 2018 22:59
App.js Basic
const nconf = require('nconf');
const server = require('./server');
const { loadSettings } = require('./config/configurationAdaptor');
const appSettingsPath = process.env.APP_SETTINGS_FILE_PATH;
loadSettings({ appSettingsPath })
.then(() => {
// TODO Connect to DB, if any.
@tarusharora
tarusharora / configurationAdaptor.js
Created December 27, 2018 22:09
Configuration Adaptor
const nconf = require('nconf');
const _ = require('lodash');
const loadSettings = ({ appSettingsPath }) => new Promise((resolve, reject) => {
try {
if (_.isEmpty(appSettingsPath)) {
throw new Error('Configuration settings path is required.');
}
nconf.file({
file: appSettingsPath,
@tarusharora
tarusharora / appSettings.json
Last active December 27, 2018 22:09
Simple App Settings file
{
"logSeverity": "info"
}
@tarusharora
tarusharora / server.js
Created December 22, 2018 21:33
node-api-boilerplate
// import dependencies from npm
const Fastify = require('fastify');
const path = require('path');
const AutoLoad = require('fastify-autoload');
const uuidv4 = require('uuid/v4');
// create request ids
const createRequestId = () => uuidv4();
// create the server