Skip to content

markreid/esp

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

esp

A really simple boilerplate for getting an app with Express, Socket.IO and Passport up and running.

I find myself starting a lot of apps with this setup so I figured I'd knock up a quick boilerplate that just covers the basics of setting up an OAuth2-based authentication with Passport and applying it to a simple Express app with Socket.io integration for realtime sockety goodness.

Running the demo app

This repo is intended as more of a guide, but if you want you can fairly easily run the app.

I've used the Google OAuth2 strategy because that's the one I use most frequently. You can trivially switch it out for another strategy, or you can get your own Google OAuth 2 credentials and run it.

To get it going:

npm install
# copy config.js.example to config.js and edit your configuration
npm run start

notes

Session Stores

We use MemoryStore as the session store, which you shouldn't do in production. In a real app you'll want to switch it out with something else.

Express middleware

There are two things you need to consider when using middleware to change the behaviour of routes:

  • Middleware must be declared BEFORE the route (ie app.use before app.get or app.route)
  • App routes will run any middleware that matches the beginning of the path. ie, app.use('/foobar') will run on
    • app.get('/foobar')
    • app.get('/foobar/qux')

About

express-socket.io-passport boilerplate

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published