박권수

feat. RESTful now

...@@ -3,9 +3,9 @@ const bottleCtrl = require('./bottle.ctrl'); ...@@ -3,9 +3,9 @@ const bottleCtrl = require('./bottle.ctrl');
3 3
4 const bottle = new Router(); 4 const bottle = new Router();
5 5
6 -bottle.post('/connect', bottleCtrl.bottleConnect); 6 +bottle.post('/', bottleCtrl.bottleConnect);
7 -bottle.post('/disconnect/:bottleId', bottleCtrl.bottleDisconnect); 7 +bottle.delete('/:bottleId', bottleCtrl.bottleDisconnect);
8 -bottle.post('/lookupInfo/:bottleId', bottleCtrl.lookupInfo); 8 +bottle.get('/:bottleId', bottleCtrl.lookupInfo);
9 -bottle.post('/setmedicine/:bottleId', bottleCtrl.setMedicine); 9 +bottle.patch('/:bottleId', bottleCtrl.setMedicine);
10 10
11 module.exports = bottle; 11 module.exports = bottle;
...\ No newline at end of file ...\ No newline at end of file
......
...@@ -3,7 +3,7 @@ const hubCtrl = require('./hub.ctrl'); ...@@ -3,7 +3,7 @@ const hubCtrl = require('./hub.ctrl');
3 3
4 const hub = new Router(); 4 const hub = new Router();
5 5
6 -hub.post('/connect', hubCtrl.hubConnect); 6 +hub.post('/', hubCtrl.hubConnect);
7 -hub.post('/disconnect/:hubId', hubCtrl.hubDisconnect); 7 +hub.delete('/:hubId', hubCtrl.hubDisconnect);
8 8
9 module.exports = hub; 9 module.exports = hub;
...\ No newline at end of file ...\ No newline at end of file
......
...@@ -3,6 +3,7 @@ const medicineCtrl = require('./medicine.ctrl'); ...@@ -3,6 +3,7 @@ const medicineCtrl = require('./medicine.ctrl');
3 3
4 const medicine = new Router(); 4 const medicine = new Router();
5 5
6 -medicine.get('/search', medicineCtrl.medicineSearch); 6 +medicine.post('/', medicineCtrl.medicineSearch);
7 +medicine.get('/:medicineId', medicineCtrl.medicineGet);
7 8
8 module.exports = medicine; 9 module.exports = medicine;
...\ No newline at end of file ...\ No newline at end of file
......
...@@ -28,6 +28,25 @@ exports.medicineSearch = async(ctx) => { ...@@ -28,6 +28,25 @@ exports.medicineSearch = async(ctx) => {
28 } 28 }
29 } 29 }
30 30
31 +exports.medicineGet = async(ctx) => {
32 + const token = ctx.cookies.get('access_token');
33 + if(!token) {
34 + ctx.status = 401;
35 + return;
36 + }
37 +
38 + const { medicineId } = ctx.params;
39 + const medicine = await Medicine.findByMedicineId(medicineId);
40 + if(!medicine) {
41 + ctx.status = 404;
42 + return;
43 + }
44 +
45 + ctx.status = 200;
46 + ctx.body = medicine;
47 +
48 +}
49 +
31 //이름으로 약 검색 50 //이름으로 약 검색
32 const medicineSearch_ByName = async(name) => { 51 const medicineSearch_ByName = async(name) => {
33 const result = await Medicine.findByName(name); 52 const result = await Medicine.findByName(name);
......