-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.js
More file actions
34 lines (31 loc) · 738 Bytes
/
app.js
File metadata and controls
34 lines (31 loc) · 738 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
import 'dotenv/config';
import express, { json } from 'express';
import { resolve } from 'path';
import routes from './routes';
import './database';
class App {
constructor() {
this.server = express();
this.middlewares();
this.routes();
}
middlewares() {
this.server.use(json());
this.server.use((req, res, next) => {
console.log(
`Request method: ${req.method} ${req.httpVersion} ${req.headers.host}${
req.url
} ${req.headers['user-agent']}`
);
return next();
});
this.server.use(
'/files',
express.static(resolve(__dirname, '..', 'tmp', 'uploads'))
);
}
routes() {
this.server.use(routes);
}
}
module.exports = new App().server;