-
Notifications
You must be signed in to change notification settings - Fork 9
Back end
The backend uses this technologies:
- Express
- Url-to-screenshot module --> It's based on PhantomJS. We use it to take screenshots.
- Bcrypt --> We use it to hash passwords before storing them in the database
- Cloudinary --> We use it to host the images
It exposes the following API endpoints to communicate data between client and server:
-
api/auth/signup
- POST ->
-
api/auth/login
- POST ->
-
api/user
- GET -> It returns an array that contains objects where each object is a user.
You can pass the 'page' parameter with a value in the endpoint to paginate users in the front-end like so
api/users?page=3
- POST -> It creates a new user. You have to send a username and password in JSON format in the request.
Ex:
{'username': 'Joe', 'password': '0000'}
- GET -> It returns an array that contains objects where each object is a user.
You can pass the 'page' parameter with a value in the endpoint to paginate users in the front-end like so
-
api/user/:username
- GET -> It returns an object with the user data.
- PUT -> It updates the user with the data sent in JSON format in the request. Ex:
{'password': '1111'}
- DELETE -> It deletes the user.
-
api/user/:username/screenshot/
- GET -> It returns an array that contains all the screenshots taken by the user
- POST -> It creates a new screenshot associated with the user sent in the API endpoint. Also, you have to send the url that you want to take the screenshot from as JSON in the request. Ex:
{"url": "http://www.google.com"}
-
api/user/:username/screenshot/:id
- GET -> It returns an object with the screenshot data.
- PUT -> It updates the screenshot with the data sent in the request
- DELETE -> It deletes the screenshot
Some environment variables, such as API keys, will either be sourced from a file local.env.json
or from the Heroku deployment environment. They will be kept in sync.
Configuration variables can be accessed like so:
var config = require('/server/config/environment');
// Returns config object with variables set on it. E.g.
console.log(config.PORT);
The config
module pulls from the environment variables AS WELL AS some configuration files (production.js
, development.js
, and test.js
) in the environment
folder. First look at the production.js
, development.js
, or test.js
files in that folder to see if the variable you want is there, otherwise inspect index.js
for defaults.
The local.env.json
file is not tracked by GitHub for security. Go to the project Dropbox to download it. You will need this file if you want to run a local deployment.