Giter Site home page Giter Site logo

uni-proxy's Introduction

University Api

University Api

Installation

  1. Open your terminal and type :

git clone https://github.com/Ierofantis/uni-proxy

  1. When the process is completed then navigate to the project:

cd uni-proxy

  1. Please type:

docker-compose build

and after that type:

docker-compose up

  1. Now you are ready to use the uni-api proxy

Instructions

URLS

I will provide the list of the urls that you can enter:

  1. http://localhost:9000/getAllUniversities
  2. http://localhost:9000/getAllUniversities?country=united%20states&page=1&limit=2
  3. http://localhost:9000/getAllUniversities?name=Marywood&page=1&limit=2
  4. http://localhost:9000/getAllUniversities?page=1&limit=5
  5. http://localhost:9000/getUniversityStatistics

Implementation

  1. The main file is app.js that imports some libraries, starts the server and injects routes to the application
  2. src/routes.js declares routes. In every route I am using a very basic, cache and throttling mehanism. Also every route corresponds to one controller. For example in /getAllUniversities we need the universities.getAllUniversities controler
  3. In src/controllers dir we have the universities and statistics controller. Universities controller is called in /getAllUniversities route and statistics controller is called in /getUniversityStatistics
  4. In src/test we have statistics and universities files where I have implemented the integration tests.
  5. In docker/api dir there is the Dockerfile.
  6. The external files are: gitignore(git ignores the dependencies in the file), docker-compose.yml(docker-compose), package.json(dependencies) and .babelrc(necessary if you want to use ES6 modules/features e.g import)

Test

  1. I am using Mocha and I am doing integration tests in a very basic level. If you want to run these tests please type:

npm run test

Thoughts

  1. For cache in an ideal senario I would use a distributed solution like reddis, but now I have used a npm module that caches the content in memory. That has some good and bad implications:

    Good It is the fastest option available

    Bad If the server goes down the data is lost

    Also this is a very basic example and there is no strategy behind It. For example: What happens when data from the external api is updated?

  2. Node Js and expressjs are not mulit-threaded which means that it can only process one response at a time. By using asynchronous mechanisms on your server appear multi-threaded but they are not.

uni-proxy's People

Contributors

ierofantis avatar

Watchers

James Cloos avatar  avatar

Forkers

ruacon35

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.