Giter VIP home page Giter VIP logo

apex-mle-demo's Introduction

APEX + MLE

An APEX app which demonstrates the power of server-side JavaScript via MLE & GraalVM

App

Download app.sql, and import it into an APEX 20.2 instance, on an Always Free 21c DB.

Examples

Name Description Libraries Used
Form Validation Use form validations such as isEmail or isCreditCard validator
QR Code Generation Generate a QR Code as a blob or base64 encode string qrcode
Markdown to HTML Convert Markdown to HTML serverside. Integration with dompurify would also be wise marked
HTML Sanitization Clean HTML of XSS vunrabilities and other issues text-encoding, mle-jsdom, dompurify
Image Manipulation Experimental example for cropping, flipping, and watermarking images jimp
Sentiment Analysis Output a "sentiment score" based on a block of text sentiment.js

Libraries

To be able to run the examples, navigate to the Modules page and create extermal modules for the following libraries. On save, the actual code will be downloaded automatically.

Library name URL
dompurify https://cdnjs.cloudflare.com/ajax/libs/dompurify/2.2.7/purify.min.js
jimp https://cdn.jsdelivr.net/npm/[email protected]/browser/lib/jimp.js
marked https://cdnjs.cloudflare.com/ajax/libs/marked/1.2.9/marked.min.js
mle-jsdom https://raw.githubusercontent.com/stefandobre/mle-jsdom/main/jsdom.js
qrcode https://cdnjs.cloudflare.com/ajax/libs/qrcode-generator/1.4.4/qrcode.min.js
text-encoding https://cdn.jsdelivr.net/npm/[email protected]/lib/encoding.min.js
validator https://cdnjs.cloudflare.com/ajax/libs/validator/13.5.2/validator.min.js
mle-sentiment https://raw.githubusercontent.com/stefandobre/mle-sentiment/main/dist/mle-sentiment.js

Loading modules

You will notice an application process called Setup MLE that runs After Page Submission. This process exposes 2 global helper functions: requireModule and loadScript. Based on a module name, these functions will fetch the CLOB code out of the MLE_MODULE table and execute it. We can then use these functions in After Submit computations, validations, processes etc.

  • requireModule is meant to be used with CommonJS (Node JS-like) modules. Example var qrcode = requireModule('qrcode');
  • loadScript simply loads the script as is (IIFE or Browser-like). Example loadScript('text-encoding');

Some libraries are bundled in such a way that either way of loading will work. Some libraries on the other hand might need extra wrapping.

Further notes

Some libraries can be used without a hitch (see validator). Some libraries need extra attention (see dompurify).

If a library is meant to be used in node-js, you might have to "browserify" it. If a library is meant to be used in the browser, it might just work (validator), you might have to fake things like setTimeout or window (jimp), or you might have to fake a browser environment altogether (dompurify)

I am confident however that this process will get better with time, as MLE progresses, and more developers come up with better ways to bundle and ship libraries.

apex-mle-demo's People

Contributors

stefandobre 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.