import express from 'express';
import { makeExpressHandlers } from './sextant-express.generated';
import { describeSextantFeature } from './sextant-jest.generated';

const app = express();

const handlers = makeExpressHandlers('frontend', 'lambda', {
  getPosts: (req, res) => {
    res.json({
      type: 'NO_POSTS_FOUND',
    });
  },
  getComments(req, res) {
    res.json({
      type: 'COMMENTS',
      comments: ['Wow'],
    });
  },
});

handlers.forEach(({ feature, handler }) => {
  app.post(`/${feature}`, handler);
});

app.listen(3000);

describeSextantFeature('getPosts', (getUsers) => {
  getUsers.test('success', () => {});
  getUsers.test('noPostsFound', () => {});

  getUsers.testCoverage();
});
