Coder Social home page Coder Social logo

djireland / kcgi-framework Goto Github PK

View Code? Open in Web Editor NEW

This project forked from kristapsdz/kcgi-framework

0.0 0.0 0.0 40 KB

basic framework for a simple kcgi application

License: ISC License

Makefile 7.60% C 76.18% JavaScript 14.43% Shell 1.79%

kcgi-framework's Introduction

Synopsis

kcgi-framework is a set of files for starting a BCHS project that uses kcgi, ksql, and kwebapp.

The system, as is, minimally implements logging in and logging out over a session-based, RESTful JSON API. It has lots of documentation:

  • initial database documentation via sqliteconvert
  • RESTful documentation via Swagger
  • well-documented C and JS source code

The existing code tries to follow best practises for all elements of the stack: clean, secure C code that's logically separated, HTML and JavaScript that are well-formed and satisfy CSP policies, and so on.

It's also portable within UNIX systems as provided by oconfigure.

You'll only use this repository once as a primer for your project. It's not something that's installed. I use this to quickly get started on a project without needing to re-implement basis user management.

Installation

This is a framework (or foundation), so you'll use this to get your project started. Begin by copying all files into your project directory. You'll also need kcgi and ksql, kwebapp, and sqliteconvert if you plan on using the database documentation.

Begin by reading the Makefile: it will list all of the variables you'll need to set for your installation. Override these in a Makefile.local. The default values assume an OpenBSD system with a stock install. You'll probably need to set the following:

CPPFLAGS = -I/usr/local/include
LDFLAGS = -L/usr/local/lib

Then read the main.c and yourprog.kwbp. The former drives the output of the latter when pushed through kwebapp in various ways.

Finally, read index.xml and index.js, both of which drive the JSON backend. It's all super-simple and self-contained. (kwebapp can also provide this, but I erred on the side of simplicity.)

Before running make, you'll need to run ./configure to generate the compatibility layer.

The current Makefile rules are as follows.

Run make to compile the sources.

Run make installwww to install the HTML and JS sources.

Run make installapi to install the Swagger RESTful documentation.

Run make installcgi to install the CGI script and a fresh copy of the database. Warning: this will replace the existing database.

Run make updatecgi to install only the CGI script.

Package management

Most of my CGI scripts are managed by a package manager, not by hand-installation. kcgi-framework includes the building blocks for an OpenBSD package by including necessary files.

The port files exist in the OpenBSD directory. As-is, they will install the CGI script in /var/www/cgi-bin and the database and database specification in /var/www/data.

The CGI script is installed with no permission bits. This is because at initial installation, there's no database yet. And on upgrade, the database may not be in sync with the CGI script.

To solve this, the package manager will run the yourprog-upgrade script, which generates the difference between the database specification for the existing database in /var/www/data with the current version's specification. It then patches the database and installs the current specification. This keeps your database smoothly up to date.

Of course, this is something you'll need to carefully test! It uses kwebapp-sqldiff(1), which has its limitations.

License

All sources use the ISC (like OpenBSD) license. See the LICENSE.md file for details.

kcgi-framework's People

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.