Node.js(Express) 구조

최대 1 분 소요


Routes 구조


(1) source/app.js

app1

app.use('/', indexRouter)

(2) source/routes/index.js

app2

const login = require('./login/index');
const upload = require('./upload/index');
const user = require('./user/index');
const workout = require('./workout/index');

(3) source/routes/workout/index.js

app3

const express = require('express');
const router = express.Router();
const controller = require('./workout.controller');

router.get('/my', controller.getMyWcRt);
router.get('/my/:my_wc_idx', controller.getMyWcIdxRt);
router.post('/my/idx', controller.postMyWcIdxRt);
router.post('/my/alarm', controller.postMyWcAlarmRt);
router.get('/check/:type/:date', controller.getMyWcCheckRt);
module.exports = router;

(4) source/routes/workout/workout.controller.js

const common = require('../common');
const dao = require('./workout.dao');
const auth_config_dev = require('/source/config/auth_config_dev.js');
const moment = require('moment');

exports.getMyWcRt = (req, res, next) => {

}

(5) source/routes/workout/workout.dao.js

const getConnection = require('/source/config/db_config_dev.js');
const common = require('../common');
const mybatisMapper = require('mybatis-mapper');
mybatisMapper.createMapper([ './routes/workout/workout.mapper.xml' ]);
const format = {language: 'sql', indent: '  '};

module.exports = {

    getMyWc :  function(user_idx){
        console.log(user_idx);
        var params = {
            user_idx : user_idx,
            use_yn : 'y'
        };
        var query = mybatisMapper.getStatement('workoutMapper', 'selectMyWc', params, format);
        return common.returnSelectPromise(query);
    },

}

카테고리:

업데이트:

댓글남기기