feat: move routes definition to ./routes/
This commit is contained in:
parent
55334fa2b1
commit
0904acb9a9
@ -3,15 +3,10 @@ import dotenv from 'dotenv';
|
|||||||
dotenv.config()
|
dotenv.config()
|
||||||
|
|
||||||
import express from 'express';
|
import express from 'express';
|
||||||
import db from './db';
|
|
||||||
|
|
||||||
const app = express();
|
const app = express();
|
||||||
const port = process.env.PORT ?? 3000;
|
const port = process.env.PORT ?? 3000;
|
||||||
|
|
||||||
app.get('/', async (_req, res) => {
|
|
||||||
const message = await db.example_request();
|
|
||||||
res.send(message);
|
|
||||||
});
|
|
||||||
|
|
||||||
app.listen(port, () => {
|
app.listen(port, () => {
|
||||||
return console.log(`Express is listening at http://localhost:${port}`);
|
return console.log(`Express is listening at http://localhost:${port}`);
|
||||||
|
16
back-end/src/routes/index.ts
Normal file
16
back-end/src/routes/index.ts
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
import { Router } from "express";
|
||||||
|
import db from '../db';
|
||||||
|
|
||||||
|
const routes = Router();
|
||||||
|
|
||||||
|
routes.get('/', async (_req, res) => {
|
||||||
|
const message = await db.example_request();
|
||||||
|
res.send(message);
|
||||||
|
});
|
||||||
|
|
||||||
|
routes.get("/message", async (_req, res) => {
|
||||||
|
const message = await db.example_request();
|
||||||
|
res.render('index.ejs', { message });
|
||||||
|
});
|
||||||
|
|
||||||
|
export default routes;
|
Loading…
x
Reference in New Issue
Block a user