#ege-academy-nodejs @rbung @yagong
Expose data, endpoints to trigger backend works
#ege-academy-nodejs @rbung @yagong
#ege-academy-nodejs @rbung @yagong
#ege-academy-nodejs @rbung @yagong
#ege-academy-nodejs @rbung @yagong
#ege-academy-nodejs @rbung @yagong
🙅♂️
#ege-academy-nodejs @rbung @yagong
Routing refers to how an application’s endpoints (URIs) respond to client requests.
app.get('/', function (req, res) {
res.send('hello world')
})
#ege-academy-nodejs @rbung @yagong
Middleware functions are functions that have access to the request object (req), the response object (res), and the next function in the application’s request-response cycle.
const myLogger = function (req, res, next) {
console.log('LOGGED')
next()
}
// ... some code
app.use(myLogger)
#ege-academy-nodejs @rbung @yagong
A lot's of useful middleware !
And more : https://expressjs.com/en/resources/middleware.html
#ege-academy-nodejs @rbung @yagong
#ege-academy-nodejs @rbung @yagong
describe('GET /users', function() {
it('responds with json', function() {
return request(app)
.get('/users')
.set('Accept', 'application/json')
.expect(200)
.then(response => {
assert(response.body.email, 'foo@bar.com')
})
});
});
#ege-academy-nodejs @rbung @yagong