From 56fc550e3449db25289f1fac03f7e8c5812de372 Mon Sep 17 00:00:00 2001 From: Daniel <nieltansah@gmail.com> Date: Wed, 22 Nov 2017 18:30:34 +0700 Subject: [PATCH] app: Use global model --- app/api/driver.js | 14 +------------- app/model/{Hub.js => hub.js} | 2 +- 2 files changed, 2 insertions(+), 14 deletions(-) rename app/model/{Hub.js => hub.js} (98%) diff --git a/app/api/driver.js b/app/api/driver.js index 64d5f03..ed5668b 100644 --- a/app/api/driver.js +++ b/app/api/driver.js @@ -6,12 +6,10 @@ const express = require('express') -const Hub = require('../model/Hub.js') +const hub = require('../model/hub.js') let app = express.Router() -let hub = new Hub() - app.get('/find', function (req, res) { let location = req.query.location @@ -20,16 +18,6 @@ app.get('/find', function (req, res) { }) }) -app.get('/:id', function (req, res) { - let id = req.params.id - - if (hub.drivers[id]) { - res.json({}) - } else { - res.status(404).json({ 'error': 'Driver is not found' }) - } -}) - app.post('/', async function (req, res) { let id = req.body.driver_id let locations = req.body.locations diff --git a/app/model/Hub.js b/app/model/hub.js similarity index 98% rename from app/model/Hub.js rename to app/model/hub.js index 4fd79d7..0a90074 100644 --- a/app/model/Hub.js +++ b/app/model/hub.js @@ -93,4 +93,4 @@ class Hub { } } -module.exports = Hub +module.exports = new Hub() -- GitLab