GithubHelp home page GithubHelp logo

kth / kurs-pm-data-api Goto Github PK

View Code? Open in Web Editor NEW
4.0 13.0 0.0 4.79 MB

API app to save course memo data edited in kurs-pm-data-admin-web.

License: MIT License

Dockerfile 2.09% JavaScript 92.81% Shell 2.86% Handlebars 2.25%
nodejs express mongoose swagger react react-pdf

kurs-pm-data-api's Introduction

Welcome to kurs-pm-data-api ๐Ÿ‘‹

Version Prerequisite License: MIT

Introduction

The course information project (KIP) is an initiative at KTH that was launched in 2018 to improve the quality and availability of information about KTH:s courses. The background to the project is, among other things, that it was difficult for the student to find information about the courses and even more difficult to compare information about several courses. The reason for the problems is scattered course information in several places and that there is no uniformity or assigned places for the course information. The project takes measures to consolidate course information into two locations and to present the information in a manner that is uniform for KTH. The student should find the right information about the course, depending on their needs. The result of the project is a public course site where the correct course information is collected and presented uniformly. Also, a tool is developed for teachers to enter and publish course information. Eventually, this will lead to the student making better decisions based on their needs, and it will also reduce the burden on teachers and administration regarding questions and support for the student.

Kurs-pm-api is a microservice to save course memos data to database. It accepts data from admin pages (kurs-pm-data-admin-web) and serves this data to the public view of course memos (kurs-pm-web). It uses Node.js, Mongoose, kth-node-cosmos-db, and is based on node-api.

๐Ÿ  Homepage

Overview

Kurs-pm-api is used to save data in a Azure Cosmos database by using kth-node-cosmos-db to establish a connection to Azure. Before using it, the database and collection must be prepared in Azure because it will establish a connection to an existing database, and not try to create it from a code. Mongoose is used for creating models and saving data. To present a documentation Swagger is used.

Admin and public pages uses different rights and keys to separate their behaviour.

Only admin pages may change API data while public pages can only read. Therefore while useing Swagger, a developer should choose the correct api key, because some functions will not be shown in details.

Related Projects

Prerequisites

  • Node.js 18

Secrets for Development

Secrets during local development are ALWAYS stored in a .env-file in the root of your project. This file should be in .gitignore.

MONGODB_URI=mongodb://kurs-pm-data-api-stage-mongodb-kthse:[password, specified in Azure][email protected]:[port, specified in Azure]/kursinfo?ssl=true&authSource=kursinfo
API_KEYS_0=?name=kursinfo-web&apiKey=[generate a password for public pages]&scope=read
API_KEYS_1=?name=kurs-pm-data&apiKey=[generate a password for admin page]&scope=write&scope=read
APPINSIGHTS_INSTRUMENTATIONKEY=[Azure, Application insights, Instrumentation Key, can be found in Overview]
USE_COSMOS_DB='true'
LOGGING_ACCESS_LOG=debug
SERVER_PORT=3001 [if you want to change port]

These settings are also available in an env.in file.

Prepara Database in Azure

  1. Create database kursinfo and manually set Throughput: 400 (Shared). Name of database will be used in a connection string.
  2. In this database create a collection coursememos where a shard key is /courseCode.
  3. Change a connection string by adding name of database (kursinfo) after port slush [port]/ and as a search query after ? as authSorce=kursinfo:

mongodb://kurs-pm-data-api-stage-mongodb-kthse:[password][email protected]:[port]/?ssl=true/kursinfo?ssl=true&authSource=kursinfo

More information can be found in Confluence: Om kursen: Databas och API, connection string

For Development

Install

npm install

Usage

Start the service on localhost:3001/api/kurs-pm-data/swagger.

npm run start-dev

In Production

Secrets and docker-compose are located in cellus-registry.

Run tests

npm run test

Monitor and Dashboards

Application Status

localhost:3001/api/kurs-pm-data/_monitor

Branch Information

localhost:3001/api/kurs-pm-data/_about

Application Insights

To see more detailed behaviour in project, use Application Insights, e.g., kursinfo-web-stage-application-insights-kthse.

Use ๐Ÿณ

Copy docker-compose.yml.in to docker-compose.yml and make necessary changes, if any.

docker-compose up

Deploy in Stage

The deployment process is described in Build, release, deploy. Technical details, such as configuration, is described in How to deploy your ๐Ÿณ application using Cellus-Registy and ๐Ÿ”ง How To Configure Your Application For The Pipeline.

Edit secrets.env

ansible-vault edit secrets.env

Password find in gsv-key vault

Configure secrets.env

MONGODB_URI=mongodb://kurs-pm-data-api-mongodb-kthse:[password, specified in Azure][email protected]:[port, specified in Azure]/kursinfo?ssl=true&authSource=kursinfo
API_KEYS_0=?name=kursinfo-web&apiKey=[generate a password for public pages]&scope=read
API_KEYS_1=?name=kurs-pm-data-admin-web&apiKey=[generate a password for admin page]&scope=write&scope=read
APPINSIGHTS_INSTRUMENTATIONKEY=[Azure, Application insights, Instrumentation Key, can be found in Overview]

Author

๐Ÿ‘ค KTH

kurs-pm-data-api's People

Contributors

4886talga avatar belanglos avatar dependabot[bot] avatar falric avatar johannesbichel avatar lenaar avatar maxhaase avatar rao-sabahat-ali avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

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.