| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152 |
- import { Configuration, Inject } from '@tsed/di';
- import { PlatformApplication } from '@tsed/common';
- import '@tsed/platform-express'; // /!\ keep this import
- import bodyParser from 'body-parser';
- import compress from 'compression';
- import cookieParser from 'cookie-parser';
- import methodOverride from 'method-override';
- import '@tsed/swagger';
- export const rootDir = __dirname;
- @Configuration({
- rootDir,
- acceptMimes: ['application/json'],
- httpPort: process.env.PORT || 8080,
- httpsPort: false, // CHANGE
- mount: {
- '/': [
- `${rootDir}/controllers/*.ts`,
- `${rootDir}/middlewares/*.ts`,
- ],
- },
- swagger: [
- {
- path: '/docs',
- specVersion: '3.0.1',
- },
- ],
- exclude: [
- '**/*.spec.ts',
- ],
- })
- export class Server {
- @Inject()
- app: PlatformApplication;
- @Configuration()
- settings: Configuration;
- $beforeRoutesInit(): void {
- this.app
- .use(cookieParser())
- .use(compress({}))
- .use(methodOverride())
- .use(bodyParser.json())
- .use(bodyParser.urlencoded({
- extended: true,
- }));
- }
- }
|