-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.js
More file actions
18 lines (18 loc) · 689 Bytes
/
app.js
File metadata and controls
18 lines (18 loc) · 689 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
const express = require('express')
const app = express()
const events = require('events')
const eventsEmitter = new events.EventEmitter()
const port = 3000
app.get('/', (req, res) => {
eventsEmitter.emit('scream')
// when we need to inform someone about certain task in this case events is good
res.send('Hello World!')
})
let myEventsHandler = function () {
console.log('i heard scream')
}
eventsEmitter.on('scream', myEventsHandler)
app.get('/user', require('./app/controller/userController').userDetails)
app.get('/sendMail', require('./app/controller/userController').sendMail)
app.listen(port, () => console.log(`Example app listening on port ${port}!`))
module.exports = app