import { init } from '..';
import { router } from './routes';

const app1 = init()
  .render('/custom/a', '/b')
  .render('/range/:id', '/range')
  .use(router)
  .get('/yo', (req, res) => res.send('yo'))
  .redirect('/redirect/1', '/normal')
  .file('/package.json', './package.json');

const app2 = init({
  // static: './static',
  // dir: './lib',
  // port: 1234,
  // silent: true,
})
  // Next.js route/page rendering.
  // .render('/custom/a', '/b')
  // .render('/range/:id', '/range')
  .use(app1)

  // REST API.
  .get('/api', (req, res) => res.send({ method: 'GET', now: new Date() }))
  .post('/api', (req, res) => res.send({ method: 'POST', body: req.body }))

  // Custom middleware.
  // .use(router)

  // URL redirection.
  // .redirect('/redirect/1', '/normal')
  .redirect('/redirect/2', '/normal?color=red')
  .redirect('/redirect/id/:id', req => `/normal?id=${req.params.id}`)
  .redirect('/login', '/auth/login')

  // Static files.
  .static('/test.ui', './node_modules/@tdb/ui.test/static/test.ui')
  // .file('/package.json', './package.json')
  .file('/foo.css', './node_modules/mocha/mocha.css');

// Start
// .start();
// .start(8080);

app2.start();
// .start(8080)
