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
-
options object
An object defining options for
joystick.app()
.-
accounts object
An object defining options for Joystick's user accounts APIs like Validating Signup Metadata and Event Hooks.
-
api object
An object representing an API schema for the app.
-
cron_jobs (alias: cronJobs) object
An object containing cron job definitions for the app.
-
csp object
An object containing Content Security Policy (CSP) definitions for the app.
-
events object
An object containing Node.js event listener methods for the app.
-
fixtures function
A function called after the app's databases are connected for defining database fixtures.
-
indexes function
A function called after the app's databases are connected for defining database indexes.
-
middleware array[function]
An array containing Middleware functions for the app.
-
queues object
An object containing queue definitions for the app.
-
routes object Required
An object containing route definitions for the app.
-
uploaders object
An object containing uploader definitions for the app.
-
websockets object
An object containing WebSocket server definitions for the app.
-