diff --git a/.gitmodules b/.gitmodules deleted file mode 100644 index 3e41071..0000000 --- a/.gitmodules +++ /dev/null @@ -1,12 +0,0 @@ -[submodule "curriculum-graphql-server"] - path = curriculum-graphql-server - url = git@github.com:slonl/curriculum-graphql-server -[submodule "curriculum-rest-api"] - path = curriculum-rest-api - url = git@github.com:slonl/curriculum-rest-api -[submodule "curriculum-search-server"] - path = curriculum-search-server - url = git@github.com:slonl/curriculum-search-server.git -[submodule "curriculum-store"] - path = curriculum-store - url = git@github.com:slonl/curriculum-store diff --git a/README.md b/README.md index a6790bd..1679345 100644 --- a/README.md +++ b/README.md @@ -1,27 +1,29 @@ # Curriculum Rest API Development -This repository contains a development environment for the opendata.slo.nl curriculum rest api. The rest api needs a working graphql server, so that is also included, but there should be no need for further development here. +This repository contains a development environment for the opendata.slo.nl curriculum rest api. ## Setup +Requires: node and git to be installed. + +from the root folder (curriculum-restapi-dev): + ```bash -cd curriculum-graphql-server -git submodule update --init -git submodule foreach 'git checkout editor' -cd .. +./install.sh ``` +Once the install script is run, the apiKeys.json and editors.json need to be added in the curriculum-rest-api folder. + ## Usage +Requires: docker installed. + +from the root folder (curriculum-restapi-dev): + ```bash -docker-compose up +docker compose up ``` -This starts two docker images, one for the rest api on localhost:4500. And one for the graphql server on localhost:3500. - -The startup of the graphql server can take a few minutes, it will also run npm install and fetch all the data from the submodules and combine them in a single json file for the graphql server. +This starts two docker images, one for the rest api on localhost:4500. And one for the simplystore server on localhost:3500. ## Todo - -In production the rest api runs with an apache server as proxy. This server also provides the static assets (css, images, etc.) These are currently missing in this setup. - diff --git a/curriculum-graphql-server b/curriculum-graphql-server deleted file mode 160000 index 9e12a4a..0000000 --- a/curriculum-graphql-server +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 9e12a4a6e43f40d56823c5f5b3c0fca9aa27f15b diff --git a/docker-compose.yml b/docker-compose.yml index f3e0d03..d4cc00d 100755 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -37,7 +37,6 @@ services: - DATA_DIR=/home/node/app/curriculum volumes: - ./curriculum-search-server/:/home/node/app - - ./curriculum-graphql-server/data/:/home/node/app/curriculum ports: - "3001:3001" entrypoint: ["/bin/sh","-c"] diff --git a/install.sh b/install.sh index 75c5204..80bf053 100755 --- a/install.sh +++ b/install.sh @@ -1,10 +1,54 @@ -#!/bin/bash -cd ./curriculum-graphql-server -git submodule update --init -git submodule foreach 'git checkout editor' -cd .. +#!/usr/bin/env bash -docker-compose exec graphql sh -c 'cd json-graphql-server && npm install' -docker-compose exec graphql sh -c 'npm run combine' +set -o errexit # Exit script when a command exits with non-zero status. +set -o errtrace # Exit on error inside any functions or sub-shells. +set -o nounset # Exit script on use of an undefined variable. +set -o pipefail # Return exit status of the last command in the pipe that exited with a non-zero exit code -docker-compose exec rest-api sh -c 'npm install' \ No newline at end of file +install() { + aggregateData() { + local sPath + readonly sPath="${1?One parameters required: }" + + pushd "${sPath}/curriculum-store/scripts/" + + bash ./init.sh + node tojsontag.mjs + node convert.mjs "${sPath}/curriculum-store/data/schema.jsontag" "${sPath}/curriculum-store/data/curriculum.jsontag" "${sPath}/curriculum-store/data/data.jsontag" + } + + installRepos(){ + local sPath + readonly sPath="${1?One parameters required: }" + + git -C "${sPath}" clone https://github.com/slonl/curriculum-rest-api.git + npm --prefix "${sPath}/curriculum-rest-api" update + + + git -C "${sPath}" clone https://github.com/slonl/curriculum-search-server.git + npm --prefix "${sPath}/curriculum-search-server" update + + git -C "${sPath}" clone https://github.com/slonl/curriculum-store.git + npm --prefix "${sPath}/curriculum-store" update + } + + local sRootPath + readonly sRootPath="${1?One parameters required: }" + + installRepos "${sRootPath}" + aggregateData "${sRootPath}" + + echo 'Project installation completed successfully. Please take the following steps:' + echo '' + echo '1. Add "apikeys.json" in curriculum-rest-api folder' + echo '2. If you want to edit data, add "editors.json" in curriculum-rest-api folder' + echo '3. (optional) Make sure to select the correct branches in curriculum-rest-api' + echo '4. Start docker using the "docker compose up" command from curriculum-restapi-dev folder' +} + +if [ "${BASH_SOURCE[0]}" != "${0}" ]; then + export -f install +else + # Replace "${PWD}" with "${@}" to allow passing in a path to the script + install "${PWD}" +fi \ No newline at end of file