Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 0 additions & 12 deletions .gitmodules

This file was deleted.

26 changes: 14 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
@@ -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.

1 change: 0 additions & 1 deletion curriculum-graphql-server
Submodule curriculum-graphql-server deleted from 9e12a4
1 change: 0 additions & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
Expand Down
60 changes: 52 additions & 8 deletions install.sh
Original file line number Diff line number Diff line change
@@ -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'
install() {
aggregateData() {
local sPath
readonly sPath="${1?One parameters required: <path>}"

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: <path>}"

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: <root-path>}"

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