DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
Refcards Trend Reports Events Over 2 million developers have joined DZone. Join Today! Thanks for visiting DZone today,
Edit Profile Manage Email Subscriptions Moderation Admin Console How to Post to DZone Article Submission Guidelines
View Profile
Sign Out
Refcards
Trend Reports
Events
Zones
Culture and Methodologies Agile Career Development Methodologies Team Management
Data Engineering AI/ML Big Data Data Databases IoT
Software Design and Architecture Cloud Architecture Containers Integration Microservices Performance Security
Coding Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Partner Zones AWS Cloud
by AWS Developer Relations
Culture and Methodologies
Agile Career Development Methodologies Team Management
Data Engineering
AI/ML Big Data Data Databases IoT
Software Design and Architecture
Cloud Architecture Containers Integration Microservices Performance Security
Coding
Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance
Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Partner Zones
AWS Cloud
by AWS Developer Relations
  1. DZone
  2. Coding
  3. JavaScript
  4. Full Stack Development From Client-Side JavaScript [No Node.js]

Full Stack Development From Client-Side JavaScript [No Node.js]

We take a look at one developer's experiment, where he hopes to create a way to code a full stack app using only client-side JS.

Thomas Hansen user avatar by
Thomas Hansen
CORE ·
Sep. 19, 18 · Analysis
Like (2)
Save
Tweet
Share
5.68K Views

Join the DZone community and get the full member experience.

Join For Free

In case you think the above header sounds like an oxymoron or some sort of black magic, think again. With Lizzie, you can (at least in theory) create your entire business logic in JavaScript, in your browser, submit your Lizzie code to the server for evaluation (securely), and have it return JSON back to your client.

For the record, this assumes you've previously created generic "hooks" in C#, allowing your Lizzie code to do something useful, since, out of the box, Lizzie can barely do anything at all, besides from creating lists, dictionaries, do basic math, and some simple string manipulation. However, if you create generic methods for retrieving data from your database, etc., creating your business logic in JavaScript as Lizzie code, and transmitting this code to your server for evaluation, is actually a breeze. This in turns creates a much more dynamic server-side API, allowing you to (after a while) do anything you want from JavaScript, without having to code in (any) server-side language at all. At least that's how the theory goes. To understand what I am talking about, picture the following code.

[Route("api/[controller]")]
public class LizzieController : Controller
{
    [HttpPost]
    public string Post()
    {
        try
        {
            using (var reader = new StreamReader(Request.Body))
            {
                string code = reader.ReadToEnd();
                var lambda = LambdaCompiler.Compile(this, code);
                var result = lambda();
                return result?.ToString() ?? string.Empty;
            }
        }
        catch (Exception err)
        {
            Response.StatusCode = 500;
            return err.Message;
        }
    }

    #region [ -- Lizzie functions -- ]

    [Bind(Name = "howdy")]
    object Howdy(Binder<LizzieController> binder, Arguments arguments)
    {
        return "Hello " + arguments.Get<string>(0);
    }

    #endregion
}

The beauty of the above C# Web API code is that the endpoint accepts CODE as input. This allows you to create a single HTTP REST endpoint, accepting code over a POST request, that will evaluate your code (securely), returning JSON back to the client.

Which again effectively allows you to (at least in theory) create your entire application in client-side JavaScript, connecting to a "generic" backend, reducing the server to a simple "Lizzie evaluator," making it possible to create arguably your entire web app in Angular, React, etc. Below is a screenshot of a simple example application I created with this pattern, that allows me to type code into a CodeMirror instance in my browser, send my code to my server, evaluate the code, and display the results of the evaluation in another CodeMirror instance.

Image title

The above project can be downloaded here.

JavaScript Node.js

Opinions expressed by DZone contributors are their own.

Popular on DZone

  • Solving the Kubernetes Security Puzzle
  • What Is API-First?
  • Tracking Software Architecture Decisions
  • Comparing Map.of() and New HashMap() in Java

Comments

Partner Resources

X

ABOUT US

  • About DZone
  • Send feedback
  • Careers
  • Sitemap

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 600 Park Offices Drive
  • Suite 300
  • Durham, NC 27709
  • support@dzone.com
  • +1 (919) 678-0300

Let's be friends: