박권수

feat. api architecture architected

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