<commit_before># HeadStart
Cross-domain code generation framework for Rapid Application Development

## Overwriting defaults

You can create a `.HeadStartrc` in your project:

    {
      "cartridgePath": "../dslama/MonApp",
      "outputPath": "../dslama/MonApp/runtime",
      "projectPath": "../dslama/IIC-Data"
    }

This file will be read by the [rc](https://www.npmjs.com/package/rc) library.<commit_msg>Adding some documentation on how to use the lib in 3rd party<commit_after># HeadStart
Cross-domain code generation framework for Rapid Application Development

## Overwriting defaults

You can create a `.HeadStartrc` in your project:

    {
      "cartridgePath": "../dslama/MonApp",
      "outputPath": "../dslama/MonApp/runtime",
      "projectPath": "../dslama/IIC-Data"
    }

This file will be read by the [rc](https://www.npmjs.com/package/rc) library.


## Using inside of another project

    npm install --save https://github.com/dslama/HeadStart.git

In your application (`server/app.js`):

    const hsApp = require('HeadStart/server/app');
    const hsMiddlewares = require('HeadStart/lib/middlewares');
    app.use('/admin',
        // Authentication and authorization
        session.middlewares.requiresUser,
        hsMiddlewares.canAccess.bind(null, 'someUserProp'),
        session.middlewares.unauthorized,
        // application
        hsApp('/admin')
    );

Make sure that the path `/admin` matches on both lines:

    app.use('/admin',
        ...
        hsApp('/admin')
    );

Implementations of `session.middlewares.requiresUser` and
`session.middlewares.unauthorized` are left as an exercise.

    function requiresUser(req, res, next) {
        req.someUserProp = { object };
    }

    function unauthorized(error, req, res, next) {
        // redirect because cannot access.
    }

The `hsMiddlewares.canAccess.bind(null, 'someUserProp')` indicates to validate
the variable `req.someUserProp` will be checked for a valid user.

This implementation for authorization might need to be revised because it should
not be limited to HeadStart users, but should be linked to the hosting app
users.
{'fraction_non_alphanumeric': 0.11345522737927802, 'fraction_numerical': 0.00046882325363338024, 'mean_word_length': 3.259481037924152, 'pattern_counts': {'":': 6, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 3, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '433097', 'n_tokens_mistral': 638, 'n_tokens_neox': 602, 'n_words': 190}