25 lines
423 B
TypeScript
25 lines
423 B
TypeScript
|
import express from 'express';
|
||
|
import { config } from 'dotenv';
|
||
|
|
||
|
import { errorHandle } from './utils/error-handling';
|
||
|
|
||
|
config();
|
||
|
|
||
|
const app = express();
|
||
|
|
||
|
const port = process.env.PORT;
|
||
|
|
||
|
app.get('/', (req, res) => {
|
||
|
res.send('hello')
|
||
|
})
|
||
|
|
||
|
app.get('/error', (req, res) => {
|
||
|
throw new Error('some mistake')
|
||
|
})
|
||
|
|
||
|
|
||
|
app.use(errorHandle);
|
||
|
app.listen(port, () => {
|
||
|
console.log(`listen on http://localhost:${port}`);
|
||
|
});
|