Commit 9eeca0a3 authored by Ruven Bröring's avatar Ruven Bröring
Browse files

Initial commit

parent 2b0e87c7
# GMCI-Quindecim
## Prerequisites
This project utilizes [Docker](https://docker.com/) to set up and run custom environments for both CouchDB and the Quindecim website. Furthermore, the ports 4080 and 4084 must be available on your host machine.
## Running CouchDB and the website
With Docker installed on your system, run:
> docker compose up -d
This will start both
* CouchDB on [localhost:4084](http://localhost:4084/) and
* an Apache HTTP Server which hosts the Quindecim website on [localhost:4080](http://localhost:4080).
You can stop these services using the command shown below, but please keep in mind that this will also reset all changes you have made to the environment:
> docker compose down
## CouchDB login
To log in to the [CouchDB admin interface](http://localhost:4084/_utils/), use the following credentials:
* Name: **admin**
* Password: **quindecim**
# Configuration for CouchDB
# Enable CORS (in order to allow our app to communicate with our DB)
[httpd]
enable_cors = true
[cors]
origins = *
credentials = true
headers = accept, authorization, content-type, origin, referer
methods = GET, PUT, POST, HEAD, DELETE
version: "3.8"
services:
couchdb:
image: couchdb:3.2.0
container_name: gmci-couchdb
restart: always
networks:
- gmci-quindecim
ports:
- 4084:5984
volumes:
- ./couchdb/couchdb.ini:/opt/couchdb/etc/local.d/custom.ini
- ./couchdb/data:/opt/couchdb/data
environment:
- COUCHDB_USER=admin
- COUCHDB_PASSWORD=quindecim
php:
image: php:8.0-apache
container_name: gmci-php
restart: always
networks:
- gmci-quindecim
depends_on:
- gmci-couchdb
ports:
- 4082:80
volumes:
- ./frontend:/var/www/html
apache2:
image: ubuntu/apache2
container_name: gmci-apache2
restart: always
networks:
- gmci-quindecim
depends_on:
- gmci-couchdb
ports:
- 4080:80
volumes:
- ./frontend:/var/www/html
networks:
gmci-quindecim:
name: "GMCI-Quindecim"
"use strict";
const couchdbUri = "http://localhost:4084/";
/*
fetch("http://localhost:4084/gmci-quindecim/tables", {
method: 'PUT',
headers: {
"Content-Type": "application/json"
},
body: '{ "_rev": "2-c4401148e52f3043b877530ace62d33f", "id": 1, "seats": 4, "area": "Wintergarten", "available": true }'
}).then(response => response.json()).then(data => console.log(data)).catch(error => console.error(error));
*/
fetch(couchdbUri)
.then(response => response.json())
.then(data => console.log(data));
<!DOCTYPE html>
<html lang="de">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Reservieren &ndash; Quindecim</title>
<!-- <script type="application/javascript" src="vars.js.php"></script> -->
<script type="application/javascript" src="couchdb.js"></script>
</head>
<body>
</body>
</html>
<?php
// Change the file MIME type to application/javascript so that we can use
// it in our frontend scripts.
header("Content-Type: application/javascript");
$Var = array();
$Var["couchdbUri"] = "http://".gethostbyname("couchdb").":5984/";
foreach ($Var as $name => $value) {
switch (gettype($value)) {
case "string":
$value = "\"$value\"";
break;
case "array":
case "object":
$value = json_encode($value);
break;
}
$value = (string) $value;
echo "const $name = $value;\n";
}
?>
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment