박권수

start. server

1 +.env
2 +./node_modules
3 +*.log
...\ No newline at end of file ...\ No newline at end of file
1 +const Koa = require('koa');
2 +const Router = require('koa-router');
3 +const bodyparser = require('koa-bodyparser');
4 +
5 +const Mongoose = require('mongoose');
6 +
7 +require('dotenv').config();
8 +const { SERVER_PORT, MONGO_URL } = process.env;
9 +
10 +const app = new Koa();
11 +const router = new Router();
12 +
13 +const api = require('./src/api');
14 +
15 +Mongoose.connect(MONGO_URL, {
16 + useNewUrlParser : true,
17 + useUnifiedTopology: true,
18 + useCreateIndex : true
19 +}).then(() => {
20 + console.log('Mongo DB is connected');
21 +}).catch(e => {
22 + console.log(e, error);
23 +})
24 +
25 +app.use(bodyparser());
26 +router.use('/api', api.routes());
27 +app.use(router.routes()).use(allowedMethods());
28 +
29 +app.listen(SERVER_PORT, () => {
30 + console.log(SERVER_PORT, 'is connected');
31 +})
...\ No newline at end of file ...\ No newline at end of file
1 +{
2 + "name": "server",
3 + "version": "1.0.0",
4 + "description": "for Smart Medicine Bottle IoT Server",
5 + "main": "index.js",
6 + "scripts": {
7 + "start" : "node index",
8 + "test": "node test"
9 + },
10 + "repository": {
11 + "type": "git",
12 + "url": "http://khuhub.khu.ac.kr/2021-1-capstone-design1/RIT_Project1.git"
13 + },
14 + "keywords": [
15 + "IoT"
16 + ],
17 + "author": "박권수",
18 + "license": "ISC"
19 +}
1 +const mqtt = require('mqtt');
2 +
3 +const MqttConnect = async (ctx) => {
4 + const { host } = ctx.request.body;
5 +}
...\ No newline at end of file ...\ No newline at end of file
File mode changed