<commit_before># Backend for the Social Enterprise directory

The directory uses Node, Swagger and Mongo on the backend.

## To install
* `npm install`

## To install and start Mongo
* https://docs.mongodb.com/manual/installation/

### (Optional) Load test data into Mongo
* First delete any previous data from Mongo (if so desired)

 `mongo socialEnterpriseDirectory --eval "db.dropDatabase()"`
* Now import the test data with these commands

 `mongoimport --db socialEnterpriseDirectory --collection enterprises --file /path/to/api/mocks/test_data_mongo_public.json --jsonArray`

 `mongoimport --db socialEnterpriseDirectory --collection enterprisePrivateFields --file /path/to/api/mocks/test_data_mongo_private.json --jsonArray`

## To start
* `npm start`

## To use
* http://localhost:10010/api/v1/directory
* http://localhost:10010/api/v1/enterprise/{id}
* http://localhost:10010/api/v1/enterprise/{id}/complete
* POST http://localhost:10010/api/v1/enterprise



# Swagger commands for development/testing
First install the swagger command line
* `npm install -g swagger`
* Further reference: https://github.com/swagger-api/swagger-node

Starting server
* as alternative to `npm start` you can use `swagger project start`
* the advantage is that it will auto-detect any file modifications and nicely restart the server for you (kind of like nodemon)

To view our API documentation in Swagger UI:
* `swagger project edit` then open browser to the URL shown in the console (if it does not automatically open for you)
* One neat thing is that you can use the "Try this operation" button to send requests to the server from this UI

To run server in swagger's mock mode
* `swagger project start -m`
* This starts the server but stubs out all the controllers on the server and auto responds to API requests with mock data that conforms to the API definition. Mainly used when trying out the API or testing the clients before the server code is finished.<commit_msg>add mention to technical documentation<commit_after># Backend for the Social Enterprise directory

The directory uses Node, Swagger and Mongo on the backend.
For detailed technical documentation, see the wiki.

## To install
* `npm install`

## To install and start Mongo
* https://docs.mongodb.com/manual/installation/

### (Optional) Load test data into Mongo
* First delete any previous data from Mongo (if so desired)

 `mongo socialEnterpriseDirectory --eval "db.dropDatabase()"`
* Now import the test data with these commands

 `mongoimport --db socialEnterpriseDirectory --collection enterprises --file /path/to/api/mocks/test_data_mongo_public.json --jsonArray`

 `mongoimport --db socialEnterpriseDirectory --collection enterprisePrivateFields --file /path/to/api/mocks/test_data_mongo_private.json --jsonArray`

## To start
* `npm start`

## To use
* http://localhost:10010/api/v1/directory
* http://localhost:10010/api/v1/enterprise/{id}
* http://localhost:10010/api/v1/enterprise/{id}/complete
* POST http://localhost:10010/api/v1/enterprise



# Swagger commands for development/testing
First install the swagger command line
* `npm install -g swagger`
* Further reference: https://github.com/swagger-api/swagger-node

Starting server
* as alternative to `npm start` you can use `swagger project start`
* the advantage is that it will auto-detect any file modifications and nicely restart the server for you (it wraps nodemon)

To view our API documentation in Swagger UI:
* `swagger project edit` then open browser to the URL shown in the console (if it does not automatically open for you)
* One neat thing is that you can use the "Try this operation" button to send requests to the server from this UI

To run server in swagger's mock mode
* `swagger project start -m`
* This starts the server but stubs out all the controllers on the server and auto responds to API requests with mock data that conforms to the API definition. Mainly used when trying out the API or testing the clients before the server code is finished.
{'fraction_non_alphanumeric': 0.08043967024731452, 'fraction_numerical': 0.011991006744941295, 'mean_word_length': 4.545706371191136, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 4, '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': '3560849', 'n_tokens_mistral': 1129, 'n_tokens_neox': 1060, 'n_words': 489}