The directory uses Node, Swagger and Mongo on the backend. For detailed technical documentation, see the wiki.
npm install
- 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
mongoimport --db socialEnterpriseDirectory --collection enterpriseLogos --file /path/to/api/mocks/test_data_mongo_logos.json --jsonArray
- Add a session secret to config/production.json
"sessionSecret": "Any secret string here"
- The directory uses OAuth to authenticate administrators. To configure OAuth, create a file called
oauth.json
and place it in directoryconfig/oauth/
. The contents should look like:
{
"twitterCallbackURL": "https://<your url>/api/v1/account/login/twitter/callback",
"facebookCallbackURL": "https://<your url>/api/v1/account/login/facebook/callback",
"instagramCallbackURL": "https://<your url>/api/v1/account/login/instagram/callback",
"redirectURLOnSuccessfulLogin": "your URL",
"twitterConsumerKey" : "your key",
"twitterConsumerSecret": "your secret",
"facebookClientId": "your client id",
"facebookSecret": "your secret",
"instagramClientId": "your client id",
"instagramSecret": "your secret "
}
- A directory administrator is someone who has full privileges over the directory content as well as other administrators. If the database does not already contain a directory administrator, an administrator can be bootstrapped into the database.
Create a file called
config/admins.txt
where each line holds one email address of a directory administrator. This will be loaded into the database on startup (only if there is not already an administrator present in the database).
npm start
Full API documentation is available here:
Sample operations:
- Browse directory: http://localhost:10010/api/v1/directory
- Search directory: http://localhost:10010/api/v1/directory?q=key+words+here
- Get Enterprise: http://localhost:10010/api/v1/enterprise/{id}
- Get Enterprise Logo: http://localhost:10010/api/v1/enterprise/{id}/logo
- POST Enterprise (requires authentication): http://localhost:10010/api/v1/enterprise
See wiki.
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 useswagger 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