Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion README.md

This file was deleted.

5 changes: 5 additions & 0 deletions back-end/.firebaserc
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"projects": {
"default": "sendbyrd"
}
}
67 changes: 67 additions & 0 deletions back-end/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
firebase-debug.log*

# Firebase cache
.firebase/

# Firebase config

# Uncomment this if you'd like others to create their own Firebase project.
# For a team working on the same Firebase project(s), it is recommended to leave
# it commented so all members can deploy to the same project(s) in .firebaserc.
# .firebaserc

# 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 (http://gruntjs.com/creating-plugins#storing-task-files)
.grunt

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

# node-waf configuration
.lock-wscript

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

# Dependency directories
node_modules/

# 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

public/static/
Empty file added back-end/README.md
Empty file.
13 changes: 13 additions & 0 deletions back-end/firebase.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"functions": {
"predeploy": ["npm --prefix \"$RESOURCE_DIR\" run lint"],
"source": "functions"
},
"hosting": {
"public": "public",
"rewrites": [
{ "source": "api{,/**}", "function": "main" }
],
"ignore": ["firebase.json", "**/node_modules/**"]
}
}
123 changes: 123 additions & 0 deletions back-end/functions/.eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,123 @@
{
"parserOptions": {
// Required for certain syntax usages
"ecmaVersion": 2017
},
"plugins": [
"promise"
],
"extends": "eslint:recommended",
"rules": {
// Removed rule "disallow the use of console" from recommended eslint rules
"no-console": "off",

// Removed rule "disallow multiple spaces in regular expressions" from recommended eslint rules
"no-regex-spaces": "off",

// Removed rule "disallow the use of debugger" from recommended eslint rules
"no-debugger": "off",

// Removed rule "disallow unused variables" from recommended eslint rules
"no-unused-vars": "off",

// Removed rule "disallow mixed spaces and tabs for indentation" from recommended eslint rules
"no-mixed-spaces-and-tabs": "off",

// Removed rule "disallow the use of undeclared variables unless mentioned in /*global */ comments" from recommended eslint rules
"no-undef": "off",

// Warn against template literal placeholder syntax in regular strings
"no-template-curly-in-string": 1,

// Warn if return statements do not either always or never specify values
"consistent-return": 1,

// Warn if no return statements in callbacks of array methods
"array-callback-return": 1,

// Require the use of === and !==
"eqeqeq": 2,

// Disallow the use of alert, confirm, and prompt
"no-alert": 2,

// Disallow the use of arguments.caller or arguments.callee
"no-caller": 2,

// Disallow null comparisons without type-checking operators
"no-eq-null": 2,

// Disallow the use of eval()
"no-eval": 2,

// Warn against extending native types
"no-extend-native": 1,

// Warn against unnecessary calls to .bind()
"no-extra-bind": 1,

// Warn against unnecessary labels
"no-extra-label": 1,

// Disallow leading or trailing decimal points in numeric literals
"no-floating-decimal": 2,

// Warn against shorthand type conversions
"no-implicit-coercion": 1,

// Warn against function declarations and expressions inside loop statements
"no-loop-func": 1,

// Disallow new operators with the Function object
"no-new-func": 2,

// Warn against new operators with the String, Number, and Boolean objects
"no-new-wrappers": 1,

// Disallow throwing literals as exceptions
"no-throw-literal": 2,

// Require using Error objects as Promise rejection reasons
"prefer-promise-reject-errors": 2,

// Enforce “for” loop update clause moving the counter in the right direction
"for-direction": 2,

// Enforce return statements in getters
"getter-return": 2,

// Disallow await inside of loops
"no-await-in-loop": 2,

// Disallow comparing against -0
"no-compare-neg-zero": 2,

// Warn against catch clause parameters from shadowing variables in the outer scope
"no-catch-shadow": 1,

// Disallow identifiers from shadowing restricted names
"no-shadow-restricted-names": 2,

// Enforce return statements in callbacks of array methods
"callback-return": 2,

// Require error handling in callbacks
"handle-callback-err": 2,

// Warn against string concatenation with __dirname and __filename
"no-path-concat": 1,

// Prefer using arrow functions for callbacks
"prefer-arrow-callback": 1,

// Return inside each then() to create readable and reusable Promise chains.
// Forces developers to return console logs and http calls in promises.
"promise/always-return": 2,

//Enforces the use of catch() on un-returned promises
"promise/catch-or-return": 2,

// Warn against nested then() or catch() statements
"promise/no-nesting": 1
}
}
1 change: 1 addition & 0 deletions back-end/functions/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
node_modules/
27 changes: 27 additions & 0 deletions back-end/functions/express/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# Getting started

To get the ExpressJS server running locally:

- Clone this repo
- `npm install` to install all required dependencies
- `npm start` to start the local server

## Dependencies

- [expressjs](https://github.com/expressjs/express) - The server for handling and routing HTTP requests
- [body-parser](https://github.com/expressjs/body-parser) - NodeJS body parsing middleware
- [nodemailer](https://github.com/nodemailer/nodemailer) - Send e-mails with NodeJS

## Application Structure

- `app.js` - The entry point to our application. This file defines our express server and connects it to MongoDB using mongoose. It also requires the routes and models we'll be using in the application.
- `routes/` - This folder contains the route definitions for our API.
- `services/` - This folder contains the utilities to handle request.

## Required Environment Variables

- PORT
- DEBUG
- CLIENT_ID
- CLIENT_SECRET
- REDIRECT_URL
27 changes: 27 additions & 0 deletions back-end/functions/express/app.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
var express = require("express");
var path = require("path");

var indexRouter = require("./routes/index");
var mailRouter = require("./routes/mail");

var app = express();

app.use(express.json());
app.use(express.urlencoded({ extended: false }));
// app.use(express.static(path.join(__dirname, "public")));
// app.use(express.multipart());

// Resolve CORS
app.use((req, res, next) => {
res.header("Access-Control-Allow-Origin", "*");
res.header(
"Access-Control-Allow-Headers",
"Origin, X-Requested-With, Content-Type, Accept"
);
next();
});

app.use("/", indexRouter);
app.use("/mail", mailRouter);

module.exports = app;
99 changes: 99 additions & 0 deletions back-end/functions/express/bin/www
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
#!/usr/bin/env node

/**
* Module dependencies.
*/

var app = require("../app");
var debug = require("debug")("back-end:server");
var http = require("http");
// const fs = require("fs");

/**
* Get port from environment and store in Express.
*/

var port = normalizePort(process.env.PORT || "3000");
app.set("port", port);

/**
* Create SSL HTTP server.
*/

// var server = http.createServer(
// {
// key: fs.readFileSync("server.key"),
// cert: fs.readFileSync("server.cert")
// },
// app
// );

/**
* Create HTTP server.
*/
var server = http.createServer(app);

/**
* Listen on provided port, on all network interfaces.
*/

server.listen(port);
server.on("error", onError);
server.on("listening", onListening);
console.log(`ExpressJs Server on PORT ${port} | http:localhost:${port}`)

/**
* Normalize a port into a number, string, or false.
*/

function normalizePort(val) {
var port = parseInt(val, 10);

if (isNaN(port)) {
// named pipe
return val;
}

if (port >= 0) {
// port number
return port;
}

return false;
}

/**
* Event listener for HTTP server "error" event.
*/

function onError(error) {
if (error.syscall !== "listen") {
throw error;
}

var bind = typeof port === "string" ? "Pipe " + port : "Port " + port;

// handle specific listen errors with friendly messages
switch (error.code) {
case "EACCES":
console.error(bind + " requires elevated privileges");
process.exit(1);
break;
case "EADDRINUSE":
console.error(bind + " is already in use");
process.exit(1);
break;
default:
throw error;
}
}

/**
* Event listener for HTTP server "listening" event.
*/

function onListening() {
var addr = server.address();
var bind = typeof addr === "string" ? "pipe " + addr : "port " + addr.port;
debug("Listening on " + bind);
}
Loading