Skip to content
Report the people who used the staff fee privilege for each term.
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
config
contrib @ 826200e
db
errors
middlewares
serializers
tests
.dockerignore
.eslintignore
.eslintrc.yaml
.gitignore
.gitmodules
Dockerfile
README.md
app.js
gulpfile.js
package.json
swagger.yaml
yarn.lock

README.md

Staff Fee Privilege API

Report the people who used the staff fee privilege for each term.

Getting Started

Prerequisites

  1. Install Node.js from nodejs.org.
  2. Install Oracle Instant Client by following here.
  3. Generate a self signed certificate with OpenSSL:
$ openssl req -newkey rsa:2048 -new -nodes -keyout key.pem -out csr.pem
$ openssl x509 -req -days 365 -in csr.pem -signkey key.pem -out server.crt
  1. Copy config/example.yaml to config/default.yaml. Modify as necessary, being careful to avoid committing sensitive data.

    • Environment variables: Sensitive data and data that changes per environment has been moved into environment variables. Below is a list of the variables along with a definition:

      Environment variable Description
      ${PORT} The port used by the API.
      ${ADMIN_PORT} The port used by the ADMIN endpoint.
      ${USER} The HTTP Basic username used to authenticate API calls.
      ${PASSWD} The HTTP Basic password used to authenticate API calls.
      ${DBURL} The database URL used to connect to a backend db store.
      ${DBUSER} The database username used to connect to a backend db store.
      ${DBPASSWD} The database password used to connect to a backend db store.
      ${ENDPOINTURI} API endpoint URI.
    • Options for database configuration:

      Option Description
      poolMin The minimum number of connections a connection pool maintains, even when there is no activity to the target database.
      poolMax The maximum number of connections that can be open in the connection pool.
      poolIncrement The number of connections that are opened whenever a connection request exceeds the number of currently open connections.

      Note: To avoid ORA-02396: exceeded maximum idle time and prevent deadlocks, the best practice is to keep poolMin the same as poolMax. Also, ensure increasing the number of worker threads available to node-oracledb. The thread pool size should be at least equal to the maximum number of connections and less than 128.

    • Options for logger configuration:

      Option Description
      size Maximum size of the file after which it will rotate. This can be a number of bytes, or units of kb, mb, and gb. If using the units, add 'k', 'm', or 'g' as the suffix. The units need to directly follow the number.
      path The directory name to save log files to.
      pattern A string representing the moment.js date format to be used for rotating. The meta characters used in this string will dictate the frequency of the file rotation. For example, if your datePattern is simply 'HH' you will end up with 24 log files that are picked up and appended to every day.
      archive A boolean to define whether or not to gzip archived log files.
      colorize Color the text and status code, using the Express/morgan color palette (text: gray, status: default green, 3XX cyan, 4XX yellow, 5XX red).
      jsonConsole A boolean to jsonfy the output.

Installing

# Using yarn (recommended)
$ yarn

# Using npm
$ npm install

Usage

  1. Fetch the submodule from the contrib repository which contains SQL codes:
$ git submodule update --init
  1. Run the application:
# Run linting and testing tasks before start the app
$ gulp run

# Run the app without running linting and testing tasks (only for development)
$ nodemon app.js

Running the tests

Linting

Run ESLint to check the code:

# Using npm
$ npm run lint

# Using gulp
$ gulp lint

Note: We are following Airbnb's style as the JavaScript style guide

Testing

Run unit tests:

# Using npm
$ npm test

# Using gulp
$ gulp test

Docker

Dockerfile is also provided. To run the app in a container, just simply install Docker first, then:

  1. Download an Oracle Instant Client 12.2 Basic Light zip (64 bits), and place in ./bin folder.

  2. Build the docker image:

$ docker build -t staff-fee-privilege-api .
  1. Run the app in a container:
$ docker run -d \
             -p 8080:8080 \
             -p 8081:8081 \
             -v path/to/keytools/:/usr/src/staff-fee-privilege-api/keytools:ro \
             -v "$PWD"/config:/usr/src/staff-fee-privilege-api/config:ro \
             -v "$PWD"/logs:/usr/src/staff-fee-privilege-api/logs \
             --name staff-fee-privilege-api \
             staff-fee-privilege-api
You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.