Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save fabianwilliams-zz/31b920f82f8cf72234bc to your computer and use it in GitHub Desktop.
Save fabianwilliams-zz/31b920f82f8cf72234bc to your computer and use it in GitHub Desktop.
1. Navigate to the Directory you want your Project to be in
2. install -g express-generator
3. this will install Express Generator Globally on your system if it is not already installed
4. express projectNameHere
5. this creates a bunch of folders and files for you and will give you the scaffolding you need for your project
its install will include packages that may not be installed on your system and not in your packages.json file so
6. npm install
7. thats it. if you run npm start it will spin up your site
8. you can start to use and customize the app.js file typically i will switch the view engine to use ejs over jade
9. locate the line in app.js and change it from jade to ejs
10. go back to terminal and run the command below, you do --save to put it in your package.jsonfile
11. npm install --save ejs
12. rename your files in the View folder from .jade to .ejs and you will need to clean up the file to make it
html friendly.
13. thats it. test your site again
// Now that it is up, you can start to install and use other modules
// Installing Passport to use Social Media as Authentication/Authorization techniques
14. go to terminal and issue command
15. npm install passport --save
16. go to app.js and add it as a require
17. var passport = require('passport');
17. next we need to use it so we needs to set up the middleware
18. app.use(passport.initialize());
19. app.use(passport.session());
20. we will also need express session so we need to install that as well and use it
21. npm install express-session --save
21. we need to require it
22. var session = require('express-session');
23. app.use(session({secret: 'abc123'})); // session needs a secret that can be anyting
24. we will need to have passport put a user into asession
25. passport.serializeUser(function(user, done{
done(null, user)
});
26. passport.deserializeUser(function(userId, done{
done(null, user)
});
27. now that passport is set up we need to get a OAuth Strategy for any Social Media you want
28. You can find a bunch of strategies from npmjs.com and search for it
29.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment