Skip to main content

Additional Routing Methods

There are two main methods of creating routes (And a third method advanced method discussed here)

const app = new EzBackend();
const base = new EzApp();

//METHOD 1
base.get('/method1', async (req, res) => {
return { hello: 'world' };
});

//METHOD 2
base.setHandler('Method 2', async (instance, opts) => {
instance.server.get('/method2', async (req, res) => {
return { hello: 'world' };
});
});

app.addApp('base', base);

app.start();

Both methods are the same, however each method has their pros and cons

MethodProsCons
1Shorter SyntaxNo instance access
2Instance accessLonger Syntax

There are several other methods for creating routes as well, for exampl