Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- fs.watch(apiRootLocation, {
- recursive: true
- }, () => {
- clearTimeout(watchTimeout)
- watchTimeout = setTimeout(() => {
- invalidateAPI()
- safeConnectAPI(app)
- console.log('API updated!')
- }, 200)
- })
- function safeConnectAPI (app) {
- if (!fs.existsSync(path.resolve(apiRootLocation, 'index.js'))) {
- console.warn(chalk.yellow(`Stub API not found. Please add api from ${apiRootLocation} /index.js`))
- console.warn(chalk.italic.yellow(`
- const router = require('express').Router()
- module.exports = router
- `))
- } else {
- app.use('/api', require(apiRootLocation))
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement