-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.js
43 lines (36 loc) · 908 Bytes
/
main.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
var express = require('express');
var app = express();
var models = require('./models.js');
console.log(models)
var bodyParser = require('body-parser');
app.use(bodyParser.json());
const asyncMiddleware = fn =>
(req, res, next) => {
Promise.resolve(fn(req, res, next))
.catch(next);
};
app.post('/employees/subscription', (req, res)=>{
models.subscriptions.create(
req.body.email,
req.body.skills
)
});
app.get('/employees/getMatching/:email', (req, res)=>{
// get employees for a certain email account
models.employees.getMatching(
req.params.email
)
});
app.post('/employees/signup', asyncMiddleware(
(req, res)=>{
models.employees.create(
req.body.account,
req.body.password,
req.body.skills,
)
})
);
app.get('/', function(req, res){
res.sendStatus(200);
});
app.listen(3000);