-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathindex.js
56 lines (42 loc) · 1.72 KB
/
index.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
44
45
46
47
48
49
50
51
52
53
54
55
56
// import config/app
// importa config/app
var app = require('./config/app');
// importar config/db
// import config/db
const db = require('./config/db');
// importar controllers/recipeController
// import controllers/recipeController
var recipeController = require('./controllers/recipeController');
// importar controllers/userController
// import controllers/userController
var userController = require('./controllers/userController');
// importar routes/recipeRouter
// import routes/recipeRouter
var recipeRouter = require('./routes/recipeRouter');
// importar routes/userRouter
// import routes/userRouter
var userRouter = require('./routes/userRouter');
// direcciona para .../api-culinary-recipes/v1
// redirect to .../api-culinary-recipes/v1
app.get('/', function(req, res) {
res.redirect('/api-culinary-recipes/v1');
});
app.get('/api-culinary-recipes', function(req, res) {
res.redirect('/api-culinary-recipes/v1');
});
// defenição rota '/api-culinary-recipes/v1'
// route definition '/api-culinary-recipes/v1'
app.get('/api-culinary-recipes/v1', function(req, res){
//após aceder a rota devolve uma mensagem com o nome api e versão
//return message with name api and version
res.end(`Bem-vindo a API ${app.get('name-api')} versao ${app.get('versao-api')}`);
});
app.get('/', function(req, res){
res.end(`Bem-vindo a API ${app.get('name-api')} versao ${app.get('versao-api')}`);
});
// defenição rota '/api-culinary-recipes/v1/recipe'
// route definition '/api-culinary-recipes/v1/recipe'
app.use('/api-culinary-recipes/v1/recipe', recipeRouter);
// defenição rota 'api-culinary-recipes/v1/user'
// route definition 'api-culinary-recipes/v1/user'
app.use('/api-culinary-recipes/v1/user', userRouter);