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
14 changes: 13 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,18 @@ A mongodb database named lizardboard must be created prior to starting the appli
- brew install mongodb
- Ensure `mongo` is running
- yarn install
- yarn start (start the server)

Lizardboard needs an .env file to specify environment variables that are required to run the application.
``` echo MONGODB_URI=mongodb://localhost/lizardboard >> .env
echo PORT=3000 >> .env
echo [email protected] >> .env
echo MAILER_PASSWORD=lizardmail! >> .env
```

## (Optional) Configuration for testing
- recommended - utilize Postman and Robomongo to test api routing


## Technical Stack

Expand All @@ -31,4 +43,4 @@ A mongodb database named lizardboard must be created prior to starting the appli
- [React](https://facebook.github.io/react/)

## Testing
TBD
TBD
5 changes: 5 additions & 0 deletions bin/www
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,18 @@ var app = require('../server/index');
var debug = require('debug')('src:server');
var http = require('http');

const mongoose = require('mongoose')
mongoose.Promise = global.Promise
const connection = process.env.MONGODB_URI
/**
* Get port from environment and store in Express.
*/

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

mongoose.connect( connection )
.then( () => server.listen( port ) )
/**
* Create HTTP server.
*/
Expand Down
7 changes: 7 additions & 0 deletions config/config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
const fs = require('fs')

if( fs.existsSync( '.env' ) ) {
require( 'dotenv' ).config()
} else {
console.log( ".env not found, skipping dotenv config" )
}
11 changes: 11 additions & 0 deletions models/dashboard.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
const mongoose = require('mongoose')
const { Schema } = mongoose

const DashboardSchema = mongoose.Schema ({
user: {type: Number, ref: 'User'},
widgets: [{type: Schema.Types.ObjectId, ref:'Widget'}]
})

const Dashboard = mongoose.model('Dashboard', DashboardSchema)

module.exports = Dashboard
11 changes: 11 additions & 0 deletions models/user.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
const mongoose = require('mongoose')
const { Schema } = mongoose

const UserSchema = new Schema ({
username: String,
email: String
})

const User = mongoose.model( 'User', UserSchema )

module.exports = User
13 changes: 13 additions & 0 deletions models/widget.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
const mongoose = require('mongoose')
const { Schema } = mongoose

const WidgetSchema = new Schema ({
type: String,
title: String,
size: String,
contents: String
})

const Widget = mongoose.model( 'Widget', WidgetSchema )

module.exports = Widget
6 changes: 5 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,14 @@
"body-parser": "~1.15.1",
"cookie-parser": "~1.4.3",
"debug": "~2.2.0",
"dotenv": "^2.0.0",
"ejs": "^2.5.2",
"express": "~4.13.4",
"mongoose": "^4.6.5",
"mongoose": "^4.6.6",
"morgan": "~1.7.0",
"nodemailer": "^2.6.4",
"nodemailer-sendgrid-transport": "^0.2.0",
"nodemailer-smtp-transport": "^2.7.2",
"pug": "^2.0.0-beta6",
"react": "^15.3.2",
"react-dom": "^15.3.2",
Expand Down
11 changes: 5 additions & 6 deletions routes/index.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
const express = require('express');
const router = express.Router();
const express = require('express')
const router = express.Router()

/* GET home page. */
router.get('/', (request, response, next) => {
response.render('index', { title: 'Dragonboard', logo: 'D' });
});
response.render('index', { title: 'Dragonboard', logo: 'D' })
})

module.exports = router;
module.exports = router
21 changes: 14 additions & 7 deletions routes/users.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,16 @@
const express = require('express');
const router = express.Router();
const express = require('express')
const router = express.Router()
const mongoose = require('mongoose')
const User = require('../models/user.js')
const { sendWelcomeEmail } = require('../server/mailer/welcomeemail.js')

/* GET users listing. */
router.get('/', (request, response, next) => {
response.send('respond with a resource');
});
router.post( '/', (request, response, next ) => {
User.create( request.body )
.then( user => {
sendWelcomeEmail( user )
response.json( user )
})
.catch( error => next( error) )
})

module.exports = router;
module.exports = router
5 changes: 3 additions & 2 deletions server/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,13 @@ const logger = require('morgan');
const cookieParser = require('cookie-parser');
const bodyParser = require('body-parser');

const env = process.env.NODE_ENV || 'development';
const config = require(__dirname + '/../config/config.js')[env];
const routes = require('../routes/index');
const users = require('../routes/users');

const appRoot = process.env.APP_ROOT
const app = express();

// view engine setup
app.set('views', path.join(__dirname, '../views'));
app.set('view engine', 'pug');
Expand Down Expand Up @@ -70,4 +71,4 @@ app.use(function(err, req, res, next) {
});


module.exports = app;
module.exports = app;
29 changes: 29 additions & 0 deletions server/mailer/welcomeemail.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
const nodemailer = require('nodemailer')
const smtpTransport = require('nodemailer-smtp-transport')

const mailer_account = {
email: process.env.MAILER_EMAIL,
password: process.env.MAILER_PASSWORD
}
const mailer = nodemailer.createTransport(smtpTransport(
`smtps://${mailer_account.email}:${mailer_account.password}@smtp.gmail.com`)
)

const sendWelcomeEmail = user => {
return mailer.sendMail( welcomeEmail(user.email, user.username) )
}

const welcomeEmail = ( userEmail, userName ) => {
return {
from: '"Lizardboard" <[email protected]>',
to: userEmail,
subject: `Are You Ready For Lizards, ${userName}?`,
text: "Welcome to Lizardboard",
html: `<p style="font-family:serif; font-size:20px">Hi ${userName}, <br>I wanted to personally welcome you and
congratulate you on joining Lizardboard. <br>We've made it super easy
to get started. Just start! <br> Cheers, <br>The Lizardboard Team </p>`
}
}


module.exports = { sendWelcomeEmail }
2 changes: 0 additions & 2 deletions views/layout.pug
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,3 @@ html
div.footer-nav

include footer
script(src="/javascripts/index.js")
script(src="/public/javascripts/index.js")
27 changes: 17 additions & 10 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -109,11 +109,11 @@ async@~0.2.6:
version "0.2.10"
resolved "https://registry.yarnpkg.com/async/-/async-0.2.10.tgz#b6bbe0b0674b9d719708ca38de8c237cb526c3d1"

async@2.0.1:
version "2.0.1"
resolved "https://registry.yarnpkg.com/async/-/async-2.0.1.tgz#b709cc0280a9c36f09f4536be823c838a9049e25"
async@2.1.2:
version "2.1.2"
resolved "https://registry.yarnpkg.com/async/-/async-2.1.2.tgz#612a4ab45ef42a70cde806bad86ee6db047e8385"
dependencies:
lodash "^4.8.0"
lodash "^4.14.0"

asynckit@^0.4.0:
version "0.4.0"
Expand Down Expand Up @@ -916,6 +916,10 @@ doctypes@^1.1.0:
version "1.1.0"
resolved "https://registry.yarnpkg.com/doctypes/-/doctypes-1.1.0.tgz#ea80b106a87538774e8a3a4a5afe293de489e0a9"

dotenv:
version "2.0.0"
resolved "https://registry.yarnpkg.com/dotenv/-/dotenv-2.0.0.tgz#bd759c357aaa70365e01c96b7b0bec08a6e0d949"

duplexer@~0.1.1:
version "0.1.1"
resolved "https://registry.yarnpkg.com/duplexer/-/duplexer-0.1.1.tgz#ace6ff808c1ce66b57d1ebf97977acb02334cfc1"
Expand Down Expand Up @@ -1681,7 +1685,11 @@ lodash.restparam@^3.0.0:
version "3.6.1"
resolved "https://registry.yarnpkg.com/lodash.restparam/-/lodash.restparam-3.6.1.tgz#936a4e309ef330a7645ed4145986c85ae5b20805"

lodash@^4.2.0, lodash@^4.8.0:
lodash@^4.14.0:
version "4.16.6"
resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.16.6.tgz#d22c9ac660288f3843e16ba7d2b5d06cca27d777"

lodash@^4.2.0:
version "4.16.5"
resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.16.5.tgz#77d88feac548009b1a5c4ca7b49ac431ce346ae8"

Expand Down Expand Up @@ -1798,11 +1806,11 @@ [email protected]:
mongodb-core "2.0.13"
readable-stream "2.1.5"

mongoose@^4.6.5:
version "4.6.5"
resolved "https://registry.yarnpkg.com/mongoose/-/mongoose-4.6.5.tgz#74eed37312e557c391d428c0cf3c8b8eb8959515"
mongoose:
version "4.6.6"
resolved "https://registry.yarnpkg.com/mongoose/-/mongoose-4.6.6.tgz#62817b63804dcefd2e5c6f7e6a9bb68e30811968"
dependencies:
async "2.0.1"
async "2.1.2"
bson "~0.5.4"
hooks-fixed "1.2.0"
kareem "1.1.3"
Expand Down Expand Up @@ -2792,4 +2800,3 @@ yargs@~3.10.0:
cliui "^2.1.0"
decamelize "^1.0.0"
window-size "0.1.0"