GithubHelp home page GithubHelp logo

skyformat99 / kwebapp Goto Github PK

View Code? Open in Web Editor NEW

This project forked from kristapsdz/openradtool

0.0 2.0 0.0 731 KB

create web application API and database layer

Home Page: https://kristaps.bsd.lv/kwebapp

License: ISC License

Makefile 1.51% C 71.13% CSS 2.56% HTML 3.08% JavaScript 3.09% Vim Script 0.14% Roff 13.43% XSLT 5.05%

kwebapp's Introduction

Introduction

kwebapp translates business logic of a database application---objects and queries---into C, SQL (SQLite), and JavaScript code. The business logic is given as a configuration file, for example:

struct user {
  field name text null comment "full name (or null)";
  field email text unique comment "unique e-mail";
  field hash password comment "hashed password";
  field id int rowid comment "unique identifier";
  search id: comment "search by user identifier";
  search email,password: name creds comment "lookup by credentials";
  comment "a system user";
};
struct session {
  field user struct uid;
  field uid:user.id int comment "user bound to session";
  field token int comment "unique session token";
  field id int rowid;
  comment "web session";
};

This configuration is then translated into a C API (header file and implementation) and an SQL schema or update sequence. The API consists of "getters", "setters", updaters, and deleters; and is implemented in straight-forward C code you link directly into your application.

The generated files currently use ksql(3) to wrap around SQLite and (optionally) kcgi(3) for JSON or validation output.

You will need the newest library version to use kwebapp. All of these tools are built in tandem.

Why is kwebapp handy? It removes a lot of "boilerplate" code querying the database and allocating objects. Some more features:

  • Functions generated for modifying (updates), allocating (inserts), and accessing (queries).
  • Automagic foreign key "INNER JOIN" when accessing structures. You specify nested structures in your configuration file, and kwebapp creates the "join" functionality when querying for those objects.
  • Several types of accessors: iterator-based (function callback), list-based (queue), and unique (selecting on unique fields).
  • Well-formed, readable C and SQL output describing functions (if applicable), variables, structures, and so on.
  • "Difference calculator" between configuration files helps database updates be reasonable by providing the necessary "ALTER TABLE" and so on to help with versioning. (Also protects against accidental incompatible changes.)
  • Beyond the usual native type support (int, text, real, blob), also supports "password" type that has automatic hashing mechanism built-in during selection from and insertion into the database.
  • Several different types of SQL query (and update and delete) operators.
  • Optional JSON output functions.
  • Optional field validation (kcgi(3)) functions.

See the TODO for what still needs to be done.

This repository mirrors the main repository on BSD.lv. It is still very much under development!

License

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

kwebapp's People

Watchers

skyformat99 avatar  avatar

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.