haplo
haplo lets you write both your front-end and back-end in the same JavaScript codebase.
// main.jshaplo;
The data variable will only exist on the server and be retrieved by the client via AJAX on load. It works by compiling it down to separate files, one for each end, and automatically setting up routes for the transition between contexts.
$ haplo main.js
// client.jshaplo;
// server.jshaplo;
Installation
1. Install haplo globally
$ npm install --global haplo
2. Install haplo in your project
$ npm install haplo
3. Create main.js in the project's root
// app/main.jsvar haplo = ; console;haplo;
4. Create a public folder with an index.html
<!-- app/public/index.html --> <!-- bundle.js will be generated by the haplo command -->
5. Run haplo
$ haplo
6. Done!
Your application is now live at http://localhost:3000.
Fire it up and have a look at the browser's console as well the terminal window where haplo is running. You should see that the console messages are printed in their respective environments.
Example
A simple example app with a MongoDB backend. Input is validated both on the client and server.
// app/main.jsvar haplo = ; var form = documentforms0; form;
<!-- app/public/index.html -->Haplo Example Add item