Created
June 28, 2018 13:38
-
-
Save shierro/38d5697aed749661d89a0d12a2c04ce0 to your computer and use it in GitHub Desktop.
express.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const UserController = { | |
get(req, res, next) { | |
try { | |
new Promise(resolve => setTimeout(() => resolve({ success: true }), 5000)) | |
.then(res.json) | |
.catch(res.json); | |
} catch (e) { | |
next(e); | |
} | |
}, | |
}; | |
module.exports = UserController; | |
const UserController = require('./controllers/UserController'); | |
module.exports = (app) => { | |
const router = express.Router(); | |
/* APIs */ | |
app.use('/api', router); | |
router.get('/user', UserController.get); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment