Entipe
Entipe tries to provide entity persistence for web applications. Unlike other approaches it concentrates on entities. Entities are defined by a database schema. A web application can read and write entities and their attributes but can not define new entities or modify the database schema.
Design
Entipe consists of two parts: a client library written in JavaScript and a server. The prototype for the reference server is implemented as a CGI script in Perl. Other server implementations will follow after version 1.0 has been finished. The current version number is 10-6.
An application has to load the Entipe client library and has to query the Entipe server for the database schema. This can be done by two script tags in the web page.
<script src="entipe.js"></script>
<script src="entipe.cgi?demo"></script>
The GET request to the Entipe server reads the database schema and returns a JavaScript schema definition, which might look like this:
var demo = new Schema("http://localhost/entipe.cgi?demo",
{"address":["street","locality","country"],
"person":["firstname","lastname"]});
The above code will create a schema object called demo. The schema object can be use to create entities.
peter = new demo.person({"firstname":"Peter", "lastname":"Pan"})
-> Entity {}
peter.firstname
-> "Peter"
peter.lastname = "Parker"
-> "Parker"
peter.lastname
-> "Parker"
The Entipe client sends queries to the Entipe server using a SQL subset with some Entipe specific extensions. The Entipe server sends JSON encoded data to the Entipe client. The Entipe server works as a proxy, parsing the Entipe specific SQL and translating it into database specific SQL. The Entipe server has to validate the client requests to reject requests the client is not allowed to query. This implies all DDL statements.
Development
The development configuration is insecure, because all files are in the document root of the web server. This means that files are publicly accessible though the web server. The setup is intended only for development using only public data. The following setup uses TLS encryption with the Debian default certificate and HTTP basic authentication with PAM.
Install
The following configuration has been tested with Debian 8.2.
sudo apt-get install apache2 libapache2-mod-authnz-external
sudo a2enmod ssl cgi
sudo apt-get install sqlite3 libdbd-sqlite3-perl libjson-perl
#sudo apt-get install libparse-recdescent-perl
sudo cpan -i Marpa::R2
sudo mkdir -m 775 /var/www/entipe
sudo chown $(id -u).$(id -g) /var/www/entipe
git clone https://github.com/ceving/entipe.git /var/www/entipe
sudo chgrp www-data /var/www/entipe/demo.sqlite3
sudo chgrp www-data /var/www/entipe
sudo ln -s /var/www/entipe/demo.debian.site /etc/apache2/sites-available/entipe.conf
sudo a2ensite entipe
sudo service apache2 restart
Next the demo can be accessed via https://localhost/demo.html.
Perl Profiling
For profiling the following additional package is required.
sudo apt-get install libdevel-nytprof-perl
But note that this installs about 15 further dependencies.
JavaScript Documentation
To generate the source code documentation JSDoc is required.
apt-get install npm nodejs-legacy
This will install about 50 packages. After that JSDoc can be
installed using npm
. Today (2015/11) it is necessary to use my fork
of JSDoc.
npm install -g git+https://github.com/ceving/jsdoc.git
When the stable branch supports the new ECMAScript 6 features and my changes the following might be sufficient.
npm install -g jsdoc
Uninstall
Execute the following to uninstall the demo. Be sure that you do not
uninstall packages, which had already been installed before you tried
Entipe. The packages apache
and sqlite3
are maybe already
installed.
sudo a2dissite entipe
sudo rm /etc/apache2/sites-available/entipe.conf
sudo rm -rf /var/www/entipe
sudo apt-get remove --purge apache2 libapache2-mod-authnz-external
sudo apt-get remove --purge sqlite3 libdbd-sqlite3-perl
sudo apt-get remove --purge libjson-perl libparse-recdescent-perl
sudo apt-get remove --purge libdevel-nytprof-perl
sudo apt-get autoremove --purge
Documentation
The following source code documentation is available.