Skip to content

Commit

Permalink
reducing content api to the core
Browse files Browse the repository at this point in the history
  • Loading branch information
RudiThoeni committed Sep 13, 2024
0 parents commit 04c2909
Show file tree
Hide file tree
Showing 187 changed files with 26,563 additions and 0 deletions.
10 changes: 10 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
.dockerignore
.env
.git
.gitignore
.vs
.vscode
docker-compose.yml
docker-compose.*.yml
*/bin
*/obj
13 changes: 13 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
PG_CONNECTION=
XMLDIR=
IMG_URL=
DOC_URL=
S3_BUCKET_ACCESSPOINT=
S3_IMAGEUPLOADER_ACCESSKEY=
S3_IMAGEUPLOADER_SECRETKEY=
OAUTH_AUTORITY=
ELK_URL=
ELK_TOKEN=
JSONPATH=
DATABROWSER_URL=
API_URL=
89 changes: 89 additions & 0 deletions .github/workflows/main_api.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
name: CI/CD API

on:
push:
pull_request:

env:
PROJECT_NAME: odh-content-api
DOCKER_IMAGE: ghcr.io/${{ github.repository }}/${{ github.event.repository.name }}-api
DOCKER_TAG: ${{ github.sha }}

jobs:
test:
runs-on: ubuntu-20.04

steps:
- uses: actions/checkout@v2
with:
submodules: true
- name: REUSE Compliance Check
uses: fsfe/reuse-action@v1
- name: Setup .NET
uses: actions/setup-dotnet@v1
with:
dotnet-version: '8.0.x'
dotnet-quality: 'preview'
- name: Restore dependencies
run: dotnet restore ContentApiCore.sln
- name: Build ContentApiCore Solution
run: dotnet build ContentApiCore.sln --no-restore
- name: Test
run: dotnet test ContentApiCore --filter Category!=Integration

# deploy-test-api:
# runs-on: ubuntu-20.04
# if: github.ref == 'refs/heads/main'
# env:
# API_URL: "https://api.tourism.testingmachine.eu/v1/"
# needs: test
# concurrency: deploy-test-api
# steps:
# - name: Checkout source code
# uses: actions/checkout@v2
# with:
# submodules: true

# - name: Create .env file
# uses: noi-techpark/github-actions/env-file@v2
# env:
# X_COMPOSE_PROJECT_NAME: ${{ env.PROJECT_NAME }}
# X_DOCKER_IMAGE: ${{ env.DOCKER_IMAGE }}
# X_DOCKER_TAG: ${{ env.DOCKER_TAG }}
# X_SERVER_PORT: 1011

# X_ASPNETCORE_ENVIRONMENT: "Development"
# X_PG_CONNECTION: ${{ secrets.PG_CONNECTION_TEST }}

# - name: Setup config
# run: |
# echo "${{ secrets.GOOGLE_SERVICE_ACCOUNT_NOICOMMUNITY }}" > google-service-account.noicommunity.json
# chmod +r google-service-account.noicommunity.json

# - name: Build and push
# uses: noi-techpark/github-actions/docker-build-and-push@v2
# with:
# docker-username: ${{ github.actor }}
# docker-password: ${{ secrets.GITHUB_TOKEN }}
# working-directory: OdhApiCore
# docker-compose-file: docker-compose.yml

# - name: Deploy application
# uses: noi-techpark/github-actions/docker-deploy@v2
# with:
# hosts: 'test'
# ssh-private-key: ${{ secrets.SSH_PRIVATE_KEY }}
# docker-username: 'noi-techpark-bot'
# docker-password: ${{ secrets.GH_PERSONAL_ACCESS_TOKEN }}
# project-name: ${{ env.PROJECT_NAME }}

# - name: Generate Json
# run: |
# curl "${{ env.API_URL }}STA/JsonPoi"
# curl "${{ env.API_URL }}STA/JsonAccommodation"
# curl "${{ env.API_URL }}ODH/AccommodationBooklist"
# curl "${{ env.API_URL }}ODH/AccommodationFulllist"
# curl "${{ env.API_URL }}ODH/Taglist"
# curl "${{ env.API_URL }}ODH/OdhTagAutoPublishlist"
# curl "${{ env.API_URL }}ODH/OdhTagCategorieslist"
# curl "${{ env.API_URL }}ODH/WeatherForecast"
12 changes: 12 additions & 0 deletions .github/workflows/reuse.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
name: REUSE Compliance Check

on: push

jobs:
test:
runs-on: ubuntu-20.04
steps:
- name: Checkout source code
uses: actions/checkout@v2
- name: REUSE Compliance Check
uses: fsfe/reuse-action@v1
182 changes: 182 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,182 @@
## Ignore Visual Studio temporary files, build results, and
## files generated by popular Visual Studio add-ons.

# User-specific files
*.suo
*.user
*.sln.docstates

# Build results

[Dd]ebug/
[Rr]elease/
x64/
build/
[Bb]in/
[Oo]bj/
-vs/

# MSTest test Results
[Tt]est[Rr]esult*/
[Bb]uild[Ll]og.*

*_i.c
*_p.c
*.ilk
*.meta
*.obj
*.pch
*.pdb
*.pgc
*.pgd
*.rsp
*.sbr
*.tlb
*.tli
*.tlh
*.tmp
*.tmp_proj
*.log
*.vspscc
*.vssscc
.builds
*.pidb
*.log
*.scc

# Visual C++ cache files
ipch/
*.aps
*.ncb
*.opensdf
*.sdf
*.cachefile

# Visual Studio profiler
*.psess
*.vsp
*.vspx

# Guidance Automation Toolkit
*.gpState

# ReSharper is a .NET coding add-in
_ReSharper*/
*.[Rr]e[Ss]harper

# TeamCity is a build add-in
_TeamCity*

# DotCover is a Code Coverage Tool
*.dotCover

# NCrunch
*.ncrunch*
.*crunch*.local.xml

# Installshield output folder
[Ee]xpress/

# DocProject is a documentation generator add-in
DocProject/buildhelp/
DocProject/Help/*.HxT
DocProject/Help/*.HxC
DocProject/Help/*.hhc
DocProject/Help/*.hhk
DocProject/Help/*.hhp
DocProject/Help/Html2
DocProject/Help/html

# Click-Once directory
publish/

# Publish Web Output
*.Publish.xml
*.pubxml

# NuGet Packages Directory
## TODO: If you have NuGet Package Restore enabled, uncomment the next line
packages/

# Windows Azure Build Output
csx
*.build.csdef

# Windows Store app package directory
AppPackages/

# Others
sql/
*.Cache
ClientBin/
[Ss]tyle[Cc]op.*
~$*
*~
*.dbmdl
*.[Pp]ublish.xml
*.pfx
*.publishsettings

# RIA/Silverlight projects
Generated_Code/

# Backup & report files from converting an old project file to a newer
# Visual Studio version. Backup files are not needed, because we have git ;-)
_UpgradeReport_Files/
Backup*/
UpgradeLog*.XML
UpgradeLog*.htm

# SQL Server files
App_Data/*.mdf
App_Data/*.ldf


#LightSwitch generated files
GeneratedArtifacts/
_Pvt_Extensions/
ModelManifest.xml

# =========================
# Windows detritus
# =========================

# Windows image file caches
Thumbs.db
ehthumbs.db

# Folder config file
Desktop.ini

# Recycle Bin used on file shares
$RECYCLE.BIN/

# Mac desktop service store files
.DS_Store
/.paket
/.vs
/OdhApiCore/docker/postgres/dumps

# Docker
/.env
/.vscode

.fake
.ionide

/OdhApiCore/STAAccommodations_de.json
/OdhApiCore/STAAccommodations_en.json
/OdhApiCore/STAAccommodations_it.json
/OdhApiCore/STAOdhActivitiesPois_de.json
/OdhApiCore/STAOdhActivitiesPois_en.json
/OdhApiCore/STAOdhActivitiesPois_it.json
/OdhApiCore/AccosAll.json
/OdhApiCore/AccosBookable.json
/OdhApiCore/GenericTags.json
/OdhApiCore/wwwroot/json/swagger.json
/OdhApiCore/wwwroot/json
/OdhApiCore/.env
/OdhApiImporter/.env
/OdhApiImporter/json/SMOS_MCPL-WX_EXP_SIAG.JSON
/PushServer/files/noi-community-firebase-adminsdk-qv1b9-5c488d5e06.json
/google-service-account.noicommunity.json
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[submodule "sqlkata"]
path = sqlkata
url = https://github.com/toburger/querybuilder
5 changes: 5 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
repos:
- repo: https://github.com/fsfe/reuse-tool
rev: v1.0.0
hooks:
- id: reuse
28 changes: 28 additions & 0 deletions .reuse/dep5
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
Format: https://www.debian.org/doc/packaging-manuals/copyright-format/1.0/
Upstream-Name: opendatahub-content-api-core
Upstream-Contact: NOI Techpark <[email protected]>
Source: https://github.com/noi-techpark/opendatahub-content-api-core

Files: .github/* infrastructure/* .gitignore .pre-commit-config.yaml .dockerignore .env.example .gitmodules docker-compose.dcproj OdhApiCore.sln */*.csproj */*.fsproj */appsettings.* */Dockerfile */Properties/*.json OdhApiImporter/json/* OdhApiCoreTests/xunit.runner.json OdhApiCore/Pages/Index.cshtml OdhApiCore/wwwroot/images/* OdhApiCore/wwwroot/json/* OdhApiCore/wwwroot/favicon.ico OdhApiCore/docker/* LCS/**/ConnectedService.json CDB/**/ConnectedService.json GeoConverterTests/Files/*
Copyright: (c) NOI Techpark <[email protected]>
License: CC0-1.0

Files: ContentApiCore/wwwroot/*/*.min.* ContentApiCore/pages/Index.cshtml
Copyright: (c) NOI Techpark <[email protected]>
License: AGPL-3.0-or-later

Files: ContentApiCore/wwwroot/lib/bootstrap/*
Copyright: 2011-2016 Twitter, Inc.
License: MIT

Files: ContentApiCore/wwwroot/lib/jquery/*
Copyright: JS Foundation and other contributors
License: MIT

Files: ContentApiCore/wwwroot/lib/jquery-validation/*
Copyright: 2017 Jörn Zaefferer
License: MIT

Files: ContentApiCore/wwwroot/lib/jquery-validation-unobtrusive/*
Copyright: Microsoft Corporation. All rights reserved.
License: MIT
30 changes: 30 additions & 0 deletions ContentApiCore/Binders/CommaSeparatedArrayBinder.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
// SPDX-FileCopyrightText: NOI Techpark <[email protected]>
//
// SPDX-License-Identifier: AGPL-3.0-or-later

using Microsoft.AspNetCore.Mvc.ModelBinding;
using System;
using System.Linq;
using System.Threading.Tasks;

namespace ContentApiCore.Controllers
{
public class CommaSeparatedArrayBinder : IModelBinder
{
public Task BindModelAsync(ModelBindingContext bindingContext)
{
var valueProviderResult = bindingContext.ValueProvider.GetValue(bindingContext.ModelName);

string[] model =
valueProviderResult
.Values
.SelectMany(value =>
value?.Split(",", StringSplitOptions.RemoveEmptyEntries) ?? Array.Empty<string>())
.ToArray();

bindingContext.Result = ModelBindingResult.Success(model);

return Task.CompletedTask;
}
}
}
Loading

0 comments on commit 04c2909

Please sign in to comment.