-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
62 lines (48 loc) · 1.69 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
57
58
59
60
61
62
/*
npm init -y
npm i express nodemon sequelize mysql2
npm i sequelize-cli
npx sequelize-cli init
// Criar banco de dados com base na configuração do config.json
npx sequelize db:create
// Criar as migrations
npx sequelize migration:generate --name create-plans
npx sequelize migration:generate --name create-patients
npx sequelize migration:generate --name create-surgeries
npx sequelize migration:generate --name create-patient_surgeries
// Executar as migrations
npx sequelize db:migrate
// Desfazer as migrations
npx sequelize db:migrate:undo:all
// Povoar banco de dados
// Criar o seed
npx sequelize seed:generate --name plans
npx sequelize seed:generate --name patients
npx sequelize seed:generate --name sugeries
npx sequelize seed:generate --name patient_sugeries
// Executar as seeds
npx sequelize db:seed:all
// Desfazer as seeds
npx sequelize db:seed:undo:all
*/
const express = require('express');
const bodyParser = require('body-parser');
const {
getAllPatientsPlans,
getAllPatientsSurgeries,
createPatients,
getPatientsAndSurgeriesNoDoctor,
} = require('./controllers/patientsController');
const getAllPlans = require('./controllers/plansController');
const getDoctorSurgeries = require('./controllers/surgeriesController');
const app = express();
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({ extended: false }));
app.post('/', createPatients)
app.get('/all', getAllPatientsPlans);
app.get('/surgeries', getAllPatientsSurgeries);
app.get('/surgeries/nodoctor', getPatientsAndSurgeriesNoDoctor);
app.get('/surgeries/:name', getDoctorSurgeries);
app.get('/:id', getAllPlans);
const PORT = process.env.PORT || 3000;
app.listen(PORT, () => console.log(`Ouvindo na porta ${PORT}`));