2 Hello world - Atlantis-Software/synapps GitHub Wiki

Hello world

Embedded below is essentially the simplest Synapps app you can create. It is a single file app.

var synapps = require('@synapps/core');
var app = synapps();

app.route('/', function(req) {
  req.resolve('hello world');
});

app.listen(3000);

This app starts a server and listens on port 3000 for connections. The app responds with “Hello World!” for requests to root URL (/). For every other path, it will respond with a 404 Not Found.

First create a directory named myapp, change to it and run npm init. Then install synapps as a dependency, as per the installation guide.

In the myapp directory, create a file named app.js and copy in the code from the example above.

Run the app with the following command:

$ node app.js

Then, load http://localhost:3000/ in a browser to see the output.