forked from Arquisoft/wiq_0
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #53 from Arquisoft/Marina
Pull Request para el Issue: #26 (Temporizador)
- Loading branch information
Showing
3 changed files
with
54 additions
and
114 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
|
||
app.use((req, res, next) => { | ||
res.setHeader('Access-Control-Allow-Origin', 'http://localhost:3000'); | ||
res.setHeader('Access-Control-Allow-Methods', 'GET, POST, OPTIONS, PUT, PATCH, DELETE'); | ||
res.setHeader('Access-Control-Allow-Headers', 'Content-Type, Authorization'); | ||
res.setHeader('Access-Control-Allow-Credentials', true); | ||
next(); | ||
}); | ||
|
||
app.get('/timer', async (req, res) => { | ||
|
||
const time = parseInt(req.params.time); | ||
startTimer(time,() =>{ | ||
res.send("Time up"); | ||
}) | ||
|
||
}); | ||
|
||
function startTimer(time,func){ | ||
this.timer = setTimeout(()=>{ | ||
func(); | ||
},time) | ||
} | ||
|
||
var server = app.listen(port, () => { | ||
console.log(`Questions Generation Service listening at http://localhost:${port}`); | ||
}); | ||
|
||
module.exports = server |
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