我做快遞的教程,我需要幫助理解這個代碼:express - app.get做什麼?
的路線/索引文件夾是這樣的代碼:
module.exports = (app) => {
app.get('/api', (req, res) => res.status(200).send({
message: 'Welcome to the Todos API!',
}));
app.post('/api/todos', todosController.create);
};
,並在應用程序文件,其中它的使用是這樣的代碼,我不明白:
require('./server/routes')(app);
它導出了一個函數,但爲什麼這裏的應用程序用作參數?
對您有幫助嗎? – 2017-03-09 00:04:21