UP main.js -> ts

This commit is contained in:
Nikola Petrov 2024-07-16 14:28:57 +02:00
parent c5b2e2d82b
commit 46bf2aca1c
3 changed files with 35 additions and 35 deletions

4
app.ts
View File

@ -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);

View File

@ -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;

33
routes/main.ts Normal file
View File

@ -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;