Skip to content

Commit

Permalink
initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
chuckthefrenchie committed Sep 25, 2019
1 parent 63a739e commit 4953e3b
Show file tree
Hide file tree
Showing 22 changed files with 1,413 additions and 0 deletions.
1 change: 1 addition & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
node_modules
39 changes: 39 additions & 0 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
{
"env": {
"browser": true,
"commonjs": true,
"node": true
},
"extends": "prettier",
"plugins": [
"prettier"
],
"rules": {
"no-duplicate-case":"error",
"no-empty":"error",
"no-extra-semi":"error",
"no-func-assign": "error",
"no-irregular-whitespace":"error",
"no-unreachable": "error",
"curly": "error",
"dot-notation": "error",
"eqeqeq": "error",
"no-empty-function": "error",
"no-multi-spaces": "error",
"no-unused-vars": "error",
"camelcase": "error",
"indent": [
"error",
2
],
"quotes": [
"error",
"double"
],
"semi": [
"error",
"always"
],
"prettier/prettier": "error"
}
}
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
.DS_Store
node_modules
npm-debug.log
.env
10 changes: 10 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
language: node_js
node_js: "10"
branches:
only:
- master
cache:
directories:
- node_modules
before_install:
- mysql -e 'CREATE DATABASE testdb;'
21 changes: 21 additions & 0 deletions config/config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"development": {
"username": "root",
"password": null,
"database": "exampledb",
"host": "localhost",
"dialect": "mysql"
},
"test": {
"username": "root",
"password": null,
"database": "testdb",
"host": "localhost",
"dialect": "mysql",
"logging": false
},
"production": {
"use_env_variable": "JAWSDB_URL",
"dialect": "mysql"
}
}
24 changes: 24 additions & 0 deletions example.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
var num_1 = parseInt(prompt("Give me a number!"));
var num_2 = parseInt(prompt("Give me another number!"));
var result;

var operation = prompt("What would you like to do? (add, subtract, multiply, divide)").toUpperCase();

if (operation == "ADD") {
var result = num_1 + num_2;
alert("The sum of " + num_1 + " and " + num_2 + " is " + result);
} else if ( operation === "SUBTRACT")
{
result = num_1 - num_2;
alert("The difference between " + num_1 + " and " + num_2 + " is " + result);
}
else if (operation === "MULTIPLY") {
result = num_1 * num_2;
alert("The product of " + num_1 + " and " + num_2 + " is " + result);
} else if (operation === "DIVIDE") {
result = num_1 / num_2;
alert("The quotient of " + num_1 + " and " + num_2 + " is " + result);
} else {
alert("Not a valid option!");
}

12 changes: 12 additions & 0 deletions index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Calculator</title>
</head>
<body>
<script src="example.js"></script>
</body>
</html>
7 changes: 7 additions & 0 deletions models/example.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
module.exports = function(sequelize, DataTypes) {
var Example = sequelize.define("Example", {
text: DataTypes.STRING,
description: DataTypes.TEXT
});
return Example;
};
42 changes: 42 additions & 0 deletions models/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
"use strict";

var fs = require("fs");
var path = require("path");
var Sequelize = require("sequelize");
var basename = path.basename(module.filename);
var env = process.env.NODE_ENV || "development";
var config = require(__dirname + "/../config/config.json")[env];
var db = {};

if (config.use_env_variable) {
var sequelize = new Sequelize(process.env[config.use_env_variable]);
} else {
var sequelize = new Sequelize(
config.database,
config.username,
config.password,
config
);
}

fs.readdirSync(__dirname)
.filter(function(file) {
return (
file.indexOf(".") !== 0 && file !== basename && file.slice(-3) === ".js"
);
})
.forEach(function(file) {
var model = sequelize.import(path.join(__dirname, file));
db[model.name] = model;
});

Object.keys(db).forEach(function(modelName) {
if (db[modelName].associate) {
db[modelName].associate(db);
}
});

db.sequelize = sequelize;
db.Sequelize = Sequelize;

module.exports = db;
5 changes: 5 additions & 0 deletions models/schema.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
DROP DATABASE IF EXISTS exampledb;
CREATE DATABASE exampledb;

DROP DATABASE IF EXISTS testdb;
CREATE DATABASE testdb;
Loading

0 comments on commit 4953e3b

Please sign in to comment.