Let's start by defining the first routes we need and how we want them to behave and simple logical steps building what's strictly essential first, in a TDD style.
The first thing is that we need users to be able to register; the smallest test case to register our user is as follows:
'''javascript var dbCleanup = require('./utils/db') var expect = require('chai').expect; var request = require('supertest'); var app = require('../src/app'); describe('Registration', function() { it("shoots a valid request", function(done){ var user = { 'email': 'supertest'+Math.random()+'@example.com', 'name': 'Super'+Math.random(), }; request(app) .post('/register') .send(user) .expect(200, done); }) })
Assuming you have Mocha installed with
npm i -g mocha
, executemocha
.See 404? Good start! Now let's expand and create a file,
src/route/index.js
, which will declare all the routes known to the app. It uses controllers that handle each concern.Start...