1.0.0 • Published 1 year ago

howdy_api_app v1.0.0

Weekly downloads
-
License
ISC
Repository
-
Last release
1 year ago

API

Developing Locally

Coding Standards

Required Software

  • Git
  • NodeJS / NPM
  • Homebrew
  • Redis

Setup local workstation:

  • Clone the Howdy-APIs repository
  • npm install
  • sudo npm i -g realpath
  • sudo npm i -g linkemon

  • Download Oracle Instant Client

  • sudo mkdir -p /usr/local/oracle/instantclient_19_8/
    • Unzip and copy the Oracle Instance Client files into /usr/local/oracle/instantclient_19_8/
    • Talk to Marc, or ask another developer to filex you the Oracle Wallet files listed below. Place them in /usr/local/oracle/instantclient_19_8/network/admin/
      • tnsnames.ora
      • sqlnet.ora
      • ewallet.p12
      • cwallet.sso
  • Redis

    (For more detailed instructions see https://phoenixnap.com/kb/install-redis-on-mac)

    • Install brew install redis
    • Start brew services start redis

If interested, you may also setup redis-sentinel to more closely mimic the server side behaviour. Finally, installing https://github.com/qishibo/AnotherRedisDesktopManager will provide a nice GUI for viewing your local Redis datastore.

  • Set up your development environment
    • IntelliJ
      • Open the application and click File > New > Create Project from Existing Sources
      • Select the downloaded repo and follow the steps.
  • Set up Environment variables - Used to store sensitive information such as passwords that should not be committed to the project.
    • Replace the bash variables in the script below with your values (Note: You may also use IntelliJ's local configuration feature.)

      • vi config/myConfig.sh
      #!/bin/bash 
      
      export BAN_ENV='${netID}' 
      export TNS_ADMIN='/usr/local/oracle/instantclient_19_8/network/admin'
      export EXTERNAL_AUTH='true'
      export ENABLE_SSL='true'
      # For TEST, TST2, DEVL and DALY
      export BAN_USER=
      export BAN_PASSWORD=
      # Either change the instance name of adjust the commented lines below to switch environments
      export BAN_CONNECTIONSTRING=TST2_HOWDYWEB
      #export BAN_CONNECTIONSTRING=TEST_HOWDYWEB
      #export BAN_CONNECTIONSTRING=DEVL_HOWDYWEB
      #export BAN_CONNECTIONSTRING=DALY_HOWDYWEB
      export REDIS_PASSWORD=${REDIS_PASSWORD_IS_PROBABLY_BLANK_FOR_LOCAL}'
      export sharedSecretKey='${SHARED_SECRET_KEY_GOES_HERE}
      export HTTP_PORT='3000'
      export FILE_LOG_LEVEL='debug'
      export CONSOLE_LOG_LEVEL='debug'
      export LOGSTASH_URL='http://localhost:9200/'
      export NPM_TOKEN='${Your_NPM_TOKEN}'
      export MY_API_APP_PATH='/Users/${netID}/TAMU_GIT/howdy_web_components/howdy_api_app/ <== adjust the path for your local environment'
      export STUDENT_USER='${PUT_TEST_ACCOUNT_NAME_HERE}'
      export STUDENT_PASSWORD='${PUT_TEST_ACCOUNT_PASSWORD_HERE}'
  • Source your environment variables prior to starting the api service

    • source config/myConfig.sh

Running your Local API server

  1. Open a terminal window and navigate to the repo location
  • run npm link "@tamu-eis/automated-application-testing"
  • run howdyApiMain.js linkemon howdyApiMain.js

Highlights of the HOWDY-APIS project

  • This will be a brief description of the Project focusing on the parts that most users will need to know to create an api
    • config - This folder holds the files that will reference the local environment variables
    • controllers - This folder holds the 'controller' for the api's and in affect mostly calls an asynchronous function named get. Most people will only need to copy a file of a similar api rename it change the names inside.
    • db_apis - This is where most of the work really happens. the files here hold the implementation (pl/sql call out). again Most people will copy a file of a similar api rename it and some names inside. After doing that the sql-pl/sql will also need to be updated along with changing any binding to vars.
    • node_modules - This folder is filled with dependencies and is modified by updating the package.json file and running npm install
    • services
      • database.js - Generally not touched but handles all the connecting to the database and closing the connection after the call is done.
      • router.js - Another place that needs to be updated. generally a developer will Instantiate API endpoint (look for comment in file) and then Create a Route for API (again look for comment in file).
      • web-server.js - this only needs to be updated to update user that the web server is listening and what api's are exposed (so add your newly created api call)

Creating your own api

  1. create a controller
  • this will house the routed call to the appropriate db call that is written in the db_apis folder
  1. create a db_apis
  • this will house the db call
  1. update router.js
  • this update creates the programmatic route to the controller
  • note: only anonymous endpoints can go before the router.use authn and authz or it will not be validated properly (Around line: 58)
  1. update the table at HOWDYWEB.HWR_API_CONFIG
  • this is the database that gives permission to the users that can make this api call

Production

Running PM2 & Node.js in Production Environments

Express in PROD

Express Tutorial Part 7: Deploying to production

run directly against Node.js in production

PM2

Logging

Monitoring

Encryption (TLS)

Resources

The Oracle connectivity and basic API approach was inspired by this article.

How to write production-ready Node.js Rest API — Javascript version

How to write production-ready Node.js Rest API — Typescript version

Express

Express/cors

Installing node-oracledb

Automatically send pm2 monit stats to Elasticsearch

Student Risk Dashboard API

This API will return a JSON containing students to populate the risk dashboard.

sbs Account Details API

This API will return a JSON containing tuition and fees datagrid to populate the tuition and fees angular component in Howdy.

sbs Balances API

This API will return a JSON containing sbs Balances to populate the tuition and fees angular component in Howdy.

student Holds API

This API will return a JSON containing studentHolds to display and set permissions for angular components in Howdy.

curr Change My Pending Requests API

This API will return a JSON containing ??? to display ??? for angular components in Howdy.

curr Change Submit Request API

This API will return a JSON containing ??? to display ??? for angular components in Howdy.

ccm Template API

This API will return a JSON containing a ccmTemplate to display angular components in Howdy.

App

Setup instructions for the /app routing endpoints.

@aws-sdk/client-s3@elastic/elasticsearch@entropy/winston-elasticsearch-apm@pdf-lib/fontkit@tamu-eis/academic-record-api@tamu-eis/advising-comments-api@tamu-eis/ag-grad-url-api@tamu-eis/arcs-api@tamu-eis/associate-degree-transcript-authorization-api@tamu-eis/automated-application-testing@tamu-eis/aws-s3-api@tamu-eis/carf-api@tamu-eis/change-of-curriculum-api@tamu-eis/class-absence-api@tamu-eis/class-presence-status-api@tamu-eis/compass-reports-api@tamu-eis/core-curriculum-api@tamu-eis/course-details-api@tamu-eis/course-level-change-api@tamu-eis/crc-student-loan-api@tamu-eis/credit-by-exam-api@tamu-eis/degree-eval-api@tamu-eis/degree-planner-api@tamu-eis/directory-information-api@tamu-eis/duplicate-diploma-api@tamu-eis/dw-exceptions-api@tamu-eis/en-recommended-schedule-api@tamu-eis/former-student-questionnaire-api@tamu-eis/general-bio-api@tamu-eis/general-common-api@tamu-eis/grad-guard-api@tamu-eis/grades-api@tamu-eis/graduate-committee-api@tamu-eis/graduation-app-status-check-api@tamu-eis/gv-student-probation-mgmt-api@tamu-eis/holds-api@tamu-eis/howdy-finaid-api@tamu-eis/howdy-generate-pdf-api@tamu-eis/howdy-impersonation-api@tamu-eis/howdy-notifications-api@tamu-eis/howdy-role-management-api@tamu-eis/kine-grade-mode-change-api@tamu-eis/law-attendance-management-api@tamu-eis/math-placement-api@tamu-eis/optional-services-api@tamu-eis/person-search-form-api@tamu-eis/post-secondary-education-api@tamu-eis/prior-ed-and-testing-api@tamu-eis/registration-status-api@tamu-eis/roster-api@tamu-eis/schedules-api@tamu-eis/sea-time-tracking-api@tamu-eis/secondary-education-api@tamu-eis/sections-api@tamu-eis/sponsor-consent-api@tamu-eis/stou-api@tamu-eis/student-parent-guardian-access-api@tamu-eis/student-profile-api@tamu-eis/student-qdrop-api@tamu-eis/student-registration-holds-api@tamu-eis/student-success-advanced-search-api@tamu-eis/student-withdrawal-api@tamu-eis/syllabus-cv-api@tamu-eis/tamu-attendance-dashboard-non-law-api@tamu-eis/tamug-mobile-schedule-optin-api@tamu-eis/tax-ssn-api@tamu-eis/tce-api@tamu-eis/test-api@tamu-eis/tgtp-request-api@tamu-eis/transcript-generation-api@tamu-eis/transcript-order-api@tamu-eis/tsi-api@tamu-eis/tuition-and-fees-api@tamu-eis/upper-business-level-api@tamu-eis/withdrawal-admin-apiapp-root-pathaxiosbody-parserbusboychromedrivercompressionconfigconnect-rediscookie-parsercorselastic-apm-nodeexpressexpress-sessiongeckodriverhelmetical-generatorioredisip-range-checkjs-base64json-2-csvjsonwebtokenmochamocha-json-serialize-reportermochawesomemochawesome-report-generatormomentmorgannode-fetchnodemailernodemonnpmoracledbparse-multipartpassportpassport-azure-adpassport-ldapauthpassport-localpdf-librequestselenium-webdriversocket.iosocket.io-redisutilwinstonwinston-daily-rotate-filewinston-elasticsearch
1.0.0

1 year ago