GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Nullstack
  • What is Nullstack?
  • Documentation
  • Examples
  • Contributors
  • F.A.Q
  • Waifu
  • Português
  • Star
  • Leave a star on GitHub

This view

  • Original page
  • New address

GeezerVison is showing nullstack.app — Using Nullstack as a Web API - Nullstack

Using Nullstack as a Web API

Nullstack can be used as a Web API. Nullstack runs an Express server behind the scenes allowing you to configure your own routes and build a fully customized Web API.

You can configure the Express routes by using the server object available in the Nullstack Context on server.js.

// server.js
import Nullstack from 'nullstack';
import Application from './src/Application';

const context = Nullstack.start(Application);

context.server.get('/api/waifus', (request, response) => {
  response.json({waifus: []});
});

export default context;

It's also possible to expose server functions from your components to be in the web API. Instead of using a function that a request and a response pass the static function from your component to the express route.

// server.js
import Nullstack from 'nullstack';
import Application from './src/Application';
import WaifuComponent from './src/WaifuComponent';

const context = Nullstack.start(Application);

context.server.get('/waifus', WaifuComponent.getWaifus)

export default context;
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.