Cleanup and refactoring
parent
e9add46005
commit
26ddda1c0a
|
@ -17,5 +17,6 @@ npm-debug.log
|
|||
node_modules
|
||||
.idea
|
||||
.DS_Store
|
||||
Thumbs.db
|
||||
|
||||
public/vendor
|
20
LICENSE
20
LICENSE
|
@ -1,20 +0,0 @@
|
|||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2013 Sahat Yalkabov
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
this software and associated documentation files (the "Software"), to deal in
|
||||
the Software without restriction, including without limitation the rights to
|
||||
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
||||
the Software, and to permit persons to whom the Software is furnished to do so,
|
||||
subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
||||
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
||||
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
||||
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
@ -0,0 +1,9 @@
|
|||
Sendgrid
|
||||
Facebook
|
||||
Rdio
|
||||
Tumblr
|
||||
Twitter
|
||||
Twilio
|
||||
Etsy
|
||||
Foursquare
|
||||
New York Times
|
|
@ -3,30 +3,26 @@ var express = require('express'),
|
|||
path = require('path'),
|
||||
fs = require('fs'),
|
||||
mongoose = require('mongoose'),
|
||||
passport = require('passport'),
|
||||
passport = require('passport');
|
||||
|
||||
config = require('./config'),
|
||||
// Configuration (API Keys, Database URI)
|
||||
var config = require('./config.json');
|
||||
|
||||
// Load controllers
|
||||
home = require('./controllers/home'),
|
||||
// Load controllers
|
||||
var home = require('./controllers/home'),
|
||||
api = require('./controllers/api'),
|
||||
auth = require('./controllers/auth'),
|
||||
users = require('./controllers/users');
|
||||
users = require('./controllers/user');
|
||||
|
||||
// Connect to database
|
||||
mongoose.connect(config.db, function(err, res) {
|
||||
if (err) {
|
||||
console.log ('Error connecting to database: ' + err);
|
||||
} else {
|
||||
console.log ('Successfully connected to database!');
|
||||
}
|
||||
});
|
||||
var db = mongoose.connect(config.db);
|
||||
|
||||
var app = module.exports = express();
|
||||
// Initialize express application
|
||||
var app = express();
|
||||
|
||||
app.set('port', process.env.PORT || 3000);
|
||||
app.set('views', __dirname + '/views');
|
||||
app.set('view engine', 'jade');
|
||||
app.set('view engine', 'hbs');
|
||||
app.use(express.logger('dev'));
|
||||
app.use(express.errorHandler());
|
||||
app.use(express.favicon());
|
||||
|
@ -42,14 +38,13 @@ app.use(app.router);
|
|||
// Routes
|
||||
app.get('/', home.index);
|
||||
|
||||
//app.get('/account', auth.ensureAuthenticated, users.account);
|
||||
app.get('/account', auth.ensureAuthenticated, users.account);
|
||||
app.get('/logout', users.logout);
|
||||
app.post('/login', users.postlogin);
|
||||
//app.get('/admin', auth.ensureAuthenticated, auth.ensureAdmin(), users.admin);
|
||||
//app.get('/api/name', api.name);
|
||||
app.get('/admin', auth.ensureAuthenticated, auth.ensureAdmin(), users.admin);
|
||||
app.get('/api/name', api.name);
|
||||
app.get('/partials/login', users.getlogin);
|
||||
app.get('/partials/:name', home.partials);
|
||||
|
||||
app.get('*', home.index);
|
||||
|
||||
|
|
@ -1,6 +1,8 @@
|
|||
var mongoose = require('mongoose'),
|
||||
passport = require('passport'),
|
||||
User = require('../models/user');
|
||||
passport = require('passport');
|
||||
|
||||
// Import models
|
||||
var User = require('../models/user');
|
||||
|
||||
exports.account = function(req, res) {
|
||||
res.render('account', { user: req.user });
|
|
@ -1,5 +1,6 @@
|
|||
var mongoose = require('mongoose'),
|
||||
bcrypt = require('bcrypt');
|
||||
bcrypt = require('bcrypt');
|
||||
|
||||
|
||||
var userSchema = new mongoose.Schema({
|
||||
username: { type: String, required: true, unique: true },
|
||||
|
|
|
@ -9,6 +9,7 @@
|
|||
"passport": "latest",
|
||||
"passport-local": "latest",
|
||||
"underscore": "latest",
|
||||
"forever": "latest"
|
||||
}
|
||||
}
|
||||
"forever": "latest",
|
||||
"hbs": "latest"
|
||||
}
|
||||
}
|
||||
|
|
|
@ -16,8 +16,9 @@ angular.module('myApp', ['ngRoute', 'myApp.filters', 'myApp.services', 'myApp.di
|
|||
templateUrl: 'partials/login',
|
||||
controller: MyCtrl3
|
||||
});
|
||||
$routeProvider.when('/logout', {
|
||||
|
||||
$routeProvider.when('/logout', {
|
||||
controller: MyCtrl4
|
||||
});
|
||||
$routeProvider.otherwise({ redirectTo: '/view1' });
|
||||
$locationProvider.html5Mode(true);
|
||||
|
|
|
@ -19,5 +19,12 @@ MyCtrl1.$inject = [];
|
|||
function MyCtrl2() {
|
||||
}
|
||||
MyCtrl2.$inject = [];
|
||||
|
||||
function MyCtrl3() {}
|
||||
MyCtrl3.$inject = [];
|
||||
|
||||
|
||||
function MyCtrl4($scope, $http) {
|
||||
$http({ method: 'GET', url: '/logout' });
|
||||
}
|
||||
MyCtrl4.$inject = [];
|
||||
|
|
|
@ -26,6 +26,7 @@ block body
|
|||
div(ng-controller='AppCtrl')
|
||||
.jumbotron
|
||||
h1 Hello {{name}}
|
||||
h2 3 times 3 mod 3 is {{3*3%3}}
|
||||
div(ng-view)
|
||||
br
|
||||
button.btn.btn-labeled.btn-success(type='button')
|
||||
|
|
Loading…
Reference in New Issue