Browse Source

initial commit

master
Rich Brown 1 year ago
commit
c6e73e9e37
8 changed files with 6612 additions and 0 deletions
  1. +8
    -0
      .eslintrc.js
  2. +73
    -0
      .gitignore
  3. +173
    -0
      build/main.js
  4. +1
    -0
      build/main.map
  5. +6282
    -0
      package-lock.json
  6. +29
    -0
      package.json
  7. +30
    -0
      routes/blog-router.js
  8. +16
    -0
      src/index.js

+ 8
- 0
.eslintrc.js View File

@@ -0,0 +1,8 @@
module.exports = {
"extends": "airbnb",
"plugins": [
"react",
"jsx-a11y",
"import"
]
};

+ 73
- 0
.gitignore View File

@@ -0,0 +1,73 @@
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*

# Runtime data
pids
*.pid
*.seed
*.pid.lock

# Directory for instrumented libs generated by jscoverage/JSCover
lib-cov

# Coverage directory used by tools like istanbul
coverage

# nyc test coverage
.nyc_output

# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
.grunt

# Bower dependency directory (https://bower.io/)
bower_components

# node-waf configuration
.lock-wscript

# Compiled binary addons (https://nodejs.org/api/addons.html)
build/Release

# Dependency directories
node_modules/
jspm_packages/

# TypeScript v1 declaration files
typings/

# Optional npm cache directory
.npm

# Optional eslint cache
.eslintcache

# Optional REPL history
.node_repl_history

# Output of 'npm pack'
*.tgz

# Yarn Integrity file
.yarn-integrity

# dotenv environment variables file
.env

# parcel-bundler cache (https://parceljs.org/)
.cache

# next.js build output
.next

# nuxt.js build output
.nuxt

# vuepress build output
.vuepress/dist

# Serverless directories
.serverless

+ 173
- 0
build/main.js View File

@@ -0,0 +1,173 @@
require('source-map-support/register')
module.exports =
/******/ (function(modules) { // webpackBootstrap
/******/ // The module cache
/******/ var installedModules = {};
/******/
/******/ // The require function
/******/ function __webpack_require__(moduleId) {
/******/
/******/ // Check if module is in cache
/******/ if(installedModules[moduleId]) {
/******/ return installedModules[moduleId].exports;
/******/ }
/******/ // Create a new module (and put it into the cache)
/******/ var module = installedModules[moduleId] = {
/******/ i: moduleId,
/******/ l: false,
/******/ exports: {}
/******/ };
/******/
/******/ // Execute the module function
/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
/******/
/******/ // Flag the module as loaded
/******/ module.l = true;
/******/
/******/ // Return the exports of the module
/******/ return module.exports;
/******/ }
/******/
/******/
/******/ // expose the modules object (__webpack_modules__)
/******/ __webpack_require__.m = modules;
/******/
/******/ // expose the module cache
/******/ __webpack_require__.c = installedModules;
/******/
/******/ // define getter function for harmony exports
/******/ __webpack_require__.d = function(exports, name, getter) {
/******/ if(!__webpack_require__.o(exports, name)) {
/******/ Object.defineProperty(exports, name, {
/******/ configurable: false,
/******/ enumerable: true,
/******/ get: getter
/******/ });
/******/ }
/******/ };
/******/
/******/ // getDefaultExport function for compatibility with non-harmony modules
/******/ __webpack_require__.n = function(module) {
/******/ var getter = module && module.__esModule ?
/******/ function getDefault() { return module['default']; } :
/******/ function getModuleExports() { return module; };
/******/ __webpack_require__.d(getter, 'a', getter);
/******/ return getter;
/******/ };
/******/
/******/ // Object.prototype.hasOwnProperty.call
/******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
/******/
/******/ // __webpack_public_path__
/******/ __webpack_require__.p = "/";
/******/
/******/ // Load entry module and return exports
/******/ return __webpack_require__(__webpack_require__.s = 1);
/******/ })
/************************************************************************/
/******/ ([
/* 0 */
/***/ (function(module, exports) {

module.exports = require("express");

/***/ }),
/* 1 */
/***/ (function(module, exports, __webpack_require__) {

module.exports = __webpack_require__(2);


/***/ }),
/* 2 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {

"use strict";
Object.defineProperty(__webpack_exports__, "__esModule", { value: true });
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_express__ = __webpack_require__(0);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_express___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_0_express__);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1_cors__ = __webpack_require__(3);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1_cors___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_1_cors__);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2_compression__ = __webpack_require__(4);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2_compression___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_2_compression__);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_3__routes_blog_router__ = __webpack_require__(5);






const app = __WEBPACK_IMPORTED_MODULE_0_express___default()();

app.use(__WEBPACK_IMPORTED_MODULE_2_compression___default()());
app.use(__WEBPACK_IMPORTED_MODULE_1_cors___default()());
app.use(__WEBPACK_IMPORTED_MODULE_0_express___default.a.urlencoded({ extended: false }));
app.use(__WEBPACK_IMPORTED_MODULE_0_express___default.a.json());
app.use('/blog', __WEBPACK_IMPORTED_MODULE_3__routes_blog_router__["a" /* blogRouter */]);
app.get('*', (req, res) => res.senStatus(404));

app.listen(8081, () => console.log('On 8081')); //eslint-disable-line

/***/ }),
/* 3 */
/***/ (function(module, exports) {

module.exports = require("cors");

/***/ }),
/* 4 */
/***/ (function(module, exports) {

module.exports = require("compression");

/***/ }),
/* 5 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {

"use strict";
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_express__ = __webpack_require__(0);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_express___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_0_express__);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1_axios__ = __webpack_require__(6);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1_axios___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_1_axios__);




__webpack_require__(7).config();

const blogRouter = __WEBPACK_IMPORTED_MODULE_0_express___default.a.Router();
/* harmony export (immutable) */ __webpack_exports__["a"] = blogRouter;
//eslint-disable-line

blogRouter.post('/notify', async (req, res) => {
const toSlack = {};
if (req.body.email) {
toSlack.email = req.body.email;
}

if (req.body.textarea) {
toSlack.textarea = req.body.textarea;
}

__WEBPACK_IMPORTED_MODULE_1_axios___default.a.post(process.env.WEBHOOK, {
text: `got a blog inquiry: ${JSON.stringify(toSlack)}`
}, {
headers: { 'Content-type': 'application/json' }
}).then(() => res.send({ message: `received ${req.body.email} and alerting admins` })).catch(e => console.log(e)); //eslint-disable-line
});

/***/ }),
/* 6 */
/***/ (function(module, exports) {

module.exports = require("axios");

/***/ }),
/* 7 */
/***/ (function(module, exports) {

module.exports = require("dotenv");

/***/ })
/******/ ]);
//# sourceMappingURL=main.map

+ 1
- 0
build/main.map
File diff suppressed because it is too large
View File


+ 6282
- 0
package-lock.json
File diff suppressed because it is too large
View File


+ 29
- 0
package.json View File

@@ -0,0 +1,29 @@
{
"name": "@shoesandsocks/notifier",
"version": "1.0.0",
"description": "a personal slack notifier",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"dev": "backpack",
"build": "backpack build",
"start": "npm run build && node ./src/index.js"
},
"author": "",
"license": "ISC",
"dependencies": {
"axios": "^0.18.0",
"backpack-core": "^0.7.0",
"compression": "^1.7.3",
"cors": "^2.8.4",
"dotenv": "^6.0.0",
"express": "^4.16.3"
},
"devDependencies": {
"eslint": "^5.6.1",
"eslint-config-airbnb": "^17.1.0",
"eslint-plugin-import": "^2.14.0",
"eslint-plugin-jsx-a11y": "^6.1.1",
"eslint-plugin-react": "^7.11.1"
}
}

+ 30
- 0
routes/blog-router.js View File

@@ -0,0 +1,30 @@

import express from 'express';
import axios from 'axios';

require('dotenv').config();

export const blogRouter = express.Router(); //eslint-disable-line

blogRouter.post('/notify', async (req, res) => {
const toSlack = {};
if (req.body.email) {
toSlack.email = req.body.email;
}

if (req.body.textarea) {
toSlack.textarea = req.body.textarea;
}

axios.post(
process.env.WEBHOOK,
{
text: `got a blog inquiry: ${JSON.stringify(toSlack)}`,
},
{
headers: { 'Content-type': 'application/json' },
},
)
.then(() => res.send({ message: `received ${req.body.email} and alerting admins` }))
.catch(e => console.log(e)); //eslint-disable-line
});

+ 16
- 0
src/index.js View File

@@ -0,0 +1,16 @@
import express from 'express';
import cors from 'cors';
import compression from 'compression';

import { blogRouter } from '../routes/blog-router';

const app = express();

app.use(compression());
app.use(cors());
app.use(express.urlencoded({ extended: false }));
app.use(express.json());
app.use('/blog', blogRouter);
app.get('*', (req, res) => res.senStatus(404));

app.listen(8081, () => console.log('On 8081')); //eslint-disable-line

Loading…
Cancel
Save