Permalink
Browse files

First initialize

  • Loading branch information...
erayaydin committed Jun 27, 2016
0 parents commit a06d17e919183def80c4e01be36363001a283208
Showing with 23,519 additions and 0 deletions.
  1. +25 −0 .env.example
  2. +29 −0 .gitignore
  3. +85 −0 README.md
  4. +151 −0 app.js
  5. +347 −0 config/passport.js
  6. +9 −0 controllers/home.js
  7. +373 −0 controllers/user.js
  8. +68 −0 models/User.js
  9. +51 −0 package.json
  10. +115 −0 public/css/lib/bootstrap-social.scss
  11. +73 −0 public/css/lib/bootstrap/_alerts.scss
  12. +68 −0 public/css/lib/bootstrap/_badges.scss
  13. +28 −0 public/css/lib/bootstrap/_breadcrumbs.scss
  14. +244 −0 public/css/lib/bootstrap/_button-groups.scss
  15. +168 −0 public/css/lib/bootstrap/_buttons.scss
  16. +270 −0 public/css/lib/bootstrap/_carousel.scss
  17. +36 −0 public/css/lib/bootstrap/_close.scss
  18. +69 −0 public/css/lib/bootstrap/_code.scss
  19. +37 −0 public/css/lib/bootstrap/_component-animations.scss
  20. +216 −0 public/css/lib/bootstrap/_dropdowns.scss
  21. +617 −0 public/css/lib/bootstrap/_forms.scss
  22. +307 −0 public/css/lib/bootstrap/_glyphicons.scss
  23. +84 −0 public/css/lib/bootstrap/_grid.scss
  24. +171 −0 public/css/lib/bootstrap/_input-groups.scss
  25. +54 −0 public/css/lib/bootstrap/_jumbotron.scss
  26. +66 −0 public/css/lib/bootstrap/_labels.scss
  27. +130 −0 public/css/lib/bootstrap/_list-group.scss
  28. +66 −0 public/css/lib/bootstrap/_media.scss
  29. +40 −0 public/css/lib/bootstrap/_mixins.scss
  30. +150 −0 public/css/lib/bootstrap/_modals.scss
  31. +662 −0 public/css/lib/bootstrap/_navbar.scss
  32. +242 −0 public/css/lib/bootstrap/_navs.scss
  33. +424 −0 public/css/lib/bootstrap/_normalize.scss
  34. +54 −0 public/css/lib/bootstrap/_pager.scss
  35. +89 −0 public/css/lib/bootstrap/_pagination.scss
  36. +271 −0 public/css/lib/bootstrap/_panels.scss
  37. +131 −0 public/css/lib/bootstrap/_popovers.scss
  38. +101 −0 public/css/lib/bootstrap/_print.scss
  39. +87 −0 public/css/lib/bootstrap/_progress-bars.scss
  40. +35 −0 public/css/lib/bootstrap/_responsive-embed.scss
  41. +179 −0 public/css/lib/bootstrap/_responsive-utilities.scss
  42. +161 −0 public/css/lib/bootstrap/_scaffolding.scss
  43. +234 −0 public/css/lib/bootstrap/_tables.scss
  44. +291 −0 public/css/lib/bootstrap/_theme.scss
  45. +38 −0 public/css/lib/bootstrap/_thumbnails.scss
  46. +101 −0 public/css/lib/bootstrap/_tooltip.scss
  47. +298 −0 public/css/lib/bootstrap/_type.scss
  48. +55 −0 public/css/lib/bootstrap/_utilities.scss
  49. +874 −0 public/css/lib/bootstrap/_variables.scss
  50. +29 −0 public/css/lib/bootstrap/_wells.scss
  51. +56 −0 public/css/lib/bootstrap/bootstrap.scss
  52. +14 −0 public/css/lib/bootstrap/mixins/_alerts.scss
  53. +12 −0 public/css/lib/bootstrap/mixins/_background-variant.scss
  54. +18 −0 public/css/lib/bootstrap/mixins/_border-radius.scss
  55. +65 −0 public/css/lib/bootstrap/mixins/_buttons.scss
  56. +7 −0 public/css/lib/bootstrap/mixins/_center-block.scss
  57. +22 −0 public/css/lib/bootstrap/mixins/_clearfix.scss
  58. +88 −0 public/css/lib/bootstrap/mixins/_forms.scss
  59. +58 −0 public/css/lib/bootstrap/mixins/_gradients.scss
  60. +81 −0 public/css/lib/bootstrap/mixins/_grid-framework.scss
  61. +122 −0 public/css/lib/bootstrap/mixins/_grid.scss
  62. +21 −0 public/css/lib/bootstrap/mixins/_hide-text.scss
  63. +33 −0 public/css/lib/bootstrap/mixins/_image.scss
  64. +12 −0 public/css/lib/bootstrap/mixins/_labels.scss
  65. +32 −0 public/css/lib/bootstrap/mixins/_list-group.scss
  66. +10 −0 public/css/lib/bootstrap/mixins/_nav-divider.scss
  67. +9 −0 public/css/lib/bootstrap/mixins/_nav-vertical-align.scss
  68. +8 −0 public/css/lib/bootstrap/mixins/_opacity.scss
  69. +24 −0 public/css/lib/bootstrap/mixins/_pagination.scss
  70. +24 −0 public/css/lib/bootstrap/mixins/_panels.scss
  71. +10 −0 public/css/lib/bootstrap/mixins/_progress-bar.scss
  72. +8 −0 public/css/lib/bootstrap/mixins/_reset-filter.scss
  73. +18 −0 public/css/lib/bootstrap/mixins/_reset-text.scss
  74. +6 −0 public/css/lib/bootstrap/mixins/_resize.scss
  75. +21 −0 public/css/lib/bootstrap/mixins/_responsive-visibility.scss
  76. +10 −0 public/css/lib/bootstrap/mixins/_size.scss
  77. +9 −0 public/css/lib/bootstrap/mixins/_tab-focus.scss
  78. +28 −0 public/css/lib/bootstrap/mixins/_table-row.scss
  79. +12 −0 public/css/lib/bootstrap/mixins/_text-emphasis.scss
  80. +8 −0 public/css/lib/bootstrap/mixins/_text-overflow.scss
  81. +222 −0 public/css/lib/bootstrap/mixins/_vendor-prefixes.scss
  82. +34 −0 public/css/lib/font-awesome/_animated.scss
  83. +25 −0 public/css/lib/font-awesome/_bordered-pulled.scss
  84. +12 −0 public/css/lib/font-awesome/_core.scss
  85. +6 −0 public/css/lib/font-awesome/_fixed-width.scss
  86. +697 −0 public/css/lib/font-awesome/_icons.scss
  87. +13 −0 public/css/lib/font-awesome/_larger.scss
  88. +19 −0 public/css/lib/font-awesome/_list.scss
  89. +26 −0 public/css/lib/font-awesome/_mixins.scss
  90. +15 −0 public/css/lib/font-awesome/_path.scss
  91. +20 −0 public/css/lib/font-awesome/_rotated-flipped.scss
  92. +20 −0 public/css/lib/font-awesome/_stacked.scss
  93. +708 −0 public/css/lib/font-awesome/_variables.scss
  94. +17 −0 public/css/lib/font-awesome/font-awesome.scss
  95. +8,827 −0 public/css/main.css
  96. +71 −0 public/css/main.scss
  97. +51 −0 public/css/themes/default/_default.scss
  98. +60 −0 public/css/themes/default/_variables.scss
  99. +331 −0 public/css/themes/flatly/_flatly.scss
  100. +868 −0 public/css/themes/flatly/_variables.scss
  101. +892 −0 public/css/themes/ios7/_ios7.scss
  102. +92 −0 public/css/themes/modern/_modern.scss
  103. +68 −0 public/css/themes/modern/_variables.scss
  104. BIN public/favicon.png
  105. BIN public/fonts/FontAwesome.otf
  106. BIN public/fonts/fontawesome-webfont.eot
  107. +655 −0 public/fonts/fontawesome-webfont.svg
  108. BIN public/fonts/fontawesome-webfont.ttf
  109. BIN public/fonts/fontawesome-webfont.woff
  110. BIN public/fonts/fontawesome-webfont.woff2
  111. +7 −0 public/js/lib/bootstrap.min.js
  112. +4 −0 public/js/lib/jquery-2.2.0.min.js
  113. +5 −0 public/js/main.js
  114. +34 −0 test/app.js
  115. +46 −0 test/models.js
  116. +27 −0 views/home/index.jade
  117. +33 −0 views/layout.jade
  118. +18 −0 views/partials/flash.jade
  119. +8 −0 views/partials/footer.jade
  120. +36 −0 views/partials/header.jade
  121. +15 −0 views/user/forgot.jade
  122. +41 −0 views/user/login.jade
  123. +106 −0 views/user/profile.jade
  124. +24 −0 views/user/register.jade
  125. +17 −0 views/user/reset.jade
@@ -0,0 +1,25 @@
MONGODB_URI=mongodb://localhost:27017/dbname
MONGOLAB_URI=mongodb://localhost:27017/dbname
SESSION_SECRET=Your Session Secret goes here
MAILGUN_USER=
MAILGUN_PASSWORD=
SENDGRID_USER=
SENDGRID_PASSWORD=
FACEBOOK_ID=
FACEBOOK_SECRET=
GITHUB_ID=
GITHUB_SECRET=
TWITTER_KEY=
TWITTER_SECRET=
GOOGLE_ID=
GOOGLE_SECRET=
INSTAGRAM_ID=
INSTAGRAM_SECRET=
@@ -0,0 +1,29 @@
lib-cov
*.seed
*.log
*.csv
*.dat
*.out
*.pid
*.gz
*.swp
pids
logs
results
tmp
# API keys and secrets
.env
# Dependency directory
node_modules
bower_components
# Editors
.idea
*.iml
# OS metadata
.DS_Store
Thumbs.db
@@ -0,0 +1,85 @@
HolyJS
======
This project based on [Hackathon Starter](https://github.com/sahat/hackathon-starter)
Project starter for **Node.js** web applications.
## Features
- **.env** environment variables
- **Local Authentication** using *Email* and *Password*
- **Authentication** via Twitter, Facebook, Google, Github, instagram
- **Flash Notifications** like success, error and info
- **MVC** project structure
- **Ready, Account Management**
- Gravatar
- Profile Details
- Change Password
- Forgot Password (Reset)
- Linking multiple social accounts to one account
- Delete Account
- **CSRF** Protection
## Prerequisites
- MongoDB
- NodeJS
## Project structure
| Name | Description |
| ----------------------------- | -------------------------------------------------------------- |
| **config**/passport.js | Passport Strategies, Login Middleware |
| **controllers**/home.js | Controller for home page |
| **controllers**/user.js | Controller for user account management |
| **models**/User.js | User model |
| **public**/ | Static files (fonts, css, js, images) |
| **views**/ | Template files |
| **views**/layout.jade | Main layout template |
| **views**/partials/flash.jade | Flash notifications **success** **info** **error** |
| **test**/app.js | Application test cases |
| **test**/models.js | Model test cases |
| .travis.yml | [Travis CI](https://travis-ci.org/) integration |
| .env.example | Example file for API keys, tokens, passwords and database info |
| .env | Must be created manually from example |
| app.js | The main application file |
| package.json | NPM dependencies and project info |
## Packages
| Package | Description |
| --------------------- | ------------------------------------------------------------ |
| async | Library for asynchronous control flow. |
| bcrypt-nodejs | Hashing and salting passwords. |
| connect-mongo | MongoDB session store for Express. |
| dotenv | .env file environment variables. |
| express | Node.js Web Framework. |
| body-parser | Express 4 middleware for parse request bodies. |
| express-session | Express 4 middleware for session store. |
| morgan | HTTP request logger. |
| compression | `deflate` and `gzip` compressions. |
| errorhandler | Express 4 middleware for error handling. |
| serve-favicon | Express 4 middleware for serving favicon. (also caching) |
| express-flash | Express 4 flash messages. |
| express-validator | Express 4 middleware for string validation and sanitization. |
| jade | Template engine. |
| lusca | CSRF middleware. |
| mongoose | MongoDB ORM. |
| nodemailer | Node.js library for sending emails. |
| passport | Authentication library. |
| passport-facebook | Sign-in with Facebook. |
| passport-github | Sign-in with GitHub. |
| passport-google-oauth | Sign-in with Google. |
| passport-twitter | Sign-in with Twitter. |
| passport-instagram | Sign-in with Instagram. |
| passport-local | Sign-in with username and password. |
| passport-oauth | OAuth 1.0a and OAuth 2.0 strategies. |
| request | HTTP request library. |
| lodash | Javascript utilities library. |
## Development Packages
| Package | Description |
| --------------------- | -------------------------- |
| mocha | Test framework. |
| supertest | HTTP assertion library. |
| chai | BDD/TDD assertion library. |
151 app.js
@@ -0,0 +1,151 @@
/**
* Module Dependencies
*/
const express = require('express');
const compression = require('compression');
const session = require('express-session');
const bodyParser = require('body-parser');
const logger = require('morgan');
const errorHandler = require('errorhandler');
const lusca = require('lusca');
const dotenv = require('dotenv');
const MongoStore = require('connect-mongo')(session);
const flash = require('express-flash');
const path = require('path');
const mongoose = require('mongoose');
const passport = require('passport');
const expressValidator = require('express-validator');
const sass = require('node-sass-middleware');
const multer = require('multer');
const upload = multer({ dest: path.join(__dirname, 'uploads') });
/**
* Load environment variables such as api keys, passwords
*/
dotenv.load({ path: '.env' });
/**
* Controllers
*/
const homeController = require('./controllers/home');
const userController = require('./controllers/user');
/**
* API keys and Password Configuration
*/
const passportConfig = require('./config/passport');
/**
* Express Server
*/
const app = express();
/**
* Connect to MongoDB
*/
mongoose.connect(process.env.MONGODB_URI || process.env.MONGOLAB_URI);
mongoose.connection.on('error', () => {
console.log('MongoDB connection error. Please make sure that MongoDB is running.');
process.exit(1);
});
/**
* Express Configuration
*/
app.set('port', process.env.PORT || 3000);
app.set('views', path.join(__dirname, 'views'));
app.set('view engine', 'jade');
app.use(compression());
app.use(sass({
src: path.join(__dirname, 'public'),
dest: path.join(__dirname, 'public')
}));
app.use(logger('dev'));
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({ extended: true }));
app.use(expressValidator());
app.use(session({
resave: true,
saveUninitialized: true,
secret: process.env.SESSION_SECRET,
store: new MongoStore({
url: process.env.MONGODB_URI || process.env.MONGOLAB_URI,
autoReconnect: true
})
}));
app.use(passport.initialize());
app.use(passport.session());
app.use(flash());
app.use((req, res, next) => {
lusca.csrf()(req, res, next);
});
app.use(lusca.xframe('SAMEORIGIN'));
app.use(lusca.xssProtection(true));
app.use((req, res, next) => {
res.locals.user = req.user;
next();
});
app.use((req, res, next) => {
if(/(api)|(contact)|(^\/$)/i.test(req.path)) {
req.session.returnTo = req.path;
}
next();
});
app.use(express.static(path.join(__dirname, 'public'), { maxAge: 31557600000 }));
/**
* Routes
*/
app.get('/', homeController.index);
app.get('/login', userController.login);
app.post('/login', userController.doLogin);
app.get('/logout', passportConfig.isAuthenticated, userController.logout);
app.get('/forgot', userController.forgot);
app.post('/forgot', userController.doForgot);
app.get('/reset/:token', userController.reset);
app.post('/reset/:token', userController.doReset);
app.get('/register', userController.register);
app.post('/register', userController.doRegister);
app.get('/account', passportConfig.isAuthenticated, userController.account);
app.post('/account/profile', passportConfig.isAuthenticated, userController.updateProfile);
app.post('/account/password', passportConfig.isAuthenticated, userController.updatePassword);
app.post('/account/delete', passportConfig.isAuthenticated, userController.deleteAccount);
app.get('/account/unlink/:provider', passportConfig.isAuthenticated, userController.oauthUnlink);
/**
* OAuth Authentication Routes
*/
app.get('/auth/facebook', passport.authenticate('facebook', { scope: ['email', 'user_location'] }));
app.get('/auth/facebook/callback', passport.authenticate('facebook', { failureRedirect: '/login' }), (req, res) => {
res.redirect(req.session.returnTo || '/');
});
app.get('/auth/twitter', passport.authenticate('twitter'));
app.get('/auth/twitter/callback', passport.authenticate('twitter', { failureRedirect: '/login' }), (req, res) => {
res.redirect(req.session.returnTo || '/');
});
app.get('/auth/github', passport.authenticate('github'));
app.get('/auth/github/callback', passport.authenticate('github', { failureRedirect: '/login' }), (req, res) => {
res.redirect(req.session.returnTo || '/');
});
app.get('/auth/google', passport.authenticate('google', { scope: 'profile email' }));
app.get('/auth/google/callback', passport.authenticate('google', { failureRedirect: '/login' }), (req, res) => {
res.redirect(req.session.returnTo || '/');
});
app.get('/auth/instagram', passport.authenticate('instagram'));
app.get('/auth/instagram/callback', passport.authenticate('instagram', { failureRedirect: '/login' }), (req, res) => {
res.redirect(req.session.returnTo || '/');
});
/**
* Error Handler
*/
app.use(errorHandler());
/**
* Start Express Server
*/
app.listen(app.get('port'), () => {
console.log('Express server listening on port %d in %s mode', app.get('port'), app.get('env'));
});
module.exports = app;
Oops, something went wrong.

0 comments on commit a06d17e

Please sign in to comment.