From 2da4594a175085825e7e8c5f29828db5d35cb22a Mon Sep 17 00:00:00 2001 From: hminn Date: Sun, 9 May 2021 02:31:00 +0900 Subject: [PATCH] =?UTF-8?q?feat:=20express=20=EC=84=9C=EB=B2=84=20?= =?UTF-8?q?=EA=B5=AC=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- BACK/hyeokim/app.js | 10 ++++++++++ BACK/hyeokim/middleware/index.js | 6 ++++++ BACK/hyeokim/package.json | 15 +++++++++++++++ BACK/hyeokim/routes/index.js | 13 +++++++++++++ 4 files changed, 44 insertions(+) create mode 100644 BACK/hyeokim/app.js create mode 100644 BACK/hyeokim/middleware/index.js create mode 100644 BACK/hyeokim/package.json create mode 100644 BACK/hyeokim/routes/index.js diff --git a/BACK/hyeokim/app.js b/BACK/hyeokim/app.js new file mode 100644 index 0000000..ffd95bd --- /dev/null +++ b/BACK/hyeokim/app.js @@ -0,0 +1,10 @@ +const express = require('express') +const indexRouter = require('./routes/index'); +const app = express() +const port = 3000 + +app.use('/', indexRouter); + +app.listen(port, () => { + console.log(`Example app listening at http://localhost:${port}`) +}); \ No newline at end of file diff --git a/BACK/hyeokim/middleware/index.js b/BACK/hyeokim/middleware/index.js new file mode 100644 index 0000000..2703d30 --- /dev/null +++ b/BACK/hyeokim/middleware/index.js @@ -0,0 +1,6 @@ +function middleware(req, res, next) { + console.log('Time: ', Date.now()); + next(); +}; + +module.exports = middleware; \ No newline at end of file diff --git a/BACK/hyeokim/package.json b/BACK/hyeokim/package.json new file mode 100644 index 0000000..4fd81b0 --- /dev/null +++ b/BACK/hyeokim/package.json @@ -0,0 +1,15 @@ +{ + "name": "hyeokim", + "version": "1.0.0", + "description": "", + "main": "index.js", + "scripts": { + "test": "echo \"Error: no test specified\" && exit 1" + }, + "author": "", + "license": "ISC", + "dependencies": { + "ejs": "^3.1.6", + "express": "^4.17.1" + } +} diff --git a/BACK/hyeokim/routes/index.js b/BACK/hyeokim/routes/index.js new file mode 100644 index 0000000..fd3dcb2 --- /dev/null +++ b/BACK/hyeokim/routes/index.js @@ -0,0 +1,13 @@ +const express = require("express"); +const router = express.Router(); +const middle = require("../middleware"); + +router.get("/", (req, res) => { + res.send("

Hello hyeokim's Express

"); +}); + +router.get('/time', middle, (req, res) => { + res.send("

Time home page

Refresh and Check the console!

"); +}); + +module.exports = router; \ No newline at end of file