The sssnap webserver
npm install
IMPORTANT: You have to do this before you start the server the first time because you need to specify a Google OAuth2 Client ID and secret.
- Copy the file
launch.sample.sh
and rename it tolaunch.sh
. - Visit the Google Developers Console and create a new project.
- Go to APIs & auth > Credentials and Create a new Client ID. Make it a Web application.
- In the first field "Authorized JavaScript origins" insert:
https://localhost:4000
- In the second field "Authorized redirect URIs" insert:
https://localhost:4000/auth/google/callback
- Click Create Client ID.
- Insert the Client ID and Client secret in
launch.sh
. - Done.
Be sure MongoDB is running. Then type:
npm start
You can start the server in different environments and/or with a different port.
npm start NODE_ENV=production PORT=3000
NODE_ENV
defaults to development
PORT
defaults to 4000
Note: Currently only NODE_ENV and PORT are supported as cli-arguments.
When executing npm start
the launch.sh
bash file will be executed. This is necessary for storing and accessing Client IDs and secrets in a safe place. The bash script will set all environment variables and run the server.
Also, while the server starts, a script will check the availability of the environment variables. If they're not specified the server terminates itself.
I'm starting the server and get "error: MongoDB connection error" together with a huge gibberish ErrorStack.
Answer: Dude, "Be sure MongoDB is running."
The page is loading an eternity and I don't get a response.
Answer: Are you sure you're calling the server over https? http is not supported.
Why isn't http supported?
Answer: In a production environment node will always be behind a proxy. The proxy will take care of redirecting http to https.
I get an error "Cannot start Server due to missing * credentials."
Answer: You can't simply run server.js. Use npm start or the provided bash file, it really doesn't matter.
Everytime I start the server a directory named incoming is created in the project.
Answer: That's fine. The uploaded and not-yet processed images will be stored there temporarily. This way your temp-filesystem won't be spammed and it's better for development/debugging purposes.
I'm using Windows and can't execute the bash script!
Answer: Who are you?