Skip to content

Instantly share code, notes, and snippets.

View EdyVision's full-sized avatar

Eidan Rosado EdyVision

View GitHub Profile
@EdyVision
EdyVision / drugServiceHandler.js
Created June 25, 2019 00:31
Drug Service Handler File
'use strict';
const drugSearch = require('./functions/drugSearch/drugSearchCtrl');
module.exports.getDrugIdentifiers = async (event) => {
return drugSearch.getDrugIdentifiers(event);
};
@EdyVision
EdyVision / drugSearchController.js
Created June 25, 2019 00:38
Drug Search Controller
'use strict';
const nlmSearch = require('./services/nlmSearch');
// Headers needed for Locked Down APIs
const headers = {
'Access-Control-Allow-Origin': '*',
'Access-Control-Allow-Headers':
'Origin, X-Requested-With, Content-Type, Accept, X-Api-Key, Authorization',
'Access-Control-Allow-Credentials': 'true'
@EdyVision
EdyVision / nlmSearch.js
Created June 25, 2019 00:39
NLM Search Service
'use strict';
const apiUtil = require('../../../common/utils/apiUtil');
const baseRxImageUrl = 'http://rximage.nlm.nih.gov/api/rximage/1';
const nlmDataDiscoveryUrl =
'https://datadiscovery.nlm.nih.gov/resource/crzr-uvwg.json?';
/**
@EdyVision
EdyVision / apiUtil.js
Created June 25, 2019 00:41
Drug Search API Util
'use strict';
const axios = require('axios');
exports.submitRequest = async function(url, headers) {
try {
let result = {
statusCode: 500,
data: {}
};
@EdyVision
EdyVision / drugServiceServerless.yml
Last active June 25, 2019 21:09
Drug Service Serverless YML File
# Serverless Drug Search Service
service: drug-search-service
provider:
name: aws
runtime: nodejs8.10
stage: ${opt:stage, 'dev'}
region: us-east-1
apiGateway:
@EdyVision
EdyVision / webpack.config.js
Created June 25, 2019 22:36
Serverless Webpack Config
const slsw = require('serverless-webpack');
const nodeExternals = require('webpack-node-externals');
module.exports = {
entry: slsw.lib.entries,
target: 'node',
devtool: 'source-map',
externals: [nodeExternals()],
mode: slsw.lib.webpack.isLocal ? 'development' : 'production',
optimization: {
@EdyVision
EdyVision / .eslintrc.js
Created June 30, 2019 20:17
Sample eslintrc Config File
module.exports = {
"extends": ['eslint:recommended'], // extending recommended config and config derived from eslint-config-prettier
"plugins": ['prettier'], // activating esling-plugin-prettier (--fix stuff)
"rules": {
'prettier/prettier': [ // customizing prettier rules (unfortunately not many of them are customizable)
'error',
{
"singleQuote": true,
"trailingComma": 'none',
"useTabs": false,
@EdyVision
EdyVision / mocha.opts
Created June 30, 2019 21:22
Mocha Opts File
--timeout 5000
--reporter list
--ui bdd
--exit
test/bootstrap.test.js
test/**/*.test.js
test/**/**/*.test.js
@EdyVision
EdyVision / .travis.yml
Last active July 1, 2019 00:49
Travis Configuration for Serverless NodeJS Projects
language: node_js
node_js:
- "10"
cache:
directories:
- node_modules
install:
- npm install -g serverless
@EdyVision
EdyVision / bootstrap.test.js
Last active July 8, 2019 00:25
Serverless Test Bootstrapping File
/* eslint-disable no-undef */
const { spawn } = require('child_process');
const slsOfflineTestConfig = require('./support/slsOfflineTestConfig');
let slsOfflineProcess;
before(function(done) {
// increase mocha timeout for this hook to allow sls offline to start
this.timeout(30000);