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

public release

parents
Branches master
No related tags found
No related merge requests found
node_modules
stages:
- build_and_push
- redeploy
variables:
IMAGE_NAME: 094360380/wp4-mock-api-academicid:latest
K8S_NAMESPACE: academicid-dev
K8S_DEPLOYMENT_01_NAME: academicid
build_and_push:
image: docker:latest
stage: build_and_push
services:
- docker:dind
script:
- docker build . -t $IMAGE_NAME
- docker login docker.io -u "$DOCKER_REGISTRY_USER" -p "$DOCKER_REGISTRY_PASSWORD"
# - docker push $IMAGE_NAME
tags:
- docker
only:
- kubernetes
redeploy_at_k8s:
image: alpine/k8s:1.21.5
stage: redeploy
script:
- kubectl config set-cluster local --server="${K8S_SERVER}"
- kubectl config set clusters.local.certificate-authority-data "${K8S_CERTIFICATE_AUTHORITY_DATA}"
- kubectl config set-credentials local --token="${K8S_USER_TOKEN}"
- kubectl config set-context local --cluster=local --user=local
- kubectl config use-context local
- kubectl --insecure-skip-tls-verify version
- kubectl get deployments -n $K8S_NAMESPACE --insecure-skip-tls-verify
- kubectl rollout restart deployment $K8S_DEPLOYMENT_01_NAME -n $K8S_NAMESPACE --insecure-skip-tls-verify
tags:
- docker
only:
- kubernetes
when: manual
\ No newline at end of file
FROM node:16
WORKDIR /app
RUN mkdir -p public/uploads
COPY package.json .
RUN npm install
COPY . .
#Application related arguments
CMD ["npm", "start"]
# AcademicID-mock
## Description
This is a mocked API for academic id 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-academicid
2. docker run -p3000:3000 -d mock-api-academicid
db.json 0 → 100644
{
"photos": [],
"institutions": [
{
"id": 1,
"name": "National Technical University of Athens",
"abbr": "NTUA",
"departments": ["Civil Engineering", "Mechanical Engineering", "Architecture", "Electrical & Computer Engineering", "Chemical Engineering", "Surveying and Geoinformatics Engineering"],
"address": {
"street": "Stournari & 28is Oktovriou",
"zipCode": "10682",
"city": "Athens",
"state": "Athens",
"country": "Greece"
}
},
{
"id": 2,
"name": "Athens University of Economics and Business",
"abbr": "AUEB",
"departments": ["Marketing", "Business Administration", "Statistics", "Management Science & Technology", "Computer Science"],
"address": {
"street": "Patision 76",
"zipCode": "10434",
"city": "Athens",
"state": "Athens",
"country": "Greece"
}
}
],
"tos": [{
"text": "Η «Ηλεκτρονική Υπηρεσία Απόκτησης Ακαδημαϊκής Ταυτότητας» παρέχεται από το Υπουργείο Παιδείας και Θρησκευμάτων με την τεχνική υποστήριξη του Εθνικού Δικτύου Έρευνας και Τεχνολογίας Α.Ε. (εφεξής ΕΔΥΤΕ Α.Ε.). Αντικείμενο και σκοπός της υπηρεσίας είναι η παροχή της Ακαδημαϊκής Ταυτότητας στους δικαιούχους φοιτητές, καθηγητές και λοιπό προσωπικό των Ακαδημαϊκών Ιδρυμάτων/Ερευνητικών Φορέων (στο εξής των οικείων φορέων).Η συμμετοχή του δικαιούχου στο πρόγραμμα και η αίτηση από μέρους του για έκδοση «Ακαδημαϊκής Ταυτότητας» συνεπάγεται την αυτόματη αποδοχή των παρόντων όρων συμμετοχής οι οποίοι προκύπτουν από το ισχύον νομοθετικό πλαίσιο.O συμμετέχων, στο πρόγραμμα «Ηλεκτρονική Υπηρεσία Απόκτησης Ακαδημαϊκής Ταυτότητας», δικαιούχος αποδέχεται ρητά ότι όλα τα στοιχεία που δηλώνει στο πρόγραμμα είναι ορθά, αληθή και επικαιροποιημένα και ότι κάθε δήλωσή του που αφορά στην «Ηλεκτρονική Υπηρεσία Απόκτησης Ακαδημαϊκής Ταυτότητας» υπέχει θέση Υπεύθυνης Δήλωσης κατά την έννοια και με τις συνέπειες του ν.1599/1986, όπως κάθε φορά ισχύει."
}],
"applications": [{
"id": 1,
"accountInfo": {
"username": "marmil",
"password": "Fixme",
"email": "marc@test.com",
"mobile": "+490721794434"
},
"studentInfo": {
"academicStatus": "Postgraduate",
"firstname": "Marcus",
"lastname": "Miller",
"institution": "National University of Athens",
"department": "Physics",
"registrationNumber": "AA01"
},
"photo": 1,
"address": {
"street": "Jahnstrasse",
"zipCode": "24116",
"city": "Kiel",
"state": "Schleswig-Holstein",
"country": "Germany"
},
"studentInfoExt": {
"academicStatus": "Postgraduate",
"studentNo": "mm123",
"SSN": "N/A",
"firstRegistrationMonth": "November",
"firstRegistrationYear": "2021"
},
"consent": {
"privacy": true,
"tos": true
},
"distributionPoint": "id"
},
{
"id": 2,
"accountInfo": {
"username": "newuser",
"password": "Fixme",
"passwordConfirm": "Fixme",
"email": "user@test.com",
"emailConfirm": "user@test.com",
"mobile": "+490721794434",
"mobileConfirm": "+490721794434"
},
"studentInfo": {
"academicStatus": "Undergraduate",
"firstname": "Joe",
"lastname": "Doe",
"institution": "Harvard University",
"department": "Computer Science",
"registrationNumber": "AA02"
},
"photo": 1,
"address": {
"street": "Palo Alto",
"zipCode": "111",
"city": "Cambridge",
"state": "Massachusetts",
"country": "USA"
},
"studentInfoExt": {
"academicStatus": "Postgraduate",
"studentNo": "mm123",
"SSN": "N/A",
"firstRegistrationMonth": "November",
"firstRegistrationYear": "2021"
},
"consent": {
"privacy": true,
"tos": true
},
"distributionPoint": "id"
}
],
"distributionPoints": [{
"id": 1,
"serviceSpeed": "fast",
"title": "Skoutaris A Ypiresies Tilepikoinonion EE (Mega CU Store stin Ermou)",
"address": {
"street": "Evagelistrias",
"number": 22,
"zipCode": 10560,
"prefecture": "Nea Ionia",
"municipality": "Attikis"
},
"poc": {
"name": "Noutsos Petros",
"mobile": "6940015075",
"email": "petros.noutsos@vodafone.com"
},
"openingHours": "MONDAY - FRIDAY 10:00-18:00",
"coordinates": [37.977320792682896, 23.729520524627915]
}, {
"id": 2,
"serviceSpeed": "medium",
"title": "Redconve Monoprosopi IKE",
"address": {
"street": "Nikiforidou & Chremonidou",
"number": 4,
"zipCode": 16231,
"prefecture": "Ladadika",
"municipality": "Thessalonikis"
},
"poc": {
"name": "Papageorgiou Kyriakos",
"mobile": "6940015075",
"email": "kyriakos.papageorg@vodafone.com"
},
"openingHours": "MONDAY - FRIDAY 12:00-18:00",
"coordinates": [37.977320792682896, 23.729520524627915]
}]
}
img/test.png

54 KiB

index.js 0 → 100644
// server.js
const swaggerUi = require('swagger-ui-express');
const path = require('path');
const jsonServer = require('json-server');
const yaml = require('js-yaml');
const fs = require('fs');
const routes = require('./routes');
var multer = require('multer');
var storage = multer.diskStorage({
destination: function (req, file, cb) {
cb(null, path.join(__dirname, 'public/uploads'));
},
filename: function (req, file, cb) {
cb(null, file.fieldname + '-' + Date.now());
}
});
var upload = multer({ storage });
const server = jsonServer.create();
const router = jsonServer.router(path.join(__dirname, 'db.json'));
const middlewares = jsonServer.defaults();
const swaggerDocument = yaml.load(fs.readFileSync('./swagger-academicid.yaml', 'utf8'));
server.get('/', (req, res) => {
res.redirect('/api-docs')
})
server.use(
'/api-docs',
swaggerUi.serve,
swaggerUi.setup(swaggerDocument)
);
server.use(middlewares);
server.use(upload.any());
server.use(jsonServer.rewriter(routes));
server.use(router);
server.listen(3000, () => {
console.log('JSON Server is running')
});
Source diff could not be displayed: it is too large. Options to address this: view the blob.
{
"name": "academicid-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": {
"js-yaml": "^4.1.0",
"json-server": "^0.17.0",
"multer": "^1.4.5-lts.1",
"swagger-ui": "^4.10.3",
"swagger-ui-dist": "^4.10.3",
"swagger-ui-express": "^4.3.0"
}
}
{
"/upload": "/photos",
"/institutions": "/institutions",
"tos": "/tos",
"/applications/create": "/applications",
"/applications/view/:id": "/applications?id=:id",
"/applications/update/:id": "/applications/:id",
"/distributionPoints/all": "/distributionPoints",
"/distributionPoints/search?prefecture=:prefecture&municipality=:municipality": "/distributionPoints?address.prefecture=:prefecture&address.municipality=:municipality"
}
openapi: 3.0.3
info:
title: Academic ID Mock-API
description: An API-Spec used for academic id.
version: 0.1.0
servers:
- url: http://academicid-academicid-dev.k8s.across-h2020.eu
paths:
/upload:
post:
summary: Upload photo.
description: Upload photo.
requestBody:
content:
multipart/form-data:
schema:
$ref: '#/components/requestBodies/Photo'
responses:
'201': # status code
description: OK - Photo Uploaded
content:
application/json:
schema:
type: array
items:
$ref: '#/components/schemas/Photo'
/institutions:
get:
summary: Retrieve all greek institutions.
description: Retrieve all greek institutions.
responses:
'200': # status code
description: OK - All institutions
content:
application/json:
schema:
type: array
items:
$ref: '#/components/schemas/Institutions'
/tos:
get:
summary: Retrieve Terms of Service text.
description: Retrieve Terms of Service text.
responses:
'200': # status code
description: OK - Retrieve text
content:
application/json:
schema:
type: array
items:
$ref: '#/components/schemas/TOS'
/applications/create:
post:
summary: Create a new application.
description: Create a new application.
requestBody:
content:
application/json:
schema:
$ref: '#/components/requestBodies/Application'
responses:
'201': # status code
description: OK - Application Created
content:
application/json:
schema:
type: array
items:
$ref: '#/components/schemas/Application'
/applications/view/{id}:
get:
summary: Returns an application based on its id.
description: Returns an application based on its id.
parameters:
- name: id
in: path
required: true
schema:
type: integer
responses:
'200': # status code
description: OK
content:
application/json:
schema:
type: array
items:
$ref: '#/components/schemas/Application'
/applications/update/{id}:
put:
summary: Update an existing application.
description: Update an existing application.
parameters:
- name: id
in: path
required: true
schema:
type: integer
requestBody:
content:
application/json:
schema:
$ref: '#/components/requestBodies/Application'
responses:
'201': # status code
description: OK - Updated
content:
application/json:
schema:
type: array
items:
$ref: '#/components/schemas/Application'
/distributionPoints/search:
get:
summary: Returns a list of distribution points based on prefecture and municipality.
description: Returns a list of distribution points based on prefecture and municipality.
parameters:
- name: prefecture
in: query
required: true
schema:
type: string
- name: municipality
in: query
required: true
schema:
type: string
responses:
'200': # status code
description: OK - Matches
content:
application/json:
schema:
type: array
items:
$ref: '#/components/schemas/DistributionPoints'
/distributionPoints/all:
get:
summary: Returns a list of all distribution points.
description: Returns a list of all distribution points.
responses:
'200': # status code
description: OK - List all
content:
application/json:
schema:
type: array
items:
$ref: '#/components/schemas/DistributionPoints'
components:
schemas:
Application:
type: object
properties:
id:
type: integer
accountInfo:
type: object
properties:
username:
type: string
password:
type: string
Photo:
type: object
properties:
id:
type: integer
fieldname:
type: string
mimetype:
type: string
TOS:
type: object
properties:
text:
type: string
Institutions:
type: object
properties:
id:
type: integer
name:
type: string
abbr:
type: string
departments:
type: array
items:
type: string
address:
type: object
properties:
street:
type: string
zipCode:
type: string
city:
type: string
state:
type: string
country:
type: string
DistributionPoints:
type: object
properties:
id:
type: integer
serviceSpeed:
type: string
title:
type: string
address:
type: object
properties:
street:
type: string
number:
type: integer
zipCode:
type: integer
prefecture:
type: string
municipality:
type: string
poc:
type: object
properties:
name:
type: string
mobile:
type: string
email:
type: string
openingHours:
type: string
coordinates:
type: string
Upload:
type: object
properties:
id:
type: integer
filename:
type: string
requestBodies:
Application:
type: object
properties:
accountInfo:
type: object
properties:
username:
type: string
required: true
password:
type: string
required: true
email:
type: string
required: true
mobile:
type: string
required: true
studentInfo:
type: object
properties:
academicStatus:
type: string
required: true
firstname:
type: string
required: true
lastname:
type: string
required: true
institution:
type: string
required: true
department:
type: string
registrationNumber:
type: string
address:
type: object
properties:
street:
type: string
required: true
zipCode:
type: string
required: true
city:
type: string
required: true
state:
type: string
required: true
country:
type: string
required: true
studentInfoExt:
type: object
properties:
academicStatus:
type: string
required: true
studentNo:
type: string
required: true
SSN:
type: string
firstRegistrationMonth:
type: string
firstRegistrationYear:
type: string
consent:
type: object
properties:
privacy:
type: boolean
required: true
tos:
type: boolean
required: true
distributionPoint:
type: string
Photo:
type: object
properties:
photo:
type: string
format: binary
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment