feat: add backend

This commit is contained in:
Anselm Stordeur
2019-01-08 12:26:15 +01:00
committed by Rainer Killinger
commit 16bbb7e9e3
66 changed files with 6939 additions and 0 deletions

175
config/default.ts Normal file
View File

@@ -0,0 +1,175 @@
import { SCConfigFile } from '@openstapps/core';
/**
* This is the default configuration for app and backend
*
* University specific files can be created with following naming scheme: default-<university license plate>.ts
*
* To select your university specific configuration which is merged from this default file and your university specific
* file, you have to supply the `NODE_APP_INSTANCE` environment variable with your license plate
*
* To get more information about the meaning of specific fields please have a look at `@openstapps/core` or use your
* IDE to read the TSDoc documentation.
*/
const config: Partial<SCConfigFile> = {
app: {
campusPolygon: {
coordinates: [
[
[
13.31916332244873,
52.50796756998264,
],
[
13.336544036865234,
52.50796756998264,
],
[
13.336544036865234,
52.51726547416385,
],
[
13.31916332244873,
52.51726547416385,
],
[
13.31916332244873,
52.50796756998264,
],
],
],
type: 'Polygon',
},
features: {
widgets: true,
},
menus: [],
name: 'StApps - Technische Universität Berlin',
privacyPolicyUrl: 'https://stappsbe01.innocampus.tu-berlin.de/_static/privacy.md',
settings: [],
},
backend: {
SCVersion: '1.0.0',
hiddenTypes: [
'date series',
'diff',
'floor',
],
name: 'Technische Universität Berlin',
namespace: '909a8cbc-8520-456c-b474-ef1525f14209',
sortableFields: [
{
fieldName: 'name',
sortTypes: ['ducet'],
},
{
fieldName: 'type',
sortTypes: ['ducet'],
},
{
fieldName: 'categories',
onlyOnTypes: ['academic event', 'building', 'catalog', 'dish', 'point of interest', 'room'],
sortTypes: ['ducet'],
},
{
fieldName: 'geo.point.coordinates',
onlyOnTypes: ['building', 'point of interest', 'room'],
sortTypes: ['distance'],
},
{
fieldName: 'geo.point.coordinates',
onlyOnTypes: ['building', 'point of interest', 'room'],
sortTypes: ['distance'],
},
{
fieldName: 'inPlace.geo.point.coordinates',
onlyOnTypes: ['date series', 'dish', 'floor', 'organization', 'point of interest', 'room', 'ticket'],
sortTypes: ['distance'],
},
{
fieldName: 'offers',
onlyOnTypes: ['dish'],
sortTypes: ['price'],
},
],
},
internal: {
aggregations: [
{
fieldName: 'categories',
onlyOnTypes: ['academic event', 'article', 'building', 'catalog', 'dish', 'point of interest', 'room'],
},
{
fieldName: 'inPlace.name',
onlyOnTypes: ['date series', 'dish', 'floor', 'organization', 'point of interest', 'room', 'ticket'],
},
{
fieldName: 'academicTerms.acronym',
onlyOnTypes: ['academic event', 'sport course'],
},
{
fieldName: 'academicTerm.acronym',
onlyOnTypes: ['catalog'],
},
{
fieldName: 'majors',
onlyOnTypes: ['academic event'],
},
{
fieldName: 'keywords',
onlyOnTypes: ['article', 'book', 'message', 'video'],
},
{
fieldName: 'type',
},
],
boostings: [
{
factor: 1,
fields: {
'academicTerms.acronym': {
'SS 2018': 1.05,
'WS 2018/19': 1.1,
},
categories: {
'course': 1.08,
'integrated course': 1.08,
'introductory class': 1.05,
'lecture': 1.1,
'seminar': 1.01,
'tutorial': 1.05,
},
},
type: 'academic event',
},
{
factor: 1.6,
type: 'building',
},
{
factor: 1,
fields: {
'categories': {
'cafe': 1.1,
'learn': 1.1,
'library': 1.2,
'restaurant': 1.1,
},
},
type: 'point of interest',
},
{
factor: 1,
fields: {
'categories': {
'main dish': 2,
},
},
type: 'dish',
},
],
},
uid: 'b-tu',
};
export default config;

View File

@@ -0,0 +1,30 @@
import { ElasticsearchConfigFile } from '../src/storage/elasticsearch/Elasticsearch';
/**
* A partial type which is recursive
*
* Copied and only modified array type from `[]` to `Array<>` from https://stackoverflow.com/a/51365037
*/
type RecursivePartial<T> = {
[P in keyof T]?:
T[P] extends Array<(infer U)> ? Array<RecursivePartial<U>> :
T[P] extends object ? RecursivePartial<T[P]> :
T[P];
};
/**
* This is the database configuration for the technical university of berlin
*/
const config: RecursivePartial<ElasticsearchConfigFile> = {
internal: {
database: {
name: 'elasticsearch',
query: {
minMatch: '60%',
queryType: 'query_string',
},
},
},
};
export default config;

25
config/elasticsearch.ts Normal file
View File

@@ -0,0 +1,25 @@
import { ElasticsearchConfigFile } from '../src/storage/elasticsearch/common';
/**
* This is the default configuration for elasticsearch (a database)
*
* University specific files can be created with following naming scheme: elasticsearch-<university license plate>.ts
*
* To select your university specific configuration which is merged from this default file and your university specific
* file, you have to supply the `NODE_APP_INSTANCE` environment variable with your license plate
*
* To select a differen database you have to supply the `NODE_CONFIG_ENV` environment variable with a database name that
* is implemented in the backend
*
* To get more information about the meaning of specific fields please use your IDE to read the TSDoc documentation.
*/
const config: ElasticsearchConfigFile = {
internal: {
database: {
name: 'elasticsearch',
version: '5.5',
},
},
};
export default config;