Defining an App Server

The heart of a Joystick app begins in the /index.server.js file at the root of your app. In development, when you run joystick start, Joystick will run this file via node, starting the Express HTTP server running under the hood and instrumenting all of Joystick's server-side features.

By making a call to the joystick.app() method on the default export from @joystick.js/node, we can define our app server and configure it's behavior.

/index.server.js

import joystick from '@joystick.js/node';

joystick.app({
  routes: {
    '/': (req = {}, res = {}) => {
      res.send('Hello!');
    }
  },
});

API Reference

joystick.app()

Function API

Function API

joystick.app(options: object) => Promise;

Parameters

On This Page