From 940235a6a632be1d5e65520f489c1d1d0062d047 Mon Sep 17 00:00:00 2001 From: bbb169 <827088092@qq.com> Date: Tue, 17 Oct 2023 00:29:32 +0800 Subject: [PATCH] feat: add test route --- app.ts | 3 +++ routes/index.ts | 9 +++++++++ 2 files changed, 12 insertions(+) create mode 100644 routes/index.ts diff --git a/app.ts b/app.ts index cf08e7e..bf705b4 100644 --- a/app.ts +++ b/app.ts @@ -5,6 +5,7 @@ import cookieParser from 'cookie-parser'; import logger from 'morgan'; import cors from 'cors'; import bodyParser from 'body-parser'; +import indexRouter from './routes'; const app = express(); @@ -27,6 +28,8 @@ app.use(bodyParser.urlencoded({ // 配置静态资源路径 app.use(express.static('public')); +app.use('/index', indexRouter); + // 捕捉404并转发到错误处理器 app.use((___, __, next) => { next(createError(404)); diff --git a/routes/index.ts b/routes/index.ts new file mode 100644 index 0000000..d376ee5 --- /dev/null +++ b/routes/index.ts @@ -0,0 +1,9 @@ +import express from 'express'; +const indexRouter = express.Router(); + +/* test. */ +indexRouter.get('/', (req, res) => { + res.send('respond with a resource'); +}); + +export default indexRouter; \ No newline at end of file