I create the class user where i just only define the get method but when i call the class in middleware and use it, it not show any error but when i run the code it show server not found. when i del this line app.use(userRoute) my server work.
users.ts
import { NextFunction, Request, Response } from 'express';
import { Controller, Get, Req, Res } from 'routing-controllers'
@Controller()
class User {
@Get('/signup')
signUP(@Req() req: Request, @Res() res: Response, next: NextFunction) {
return res.render('signup')
};
}
export { User as userRoute }
app.ts
const express = require('express')
const path = require('path')
const app = express()
import { userRoute } from "./routes/user";
const bodyPaser = require('body-parser')
app.use(bodyPaser.urlencoded({ extended: true }))
app.set('views', path.join(__dirname, 'views'))
app.set('view engine', 'ejs')
app.use(userRoute)
app.use('/', (req, res) => {
res.write('<html lang="eng">');
res.write('<head><title>Page</title><style>body{background-color: wheat; color: red; font- size: 25px; padding-left: 250px;}.d{}</style></head>')
res.write('<body><h1>It is working</h1></body>')
res.write('</html>')
return res.end()
});
app.listen('3000')
console.log('working')