Skip to content

rickfast/pachyderm

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

27 Commits
 
 
 
 
 
 

Repository files navigation

Pachyderm

A Javascript micro web framework for the JVM. Download/Installation instructions here.

// app.js
app.get('/hello', function(req, res) {
    res.render({ text: 'hello' });
});

Run using Pachyderm:

./bin/pachyderm ~/app.js

View response at http://localhost:8080/hello

Rendering views

Pachyderm uses underscore.js templating for rendering views. By default, views go in the /views folder relative to the Javascript app code.

app.get('/example/{number}', function(req, res) {
    var value = req.getParams().get("number");

    res.render({ view: "example.html", model: { someValue: value }});
});

View code (in views directory):

<!-- views/example.html -->
<li><%= someValue %></li>

View response at http://localhost:8080/example/12

Rendering JSON

app.get('/example', function(req, res) {
    res.render({json: { value: "something", other: 12.0 }});
}

View response at http://localhost:8080/example

Resolving Java dependencies

Pachyderm can resolve Java dependencies at runtime:

with(maven) {
	addDependency("commons-email:commons-email:1.1");
}

app.get('/email', function(req, res) {
	var email = new org.apache.commons.mail.SimpleEmail();

	email.setHostName("mail.myserver.com");
	email.addTo("[email protected]", "John Doe");
	email.setFrom("[email protected]", "Me");
	email.setSubject("Test message");
	email.setMsg("This is a simple test of commons-email");
	email.send();
});

Configuring Pachyderm

// set the port to 8181
config.setPort(8181);

app.get('/', function(req, res) {
    res.render({ text: 'port changed to 8181' });
}

About

A Javascript micro web framework for the JVM.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published