<commit_before># CrowdShelf server
Server for the CrowdShelf apps, written with NodeJS, ExpressJS and Sequelize.

## Workflow
We're using JIRA for issue tracking. We try to follow [Chrockford's style guide](http://javascript.crockford.com/code.html) for our code.

Do you want to contribute? Do it like this:

1. Pick a task to do on JIRA, or just something you want implemented yourself.
2. On JIRA, assign the task to yourself and move it to "In progress".
3. Create a new branch from `master` with a name that starts with the JIRA task name, and is followed by a short description. For example `cs-32-user-management-api`.
4. Work, work. Commit often. Try to follow [good commit practice](http://chris.beams.io/posts/git-commit/). You can push your branch to GitHub if you want.
5. When you're done, push your latest changes and create a pull request. Wait for someone other than yourself to give feedback etc. Work out any differences of opinion, and the pull request will be merged and deployed.

Any questions? Feel free to ask!

## Installation
1. Clone the repository with `<EMAIL>:CrowdShelf/server.git`
2. `cd` into the folder
3. Run `npm install` to install dependencies
4. Set up mongodb locally and export an environment variable `MONGODB` that defines its URL.
5. Run `npm start` and you'll be up and running on port 3000, or an environment defined as `PORT`.

## Project structure

    server\
        api\ - Setup methods for legacy APIs
        controllers\ - Controllers for handling requsts
        models\ - Models that handle database-operations
        index.js - Starts a server
        server.js - Sets the server up, defines port etc.
        router.js - Sets the routing up by setting allowed headers etc. and calling API setup-methods 
        
## Deployment 
### Heroku
The server is currently running on Heroku. It has CI with the `master`-branch. You'll find it on `crowdshelf.herokuapp.com/api`.

## Data model
A `book` is a book in our database that is owned by a user:

    {
        _id: String,
        isbn: String,
        owner: String, # username
        numberOfCopies: Integer, 
        numAvailableForRent: Integer,
        rentedTo: Array[String] # usernames
    }

`numberOfCopies` specifies the number of copies the owner of the book has, while `numAvailableForrent` specifies the number of copies the owner wants to rent out.

A `crowd` has the following properties:

    {
        _id: String, 
        name: String,
        owner: String, # username
        members: Array[String] # usernames<commit_msg>Update README.md: not using sequelize, add info on the herokuapp for dev-branch<commit_after># CrowdShelf server
Server for the CrowdShelf apps, written with NodeJS and Express.

## Workflow
We're using JIRA for issue tracking. We try to follow [Chrockford's style guide](http://javascript.crockford.com/code.html) for our code.

Do you want to contribute? Do it like this:

1. Pick a task to do on JIRA, or just something you want implemented yourself.
2. On JIRA, assign the task to yourself and move it to "In progress".
3. Create a new branch from `master` with a name that starts with the JIRA task name, and is followed by a short description. For example `cs-32-user-management-api`.
4. Work, work. Commit often. Try to follow [good commit practice](http://chris.beams.io/posts/git-commit/). You can push your branch to GitHub if you want.
5. When you're done, push your latest changes and create a pull request. Wait for someone other than yourself to give feedback etc. Work out any differences of opinion, and the pull request will be merged and deployed.

Any questions? Feel free to ask!

## Installation
1. Clone the repository with `<EMAIL>:CrowdShelf/server.git`
2. `cd` into the folder
3. Run `npm install` to install dependencies
4. Set up mongodb locally and export an environment variable `MONGODB` that defines its URL.
5. Run `npm start` and you'll be up and running on port 3000, or an environment defined as `PORT`.

## Project structure

    server\
        api\ - Setup methods for legacy APIs
        controllers\ - Controllers for handling requsts
        models\ - Models that handle database-operations
        index.js - Starts a server
        server.js - Sets the server up, defines port etc.
        router.js - Sets the routing up by setting allowed headers etc. and calling API setup-methods 
        
## Deployment 
### Heroku
The server is currently running on Heroku. It has CI with the `master`-branch. You'll find it on `crowdshelf.herokuapp.com/api`. 

There's also CI on the `dev`-branch, which is the latest version of the API. You'll find it on `crowdshelf-dev.herokuapp.com/api`

## Data model
A `book` is a book in our database that is owned by a user:

    {
        _id: String,
        isbn: String,
        owner: String, # username
        numberOfCopies: Integer, 
        numAvailableForRent: Integer,
        rentedTo: Array[String] # usernames
    }

`numberOfCopies` specifies the number of copies the owner of the book has, while `numAvailableForrent` specifies the number of copies the owner wants to rent out.

A `crowd` has the following properties:

    {
        _id: String, 
        name: String,
        owner: String, # username
        members: Array[String] # usernames
{'fraction_non_alphanumeric': 0.07184723010020798, 'fraction_numerical': 0.0060502930610701455, 'mean_word_length': 3.211783439490446, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '30788', 'n_tokens_mistral': 1515, 'n_tokens_neox': 1449, 'n_words': 728}