Skip to content
Snippets Groups Projects
Commit 83875a93 authored by Benguria Elguezabal, Gorka's avatar Benguria Elguezabal, Gorka
Browse files

public release

parents
Branches
Tags
No related merge requests found
node_modules
.idea
FROM node:16
WORKDIR /app
COPY package.json .
RUN npm install
COPY . .
#Application related arguments
CMD ["npm", "start"]
# Mock-API-Hochschulstart
## Getting started
## Add your files
- [ ] [Create](https://docs.gitlab.com/ee/user/project/repository/web_editor.html#create-a-file) or [upload](https://docs.gitlab.com/ee/user/project/repository/web_editor.html#upload-a-file) files
- [ ] [Add files using the command line](https://docs.gitlab.com/ee/gitlab-basics/add-file.html#add-a-file-using-the-command-line) or push an existing Git repository with the following command:
```
cd existing_repo
git remote add origin https://git.code.tecnalia.com/across/private/user-journey-service-delivery/mock-api-hochschulstart.git
git branch -M main
git push -uf origin main
```
***
## Name
Mock-API-Hochschulstart
## Description
This is a mocked API for hochschulstart.de to start with the first integration of an external API provided by a pilot partner to the ACROSS-Platform.
## Installation for devs and starting the application
1. Just install nodejs and npm
2. npm install
3. npm start
## building and starting the application on docker environment
1. docker build . -t mock-api-hochschulstart
2. docker run -p3000:3000 -d mock-api-hochschulstart
db.json 0 → 100644
{
"federalstates": [
{
"id": 1,
"name": "Baden-Württemberg"
},
{
"id": 2,
"name": "Bayern"
},
{
"id": 3,
"name": "Berlin"
},
{
"id": 4,
"name": "Brandenburg"
},
{
"id": 5,
"name": "Bremen"
},
{
"id": 6,
"name": "Hamburg"
},
{
"id": 7,
"name": "Hessen"
},
{
"id": 8,
"name": "Mecklenburg-Vorpommern"
},
{
"id": 9,
"name": "Niedersachsen"
},
{
"id": 10,
"name": "Nordrhein-Westfalen"
},
{
"id": 11,
"name": "Rheinland-Pfalz"
},
{
"id": 12,
"name": "Saarland"
},
{
"id": 13,
"name": "Sachsen"
},
{
"id": 14,
"name": "Sachsen-Anhalt"
},
{
"id": 15,
"name": "Schleswig-Holstein"
},
{
"id": 16,
"name": "Thüringen"
}
],
"courses": [
{
"id": 1,
"federalStateId": 2,
"name": "Electrical Engineering - Electromobility",
"semester": "Summer Semester 2022",
"institution": "Munich University of Applied Science",
"degree": "Bachelor",
"applicationPeriodFrom": "2021-11-15T10:48:33.821Z",
"applicationPeriodTo": "2022-01-15T10:48:33.821Z"
},
{
"id": 2,
"federalStateId": 2,
"name": "Electrical Engineering - Electromobility",
"semester": "Winter Semester 2022",
"institution": "Munich University of Applied Science",
"degree": "Master",
"applicationPeriodFrom": "2021-11-15T10:48:33.821Z",
"applicationPeriodTo": "2022-01-15T10:48:33.821Z"
},
{
"id": 3,
"federalStateId": 6,
"name": "Biotechnologie BA (major subject)",
"semester": "Winter Semester 2022",
"institution": "Hamburg University of Applied Sciences",
"degree": "Bachelor",
"applicationPeriodFrom": "2022-06-01T10:48:33.821Z",
"applicationPeriodTo": "2022-07-15T10:48:33.821Z"
},
{
"id": 4,
"federalStateId": 6,
"name": "Elektrotechnik und Informationstechnik BA (major subject)",
"semester": "Winter Semester 2022",
"institution": "Hamburg University of Applied Sciences",
"degree": "Bachelor",
"applicationPeriodFrom": "2022-06-01T10:48:33.821Z",
"applicationPeriodTo": "2022-07-15T10:48:33.821Z"
},
{
"id": 5,
"federalStateId": 1,
"name": "Gebärdensprachdolmetschen (0)",
"semester": "Winter Semester 2022",
"institution": "University of Education Heidelberg",
"degree": "B.A. Gebärdensprachdolmetschen",
"applicationPeriodFrom": "2022-04-25T10:48:33.821Z",
"applicationPeriodTo": "2022-07-15T10:48:33.821Z"
},
{
"id": 6,
"federalStateId": 1,
"name": "Pharmacy",
"semester": "Winter Semester 2022",
"institution": "Ruprecht-Karls-Universität Heidelberg",
"degree": "Staatsexamen / 1. Staatsprüfung",
"applicationPeriodFrom": "2022-06-01T10:48:33.821Z",
"applicationPeriodTo": "2022-07-15T10:48:33.821Z"
},
{
"id": 7,
"federalStateId": 10,
"name": "Medicine",
"semester": "Winter Semester 2022",
"institution": "University of Münster",
"degree": "Staatsexamen / 1. Staatsprüfung",
"applicationPeriodFrom": "2022-04-25T10:48:33.821Z",
"applicationPeriodTo": "2022-07-15T10:48:33.821Z"
}
],
"applications": [
{
"firstname": "Marcus",
"lastname": "Miller",
"addressStreet": "Jahnstrasse",
"addressHouseNumber": "22",
"addressZipCode": "24116",
"addressCity": "Kiel",
"addressState": "Schleswig-Holstein",
"addressCountry": "Germany",
"consentPrivacy": true,
"consentPersonalData": true,
"consentAllowContact": true,
"semester": "Summer Semester 2022",
"institution": "Munich University of Applied Sciences",
"course": "Electrical Engineering - Electromobility",
"id": 1
},
{
"firstname": "Lisbeth",
"lastname": "Wild",
"addressStreet": "Geigerweg",
"addressHouseNumber": "426",
"addressZipCode": "09206",
"addressCity": "Ahaus",
"addressState": "Nordrhein-Westfalen",
"addressCountry": "Germany",
"consentPrivacy": true,
"consentPersonalData": true,
"consentAllowContact": true,
"semester": "Winter Semester 2022",
"institution": "Munich University of Applied Sciences",
"course": "Electrical Engineering - Electromobility",
"id": 2
},
{
"firstname": "Niklas",
"lastname": "Sommer",
"addressStreet": "Waßmannsdorfer Chaussee",
"addressHouseNumber": "92",
"addressZipCode": "22119",
"addressCity": "Hamburg",
"addressState": "Hamburg",
"addressCountry": "Germany",
"consentPrivacy": true,
"consentPersonalData": true,
"consentAllowContact": true,
"semester": "Winter Semester 2022",
"institution": "Hamburg University of Applied Sciences",
"course": "Biotechnologie BA (major subject)",
"id": 3
},
{
"firstname": "Dieter",
"lastname": "Fenstermacher",
"addressStreet": "Paderborner Strasse",
"addressHouseNumber": "42",
"addressZipCode": "86399",
"addressCity": "Bobingen",
"addressState": "Bayern",
"addressCountry": "Germany",
"consentPrivacy": true,
"consentPersonalData": true,
"consentAllowContact": true,
"semester": "Winter Semester 2022",
"institution": "Hamburg University of Applied Sciences",
"course": "Elektrotechnik und Informationstechnik BA (major subject)",
"id": 4
},
{
"firstname": "Birgit",
"lastname": "Pabst",
"addressStreet": "Pappelallee",
"addressHouseNumber": "5",
"addressZipCode": "99826",
"addressCity": "Berka v d Hainich",
"addressState": "Thüringen",
"addressCountry": "Germany",
"consentPrivacy": true,
"consentPersonalData": true,
"consentAllowContact": true,
"semester": "Winter Semester 2022",
"institution": "University of Education Heidelberg",
"course": "Gebärdensprachdolmetschen (0)",
"id": 5
},
{
"firstname": "Jörg",
"lastname": "Weiß",
"addressStreet": "Sömmeringstr.",
"addressHouseNumber": "76",
"addressZipCode": "89257",
"addressCity": "Illertissen",
"addressState": "Bayern",
"addressCountry": "Germany",
"consentPrivacy": true,
"consentPersonalData": true,
"consentAllowContact": true,
"semester": "Winter Semester 2022",
"institution": "Ruprecht-Karls-Universität Heidelber",
"course": "Pharmacy",
"id": 6
},
{
"firstname": "Tobias",
"lastname": "Ehrlichmann",
"addressStreet": "Schönwalder Allee",
"addressHouseNumber": "85",
"addressZipCode": "24253",
"addressCity": "Fahren",
"addressState": "Schleswig-Holstein",
"addressCountry": "Germany",
"consentPrivacy": true,
"consentPersonalData": true,
"consentAllowContact": true,
"semester": "Winter Semester 2022",
"institution": "",
"course": "",
"id": 7
},
{
"firstname": "Sophia",
"lastname": "Feierabend",
"addressStreet": "Hallesches Ufer",
"addressHouseNumber": "16",
"addressZipCode": "66839",
"addressCity": "Schmelz",
"addressState": "Saarland",
"addressCountry": "Germany",
"consentPrivacy": true,
"consentPersonalData": true,
"consentAllowContact": true,
"semester": "Winter Semester 2022",
"institution": "University of Münster",
"course": "Medicine",
"id": 8
},
{
"firstname": "Sophia",
"lastname": "Feierabend",
"addressStreet": "Hallesches Ufer",
"addressHouseNumber": "16",
"addressZipCode": "66839",
"addressCity": "Schmelz",
"addressState": "Saarland",
"addressCountry": "Germany",
"consentPrivacy": true,
"consentPersonalData": true,
"consentAllowContact": true,
"semester": "Winter Semester 2022",
"institution": "Hamburg University of Applied Sciences",
"course": "Elektrotechnik und Informationstechnik BA (major subject)",
"id": 9
}
],
"status": [
{
"id": 1,
"level": "pending",
"note": "Automatische Zulassung in Nachrückenphase",
"pointOfEntry": "hochschulstart.de",
"modified": "2022-04-26T16:11:42.463Z",
"created": "2022-04-26T16:11:42.463Z"
},
{
"id": 2,
"level": "admitted",
"note": "Automatische Zulassung in Nachrückenphase",
"pointOfEntry": "hochschulstart.de",
"modified": "2022-04-26T16:11:42.463Z",
"created": "2022-04-26T16:11:42.463Z"
},
{
"id": 3,
"level": "admitted",
"note": "Automatische Zulassung in Nachrückenphase",
"pointOfEntry": "hochschulstart.de",
"modified": "2022-04-26T16:11:42.463Z",
"created": "2022-04-26T16:11:42.463Z"
},
{
"id": 4,
"level": "pending",
"note": "Automatische Zulassung in Nachrückenphase",
"pointOfEntry": "hochschulstart.de",
"modified": "2022-04-26T16:11:42.463Z",
"created": "2022-04-26T16:11:42.463Z"
},
{
"id": 5,
"level": "admitted",
"note": "Automatische Zulassung in Nachrückenphase",
"pointOfEntry": "hochschulstart.de",
"modified": "2022-04-26T16:11:42.463Z",
"created": "2022-04-26T16:11:42.463Z"
},
{
"id": 6,
"level": "pending",
"note": "Automatische Zulassung in Nachrückenphase",
"pointOfEntry": "hochschulstart.de",
"modified": "2022-04-26T16:11:42.463Z",
"created": "2022-04-26T16:11:42.463Z"
},
{
"id": 7,
"level": "admitted",
"note": "Automatische Zulassung in Nachrückenphase",
"pointOfEntry": "hochschulstart.de",
"modified": "2022-04-26T16:11:42.463Z",
"created": "2022-04-26T16:11:42.463Z"
},
{
"id": 8,
"level": "pending",
"note": "Automatische Zulassung in Nachrückenphase",
"pointOfEntry": "hochschulstart.de",
"modified": "2022-04-26T16:11:42.463Z",
"created": "2022-04-26T16:11:42.463Z"
},
{
"id": 9,
"level": "admitted",
"note": "Automatische Zulassung in Nachrückenphase",
"pointOfEntry": "hochschulstart.de",
"modified": "2022-04-26T16:11:42.463Z",
"created": "2022-04-26T16:11:42.463Z"
}
]
}
\ No newline at end of file
index.js 0 → 100644
require('dotenv').config()
// server.js
const express = require('express')
const jsonServer = require('json-server')
const server = jsonServer.create()
const router = jsonServer.router('db.json')
const middlewares = jsonServer.defaults()
const routes = require ('./routes')
const swaggerUi = require('swagger-ui-express')
// const swaggerDocument = require('./swagger-hochschulstart.yaml')
const yaml = require('js-yaml');
const fs = require('fs');
const swaggerDocument = yaml.load(fs.readFileSync('./swagger-hochschulstart.yaml', 'utf8'));
server.get('/', (req, res) => {
res.redirect('/api-docs')
})
server.use(
'/api-docs',
swaggerUi.serve,
swaggerUi.setup(swaggerDocument)
)
router.render = (req, res) => {
let foundPath = req.originalUrl.includes('federalstates');
if(typeof req._parsedOriginalUrl !== 'undefined') {
foundPath = req._parsedOriginalUrl.pathname.includes('federalstates');
}
let transformedData = [];
if(foundPath) {
let options = [];
res.locals.data.forEach(element => {
let buff = new Buffer(JSON.stringify(element));
options.push({
optionID: element.id,
optionVal: [{
locale: "en",
value: element.name
}]
});
});
transformedData = [
{
dropdownID : "federalStateId",
data: options
}
]
} else {
transformedData = res.locals.data;
}
res.jsonp(transformedData);
}
server.use(middlewares)
server.use(jsonServer.rewriter(routes))
server.use(router)
server.listen(3000, () => {
console.log('JSON Server is running')
})
\ No newline at end of file
Source diff could not be displayed: it is too large. Options to address this: view the blob.
{
"name": "hochschulstart-mock-api",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"start": "node index.js",
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "",
"license": "ISC",
"dependencies": {
"dotenv": "^16.0.0",
"js-yaml": "^4.1.0",
"json-server": "^0.17.0",
"swagger-ui": "^4.10.3",
"swagger-ui-dist": "^4.10.3",
"swagger-ui-express": "^4.3.0"
}
}
{
"/applications/search?institution=:institution&subject=:subject&federalStateId=:federalStateId": "/courses?institution_like=:institution&name_like=:subject&federalStateId=:federalStateId",
"/applications/search?institution=:institution&subject=:subject": "/courses?institution_like=:institution&name_like=:subject",
"/applications/search?institution=:institution": "/courses?institution_like=:institution",
"/applications/status?id=:id": "/status?id=:id",
"/applications/federalstates": "/federalstates",
"/applications/federalstates?id=:id": "/federalstates?id=:id",
"/applications": "/applications"
}
\ No newline at end of file
openapi: 3.0.3
info:
title: Hochschulstart Mock-API
description: An API-Spec used for hochschulstart as first try.
version: 0.1.0
servers:
- url: https://hochschulstart-hochschulstart-dev.k8s.across-h2020.eu
paths:
/applications/search:
get:
summary: Returns a list of courses a user could apply to.
description: Returns a list of courses a user could apply to.
parameters:
- name: institution
in: query
required: true
schema:
type: string
- name: subject
in: query
required: false
schema:
type: string
- name: federalStateId
in: query
required: false
schema:
type: string
responses:
'200': # status code
description: A JSON array of courses to apply to
content:
application/json:
schema:
type: array
items:
$ref: '#/components/schemas/Search'
/applications:
get:
summary: Returns a list of courses applied to.
description: Returns a list of courses applied to.
parameters:
- name: id
in: query
required: true
schema:
type: integer
responses:
'200': # status code
description: A JSON array of courses applied to
content:
application/json:
schema:
type: array
items:
$ref: '#/components/schemas/Application'
post:
summary: Apply for an courses.
description: Apply for an courses.
requestBody:
$ref: '#/components/requestBodies/Application'
responses:
'200': # status code
description: A JSON array of courses applied to
content:
application/json:
schema:
type: boolean
/applications/status:
get:
summary: Returns the status of an application.
description: Returns the status of an application.
parameters:
- name: id
in: query
required: true
schema:
type: integer
responses:
'200': # status code
description: the status of an application
content:
application/json:
schema:
$ref: '#/components/schemas/Status'
/applications/federalstates:
get:
summary: Returns a list of an federalstates.
description: Returns a list of an federalstates.
parameters:
- name: id
in: query
required: false
schema:
type: integer
responses:
'200': # status code
description: the status of an application
content:
application/json:
schema:
type: array
items:
$ref: '#/components/schemas/Federalstate'
components:
schemas:
Search:
type: object
properties:
id:
type: integer
federalStateId:
type: integer
name:
type: string
semester:
type: string
institution:
type: string
degree:
type: string
applicationPeriodFrom:
type: string
format: date-time
applicationPeriodTo:
type: string
format: date-time
Application:
type: object
properties:
id:
type: integer
semester:
type: string
institution:
type: string
course:
type: string
admissionPeriodFrom:
type: string
format: date-time
admissionPeriodTo:
type: string
format: date-time
period:
type: string
Federalstate:
type: object
properties:
id:
type: integer
description:
type: string
Status:
type: object
properties:
id:
type: integer
level:
type: string
note:
type: string
pointOfEntry:
type: string
modified:
type: string
format: date-time
created:
type: string
format: date-time
requestBodies:
Application:
required: true
content:
application/json:
schema:
type: object
properties:
firstname:
type: string
lastname:
type: string
addressStreet:
type: string
addressHouseNumber:
type: string
addressZipCode:
type: string
addressCity:
type: string
addressState:
type: string
addressCountry:
type: string
consentPrivacy:
type: boolean
consentPersonalData:
type: boolean
consentAllowContact:
type: boolean
semester:
type: string
institution:
type: string
course:
type: string
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment