박권수

feat. api architecture architected

1 +//회원가입, 로그인 및 로그아웃에 관한 api
2 +const User = require('../../models/user');
3 +const Joi = require('joi');
4 +const jwt = require('jsonwebtoken');
5 +
6 +exports.register = async(ctx) => {
7 + ctx.body = 'register'
8 +};
9 +
10 +exports.login = async(ctx) => {
11 + ctx.body = 'login'
12 +};
13 +
14 +exports.logout = async(ctx) => {
15 + ctx.body = 'logout'
16 +};
...\ No newline at end of file ...\ No newline at end of file
......
1 +const Router = require('koa-router');
2 +const authCtrl = require('./auth.ctrl');
3 +
4 +const auth = new Router();
5 +
6 +auth.post('/register', authCtrl.register);
7 +auth.post('/login', authCtrl.login);
8 +auth.post('/logout', authCtrl.logout);
9 +
10 +module.exports = auth;
...\ No newline at end of file ...\ No newline at end of file
......
1 +//어플에서 약병 등록 및, 약병에 관한 정보 조회 = 여기서 mqtt통신으로 broker에 데이터를 요청한다.
2 +const Bottle = require('../../models/bottle')
3 +const DataProcess = require('../../lib/DataProcess');
4 +const MqttModule = require('../../lib/MqttModule');
5 +
6 +exports.lookupInfo = async(ctx) => {
7 + /** toDO
8 + * 약병 데이터를 요청한다
9 + * 1. Broker에 데이터 요청
10 + * 2. Broker에게서 받은 데이터를
11 + * 3. 가공한 후
12 + * 4. 유저에게 http response
13 + */
14 +
15 + const a = dataRequest(); //1.
16 + const b = await getData();
17 + const c = await dataProcess();
18 +
19 + ctx.body = {
20 + a,
21 + b,
22 + c
23 + }
24 +}
25 +
26 +const dataRequest = () => {
27 + return 'dataRequest'
28 +}
29 +
30 +const getData = async() => {
31 + return 'getData'
32 +}
33 +
34 +const dataProcess = async() => {
35 + return 'dataProcess..'
36 +}
37 +
38 +
1 +const Router = require('koa-router');
2 +const bottleCtrl = require('./bottle.ctrl');
3 +
4 +const bottle = new Router();
5 +
6 +bottle.post('/lookupInfo', bottleCtrl.lookupInfo);
7 +
8 +module.exports = bottle;
...\ No newline at end of file ...\ No newline at end of file
1 -const mqtt = require('mqtt'); 1 +//허브(Mqtt Broker)등록 및 삭제
2 +const Hub = require('../../models/hub');
2 3
3 -const MqttConnect = async (ctx) => { 4 +exports.hubRegister = async(ctx) => {
4 - const { host } = ctx.request.body; 5 + ctx.body = 'hubRegister'
5 } 6 }
...\ No newline at end of file ...\ No newline at end of file
......
1 +const Router = require('koa-router');
2 +const hubCtrl = require('./hub.ctrl');
3 +
4 +const hub = new Router();
5 +
6 +hub.post('/register', hubCtrl.hubRegister);
7 +
8 +module.exports = hub;
...\ No newline at end of file ...\ No newline at end of file
......
1 +const Router = require('koa-router');
2 +const auth = require('./auth');
3 +const bottle = require('./bottle');
4 +const hub = require('./hub');
5 +const medicine = require('./medicine');
6 +
7 +const api = new Router();
8 +
9 +api.use('/auth', auth.routes());
10 +api.use('/bottle', bottle.routes());
11 +api.use('/hub', hub.routes());
12 +api.use('/medicine', medicine.routes());
13 +
14 +module.exports = api;
...\ No newline at end of file ...\ No newline at end of file
......
1 +const Router = require('koa-router');
2 +const medicineCtrl = require('./medicine.ctrl');
3 +
4 +const medicine = new Router();
5 +
6 +medicine.get('/search', medicineCtrl.medicineSearch);
7 +
8 +module.exports = medicine;
...\ No newline at end of file ...\ No newline at end of file
......
1 +//해당하는 약의 정보를 불러오거나, 약을 검색
2 +const Medicine = require('../../models/medicine');
3 +
4 +exports.medicineSearch = async(ctx) => {
5 + ctx.body = {
6 + medicineSearch : 'search..'
7 + }
8 +}
9 +
10 +//이름으로 약 검색
11 +const medicineSearch_ByName = async(name) => {
12 +
13 +}
14 +
15 +//제조사명으로 약 검색
16 +const medicineSearch_ByCompany = async(company) => {
17 +
18 +}
19 +
20 +//효능으로 약 검색
21 +const medicineSearch_ByEfficacy = async(efficacy) => {
22 +
23 +}
24 +
25 +//타겟 병명으로 약 검색
26 +const medicineSearch_ByTarget = async(target) => {
27 +
28 +}
...\ No newline at end of file ...\ No newline at end of file
......