diff --git a/app.ts b/app.ts index 5270c7c..21bbd85 100644 --- a/app.ts +++ b/app.ts @@ -13,7 +13,7 @@ mongoose.Promise = global.Promise; var db = mongoose.connection; db.on('error', console.error.bind(console, 'MongoDB connection error:')); -var app = express(); +const app = express(); app.set('views', path.join(__dirname, 'views')); app.set('view engine', 'hbs'); @@ -23,7 +23,7 @@ app.use(express.json()); app.use(express.urlencoded({ extended: false })); app.use(express.static(path.join(__dirname, 'public'))); -var mainRouter = require('./routes/main'); +import mainRouter from './routes/main'; var apiRouter = require('./routes/api/apiRouter'); app.use('/', mainRouter); diff --git a/routes/main.js b/routes/main.js deleted file mode 100644 index b71a1df..0000000 --- a/routes/main.js +++ /dev/null @@ -1,33 +0,0 @@ -var express = require('express'); -var router = express.Router(); - -const userKnowledge = require('./userKnowledge.json'); - -/* GET home page. */ -router.get('/', function (req, res, next) { - const project = userKnowledge.project; - const experience = userKnowledge.experience; - const education = userKnowledge.education; - res.render('main/2_0', { title: 'Nikola Petrov', disableBootStrap: true, project, experience, education }); -}); - -router.get('/old', function (req, res, next) { - res.render('main/1_0', { title: 'Nikola Petrov' }); -}); - -router.get('/mail', function (req, res, next) { - res.redirect('https://privateemail.com/'); -}); - -router.get('/list', function (req, res, next) { - res.render('list', { title: 'List' }); -}); - -router.get('/cash', function (req, res, next) { - res.render('cash', { title: 'Cash' }); -}); - -const userRouter = require('./user'); -//router.use('/user', userRouter); - -module.exports = router; \ No newline at end of file diff --git a/routes/main.ts b/routes/main.ts new file mode 100644 index 0000000..85c3a1e --- /dev/null +++ b/routes/main.ts @@ -0,0 +1,33 @@ +import express, { type Request, type Response } from "express"; +const router = express.Router(); + +import userData from './userKnowledge.json'; + +/* GET home page. */ +router.get('/', function (req: Request, res: Response) { + const project = userData.project; + const experience = userData.experience; + const education = userData.education; + res.render('main/2_0', { title: 'Nikola Petrov', disableBootStrap: true, project, experience, education }); +}); + +router.get('/old', function (req: Request, res: Response) { + res.render('main/1_0', { title: 'Nikola Petrov' }); +}); + +router.get('/mail', function (req: Request, res: Response) { + res.redirect('https://privateemail.com/'); +}); + +router.get('/list', function (req: Request, res: Response) { + res.render('list', { title: 'List' }); +}); + +router.get('/cash', function (req: Request, res: Response) { + res.render('cash', { title: 'Cash' }); +}); + +import userRouter from './user'; +router.use('/user', userRouter); + +export default router; \ No newline at end of file