From d9c9353f1ad1b776465edd72fa90970fb045bcb3 Mon Sep 17 00:00:00 2001 From: benoit nguyen Date: Sun, 15 Jan 2017 16:26:14 +0100 Subject: [PATCH] ready to angular go... at last --- .gitignore | 1 + app.js | 32 ++++++++++++----------- bower.json | 2 +- package.json | 1 + public/app_client/index.html | 50 ++++++++++++------------------------ public/app_client/routes.js | 1 - 6 files changed, 36 insertions(+), 51 deletions(-) diff --git a/.gitignore b/.gitignore index 162c95d..a6f73c2 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ node_modules public/app_client/vendors +public/npm-debug.log diff --git a/app.js b/app.js index 198a6a7..12fa36a 100644 --- a/app.js +++ b/app.js @@ -15,6 +15,16 @@ var bodyParser = require('body-parser') var app = express() var server = require('http').createServer(app) +// app config ================================================ + +app.use(logger('dev')); +app.use(bodyParser.json()); +app.use(bodyParser.urlencoded({ extended: false })); +app.use(cookieParser()); +app.use(morgan('dev')); +app.use(passport.initialize()) +app.use(express.static(path.join(__dirname, 'public'))); + // connection to DB ========================================== var dbconnection = require('./app_server/models/connect_db').connectdb() @@ -26,33 +36,26 @@ require('./app_server/config/passport'); var CtrlAuth = require('./app_server/controllers/authentication'); var CtrlProfile = require('./app_server/controllers/profile'); -// what part is this ? ======================================= - -app.use(logger('dev')); -app.use(bodyParser.json()); -app.use(bodyParser.urlencoded({ extended: false })); -app.use(cookieParser()); -app.use(morgan('dev')); -app.use(passport.initialize()) // Routes =================================================== +app.use('/public', express.static(__dirname + '/public')); +app.use('/app_client', express.static(__dirname + '/public/app_client')); +app.use('/vendors', express.static(__dirname + '/public/app_client/vendors')); + var routesApi = require('./app_server/routes/users') app.use(passport.initialize()); app.use('/api', routesApi); -// var routeur = require('./app_server/routes/index') -// app.use(app.router); -// app.use(express.static()) -app.get('*', function(req, res) { - res.sendFile(path.join(__dirname, 'public/app_client/index.html')) +app.get('/', function(req, res) { + res.sendFile('index.html', { root: path.join(__dirname, './public/app_client') }) }); + // Default Port ============================================= var PORT = ( process.env.PORT || 8080 ); // error handlers =========================================== -// Catch unauthorised errors (see index.js routes) app.use(function (err, req, res, next) { if (err.name === 'UnauthorizedError') { @@ -61,7 +64,6 @@ app.use(function (err, req, res, next) { } }); - server.listen(PORT, function() { console.log("Party started at http://localhost:" + PORT); }); diff --git a/bower.json b/bower.json index 22920ac..f3f6ee2 100644 --- a/bower.json +++ b/bower.json @@ -2,7 +2,7 @@ "name": "twittermean", "version": "0.0.0", "dependencies": { - "angular": "^1.5.8", + "angular": "latest", "angular-local-storage": "^0.5.0", "angular-jwt": "^0.1.3", "angular-socket-io": "^0.7.0", diff --git a/package.json b/package.json index 8a9294c..c19b3b3 100644 --- a/package.json +++ b/package.json @@ -17,6 +17,7 @@ "mongoose": "^4.7.6", "morgan": "~1.7.0", "passport": "^0.3.2", + "passport-local": "^1.0.0", "serve-favicon": "~2.3.0" }, "devDependencies": { diff --git a/public/app_client/index.html b/public/app_client/index.html index 30cbccc..a9805b1 100644 --- a/public/app_client/index.html +++ b/public/app_client/index.html @@ -1,50 +1,32 @@ - + Register momo - - - - - - + + + - - + + + + + - - - - - - - - - - - + + + + + - - -

BONJOUR

- - - - + +

YOW

diff --git a/public/app_client/routes.js b/public/app_client/routes.js index 6e81ab8..603501a 100644 --- a/public/app_client/routes.js +++ b/public/app_client/routes.js @@ -6,7 +6,6 @@ app.config(function($stateProvider, $urlRouterProvider) { url: '/register', templateUrl: '/views/register.html', controller: 'registerController' - }) })