Skip to content

Developers Manual

Netanel Draiman edited this page Jun 20, 2016 · 12 revisions

#Code access You can find and download in the code page or by doing Fork

#Project code The code is managed on 'github' ,involving The MEAN Stack

#License

This code is open-source, under the copy rights of The MIT License (MIT) And "Azrieli - Jerusalem Collage of Engineering".

#Directory structure and files in the project

Server side

Utility

contains the functions that were built to provide certain functionality against the server and the DB

Files Included:

  1. mongo.js - Provides functions to do CRUD against the DB
  2. email.js - Provides functions to send emails
  3. auth.js - Provides functions to Authenticate the user and set his Roles
  4. acl.js - Access Control List - assign action id according to request route
  5. drive.js - managing files on the server's drive account, add/delete photos etc
  6. excel.js - import/export excel files
  7. middleware.js - server wide middlewares such as ensure user is authenticated, ensure user's permission etc.
  8. validation.js - validate routes params

Routes

contains the routing that links the Urls to the utils

Files Included:

  1. auth.js - Provides the routes to sign-up, login, account activation, forgot/change password, change email.
  2. chat.js - Provides the routes to get chat history according to chat id
  3. dataexchange.js - import and exporting data from database from/to excel files
  4. home.js - upload/delete ads from the home page
  5. photos.js - upload/delete photos from user profile, renovation page or home page image slider
  6. renovation.js - create/edit renovation, assign team, tasks/pinned messages/tools management
  7. statistics.js - get statistics on database data, such as volunteer hours, renovation costs etc.
  8. status.js - Get/Update the organization referrals status and message
  9. team.js - team management routes - create, edit, delete, assign manager, assign to renovation, add/remove members
  10. user.js - user management routes - delete user, approve sign-up, edit user, get all users/sign-ups

Additional Files

  • brute.js - configures server protection from brute force attacks using express-brute
  • passport.js - configures server's user authentication using PassportJS
  • socketio.js - configures socketio to be using in chat

Environment Variables

Access using process.env.[variable name]

  • PORT - used by server host to determine the port the server will run on.
  • EMAIL_ADDR - server's email account to be used to send email for sign-ups and password/email changes
  • EMAIL_PASS - server's email account password
  • MONGODB_URL - MongoDB url including account name and password, format: mongodb://[account name]:[password]@[server address and port]/[database name]
  • SESSION_SECRET - secret used to encrypt sessions
  • GOOGLE_CLIENT_ID - client id from Google's API management
  • GOOGLE_CLIENT_SECRET - client secret from Google's API management
  • GOOGLE_CALLBACK - redirect to this route after Google OAuth authentication
  • FACEBOOK_APP_ID - app id from Facebook's APP management
  • FACEBOOK_APP_SECRET - app secret from Facebook's APP management
  • FACEBOOK_CALLBACK - redirect to this route after Facebook OAuth authentication
  • HOME
  • HOMEPATH
  • USERPROFILE

User Roles & Hierarchy

  1. guest
  2. volunteer
  3. team leader
  4. manager
  5. admin

Where 1. is the lowest in the hierarchy and 5 is the highest

Tests

contains the unit testing for the utils

Files Included:

  1. database.test.js : Provides the tests to the mongo.js , auth.js utils
  2. server.test.js : Provides the tests for the basic server functionality such loading express and vendor libraries

Client side

Photos

Setup google drive

  1. Turn on the Drive API and create client_secret.json

  2. The first time you run the server, it will prompt you to authorize access:

    a. Browse to the provided URL in your web browser. If you are not already logged into your Google account, you will be prompted to log in. If you are logged into multiple Google accounts, you will be asked to select one account to use for the authorization.

    b. Click the Accept button.

    c. Copy the code you're given, paste it into the command-line prompt, and press Enter.

Photos directives

You need to specify the album you want to add photos to

<photos album="user@123.com"></photos>

You need to specify the role "teamLead" can upload and delete photos

<photos-renovation album="user@1231.com" role="teamLead"></photos-renovation>

Compilation & Running

  1. Make sure MongoDB server is running
  2. Setup your server environment variables as listed above
  3. Upload your Drive API files (client_secret.json & drive-nodejs-creds.json) to your server - for more info click here
  4. use npm start to start the server
  • npm run debug run server with debug messages

Checking

Bugs

For bugs you can open an issue through Issues board