- NodeJS 8.7+
docs/swagger.yml- You can use
https://editor.swagger.ioto view it
The app configuration can be changed in config/default.js or by setting environment variables.
The following variables can be configured:
LOG_LEVELthe logging level,errorordebugPORTthe port on that app listensCONTEXT_PATHthe api context pathJWT_SECRETthe secret to encode/decode JWT tokensJWT_EXPIRES_INthe JWT token expiration, example values: "2 days", "10h", "7d"SESSION_SECRETthe secret to encrypt the express sessionAWS_DYNAMODB_CONFIGthe AWS DynamoDb configuration, it includes 3 environment variables:AWS_ACCESS_KEY_ID,AWS_SECRET_ACCESS_KEY, andAWS_REGIONIMPORTER_CRON_TIMEthe cron time to run the importer (using cron-like syntax), default to everyday midnightGITHUB_AUTH_CONFIGthe GitHub OAuth configGITHUB_ADMIN_TOKENthe GitHub access token to access GitHub API (https://github.com/settings/tokens)
NOTE: you need to change localhost:3000 to your production server host and port.
- Login to GitHub
- Go to https://github.com/settings/profile
- Click "Developer settings"
- Click "New OAuth App" button
- Input into all fields. NOTE: set
Homepage URLto "http://localhost:3000", andAuthorization callback URLto "http://localhost:3000/api/v1/connect/github/callback" - After submitting, you can go to the app details to get the OAuth client ID and secret.
The code follows StandardJS.
- Run
npm ito install dependencies - Run
npm run lintto check code styles - Run
npm run lint:fixto check and fix automatically the errors that can be fixed by StandardJS
-
Configure necessary variables and OAuth apps
-
Run
npm ito install dependencies -
Run
npm startto run -
Wait a minute for DynamoDB creates the tables
The app will be available at
http://localhost:3000/api/v1
- Install AWS CLI: https://docs.aws.amazon.com/cli/latest/userguide/installing.html
- Install EB CLI: https://docs.aws.amazon.com/elasticbeanstalk/latest/dg/eb-cli3-install.html
- Go to AWS Console: https://console.aws.amazon.com
- Create a new IAM user (e.g. skill-importer-api-role) with a new group (e.g. skill-importer-api-group). Make sure you added
AmazonDynamoDBFullAccessandAWSElasticBeanstalkFullAccessto the group - You can download the access key and secret by "Download .csv" button
- Go the Permissions tab of the IAM user, "Add inline policy" with this
- Configure new AWS profile by
aws configure --profile <IAM user>(where is the IAM user created above) - Make sure that
~/.aws/credentialsis created and correct cd skill-importer-api- Init EB
eb init -r <region> -p "Node.js", replace with your region, e.g. us-east-1 - Make sure you removed the
node_modulesdirectory before going to the next steps - Create EB environment
eb create(NOTE: useeb create -sif your account is free tier) - Go to EB console, update the environment to use NodeJS version 8.x (default is 6.x)
- Configure new environment variables to correct values:
AWS_ACCESS_KEY_ID,AWS_SECRET_ACCESS_KEY,AWS_REGION,GITHUB_CLIENT_ID,GITHUB_CLIENT_SECRET,GITHUB_CALLBACK_URL. You can use the AWS Console oreb setenv key=value eb opento open that app in web browser
API Demo: http://skill-importer-api-dev3.us-east-1.elasticbeanstalk.com/api/v1 Connect GitHub Demo: http://skill-importer-api-dev3.us-east-1.elasticbeanstalk.com/html
- Start the app
- Generate test data
npm run seed - You can generate additiona admin users by udpating
test_files/seed-admin.jsand runnpm run seed-admin - Import
docs/postman_collection.jsonanddocs/postman_environment.jsonto Postman - Change
URLenvironment variable in Postman according to your deployment. If you deploy locally, it should behttp://localhost:3000/api/v1by default - Send
/loginrequests first so that the access tokens are cached for subsequent calls
- Go to
http://localhost:3000/html(this url is only available forNODE_ENV !== 'production') - Enter username, password or you can use the pre-populated
- Click
Login - Check the login response to make sure the user is logged in successfully
- Click
Connect GitHub - You will be redirected to GitHub, follow the screens to authenticate with GitHub
- GitHub will redirect you back to
http://localhost:3000/api/v1/connect/github/callback - Check the DB to verify that github account is created (you can use DynamoDB console, or any client tool)
- Use Postman call (
Run Importer Job) to make call to the API to run the job immediately - Or wait until job runs (see
IMPORTER_CRON_TIMEconfig) - The job takes more than 10 minutes for each GitHub account
- Check the log output (if you deploy locally) to see the job processing steps
- Check the DB to verify that the Events and Skills get updated when the job completes