{"size": 1242, "ext": "js", "max_stars_repo_path": "freedom.api/infrastructure/server.js", "max_stars_repo_name": "fancycoconut/freedom", "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "freedom.api/infrastructure/server.js", "max_issues_repo_name": "fancycoconut/freedom", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "freedom.api/infrastructure/server.js", "max_forks_repo_name": "fancycoconut/freedom", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": null, "max_issues_count": null, "max_forks_count": null, "avg_line_length": 30.2926829268, "max_line_length": 136, "alphanum_fraction": 0.5152979066}
// Server Setup
import logger from 'morgan';
import helmet from 'helmet';
import bodyParser from 'body-parser';
//import expressSanitized from 'express-sanitized'


export const server = {
    configureServices: () => {
        return (req, res, next) => {
            const app = req.app;

            app.use(logger('dev'));
            app.use(bodyParser.json());
            //app.use(expressSanitized());
            next();
        }
    },
    configureSecurity: () => {
        return (req, res, next) => {
            const app = req.app;
            app.use(helmet());
            next();
        }
    },
    allowCrossDomain: () => {
        return (req, res, next) => {
            res.header('Access-Control-Allow-Credentials', true);
            res.header('Access-Control-Allow-Origin', '*');
            res.header('Access-Control-Allow-Methods', 'GET,PUT,POST,DELETE,OPTIONS');
            res.header('Access-Control-Allow-Headers', 'x-access-token, Content-Type, Authorization, Content-Length, X-Requested-With');
            // intercept OPTIONS method
            if ('OPTIONS' == req.method) {
                res.sendStatus(200);
            }
            else {
                next();
            }
        }
    }
};