This is a homework project for the Server-side Javascript course at BME. Written using Node.JS and Express, see the dependencies in `package.json`.
Running: `node index.js`
What's this?
------------
It's always a big fuss to find roommates in BME dorms. This app could solve this problem by bringing every roommate-seeking individual or group onto one single platform, and let them search for likeable potential roommates - similar to the popular partner-seeking app, Tinder.
Plans & docs
------------
**Attention! This project is heavily under development.**
### Planned endpoints
These endpoints are subjects to change. There might be a really bad design decision lurking in them, so wear a helmet if you want to read on!
-`/` - GET - shows a login screen when not logged in. If the user is logged in, shows a screen where users can see another user profile - and decide whether they like them or not.
<br/>
-`/login` - POST - takes a username and a password as parameters. If they are correct, creates a session. If they are not, redirects to `/`.
-`/register` - GET - a registration form.
-`/register` - POST - takes a username, a password and a password-again from the registration form. If the username is not taken, and the passwords match, creates the user and creates a session. Otherwise it redirets to `/register`.
-`/logout` - GET - destroys the session and redirects to `/`.
- Note: we're not dealing with forgotten passwords. I'm not going to set up an SMTP server for that, and "security questions" are even more terrible.
<br/>
-`/browse` - GET - shows the profile of another user, with an option to like or dislike.
-`/browse/like` - POST - expresses a like. Supplies the username of the liked profile in a parameter. If there was a match, redirects to `/browse/match`, else to `/browse`.
-`/browse/match` - GET - notifies a user about a new match.
-`/browse/dislike` - POST - expresses a dislike. Supplies the username of the disliked profile in a parameter. Redirects to `/browse`.
<br/>
-`/matches` - GET - shows a list of the matches for the user.
-`/user/:username` - GET - shows the profile of the user supplied as URL parameter.
<br/>
-`/profile` - GET - shows a form to edit user profile.
-`/profile` - POST - saves a profile.
### Necessary middlewares
-**static** middleware - because I want CSS, that's why.
<br/>
-**auth** middleware - should be placed on all non-public endpoints. If the user has a valid session, sets the username on `res.locals.username`. Else, redirects to `/`.
-**login** middleware - does the login based on username and password. If the credentials are corrects, sets a session. If not, redirects to `/login`.
-**registration** middleware - same but for registration.
-**logout** middleware - destroys the session and redirects to `/`.
<br/>
-**profile load** middleware - loads a profile and places its data on `res.locals.profile`. It takes the username to load the profile for from `res.locals.userToLoad`.
-**browse** middleware - selects a username that the current user has no relation with yet, and places it on `res.locals.userToLoad`.
-**select** middleware - selects a username from a request parameter and places it on `res.locals.userToLoad`.
-**like** middleware - creates a positive relation with the current user and the one on `res.locals.profile`. If it's a match, redirects to `/browse/match`, else to `/browse`.
-**dislike** middleware - creates a negative relation with the current user and the one on `res.locals.profile`. Redirects to the _referer_ page.
-**matches list** middleware - loads usernames for the matches of the current user, and places them on `res.locals.matches`.
-**profile edit** middleware - reads profile data from the requests and saves it for the current user.