How to use the @tsed/common.ServerSettings function in @tsed/common

To help you get started, we’ve selected a few @tsed/common examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github TypedProject / ts-express-decorators / integration / vuejs / packages / server / src / Server.ts View on Github external
import {GlobalAcceptMimesMiddleware, ServerLoader, ServerSettings} from "@tsed/common";
import "@tsed/swagger";
import * as bodyParser from "body-parser";
import * as compress from "compression";
import * as cookieParser from "cookie-parser";
import * as methodOverride from "method-override";
import * as path from "path";

const rootDir = __dirname;
const clientDir = path.join(rootDir, "../../client/dist");

@ServerSettings({
  rootDir,
  acceptMimes: ["application/json"],
  httpPort: process.env.PORT || 8081,
  httpsPort: false,
  logger: {
    debug: true,
    logRequest: true,
    requestFields: ["reqId", "method", "url", "headers", "query", "params", "duration"]
  },
  mount: {
    "/rest": [
      `${rootDir}/controllers/**/*.ts` // Automatic Import, /!\ doesn't works with webpack/jest, use  require.context() or manual import instead
    ]
  },
  swagger: [
    {
github TypedProject / ts-express-decorators / examples / aws / src / Server.ts View on Github external
import {GlobalAcceptMimesMiddleware, ServerLoader, ServerSettings} from "@tsed/common";
import "@tsed/swagger";
import {$log} from "ts-log-debug";
import {RestCtrl} from "./controllers/RestCtrl";

const cookieParser = require("cookie-parser");
const bodyParser = require("body-parser");
const compress = require("compression");
const methodOverride = require("method-override");
const rootDir = __dirname;

@ServerSettings({
  rootDir,
  acceptMimes: ["application/json"],
  logger: {
    debug: true,
    logRequest: true,
    requestFields: ["reqId", "method", "url", "headers", "query", "params", "duration"]
  },
  mount: {
    "/rest": [
      RestCtrl, // Manual import
      `${rootDir}/controllers/**/*.ts` // Automatic Import, /!\ doesn't works with webpack/jest, use  require.context() or manual import instead
    ]
  },
  swagger: {
    path: "/api-docs"
  },
github TypedProject / ts-express-decorators / examples / getting-started / src / Server.ts View on Github external
import {GlobalAcceptMimesMiddleware, ServerLoader, ServerSettings} from "@tsed/common";
import "@tsed/swagger";
import * as bodyParser from "body-parser";
import * as compress from "compression";
import * as cookieParser from "cookie-parser";
import * as methodOverride from "method-override";
import * as cors from "cors";
import {join} from "path";
import {RestCtrl} from "./controllers/RestCtrl";

const rootDir = __dirname;

@ServerSettings({
  rootDir,
  acceptMimes: ["application/json"],
  httpPort: process.env.PORT || 8083,
  httpsPort: false, // CHANGE
  logger: {
    debug: true,
    logRequest: true,
    requestFields: ["reqId", "method", "url", "headers", "query", "params", "duration"]
  },
  mount: {
    "/rest": [
      RestCtrl, // Manual import (remove it)
      `${rootDir}/controllers/**/*.ts` // Automatic Import, /!\ doesn't works with webpack/jest, use  require.context() or manual import instead
    ]
  },
  swagger: [
github TypedProject / ts-express-decorators / test / integration / app / app.ts View on Github external
import {ErrorsCtrl} from "./controllers/errors/ErrorsCtrl";
import {SocketPageCtrl} from "./controllers/pages/SocketPageCtrl";
import {ProductsCtrl} from "./controllers/products/ProductsCtrl";

import {RestCtrl} from "./controllers/RestCtrl";
import TestAcceptMimeMiddleware from "./middlewares/acceptmime";
import "./middlewares/CustomAuthMiddleware";
import {InitSessionMiddleware} from "./middlewares/InitSessionMiddleware";
import {NotFoundMiddleware} from "./middlewares/NotFoundMiddleware";

const rootDir = Path.resolve(__dirname);
const spec = require(`${rootDir}/spec/swagger.default.json`);

Docs("authentication")(PassportCtrl);

@ServerSettings({
  rootDir,
  port: 8001,
  httpsPort: false,
  logger: {
    level: "info",
    logRequest: true
  },
  mount: {
    "/": [SocketPageCtrl],
    "/rest": [
      "${rootDir}/controllers/Base/**.ts",
      "${rootDir}/controllers/calendars/**.ts",
      ErrorsCtrl,
      RestCtrl,
      ProductsCtrl,
      PassportCtrl
github TypedProject / ts-express-decorators / examples / mongoose / src / Server.ts View on Github external
import {GlobalAcceptMimesMiddleware, ServerLoader, ServerSettings} from "@tsed/common";
import "@tsed/mongoose";
import "@tsed/swagger";

@ServerSettings({
  rootDir: __dirname,
  acceptMimes: ["application/json"],
  port: process.env.POST || 8000,
  httpsPort: false,
  passport: {},
  mongoose: {
    url: process.env.mongoose_url || "mongodb://127.0.0.1:27017/example-mongoose-test"
  },
  swagger: {
    path: "/api-docs"
  },
  debug: false
})
export class Server extends ServerLoader {
  $beforeRoutesInit(): void | Promise {
github TypedProject / ts-express-decorators / docs / tutorials / snippets / session / configuration-middleware.ts View on Github external
import {ServerLoader, ServerSettings} from "@tsed/common";
import {CreateRequestSessionMiddleware} from "./middlewares/CreateRequestSessionMiddleware";

const cookieParser = require("cookie-parser");
const bodyParser = require("body-parser");
const compress = require("compression");
const methodOverride = require("method-override");
const session = require("express-session");

@ServerSettings({})
class Server extends ServerLoader {

  /**
   * This method let you configure the express middleware required by your application to works.
   * @returns {Server}
   */
  public $beforeRoutesInit(): void | Promise {

    this
      .use(cookieParser())
      .use(compress({}))
      .use(methodOverride())
      .use(bodyParser.json())
      .use(bodyParser.urlencoded({
        extended: true
      }));
github TranBaVinhSon / microservice_nodejs_template / packages / backend / src / Server.ts View on Github external
import { GlobalAcceptMimesMiddleware, ServerLoader, ServerSettings } from "@tsed/common";
import bodyParser from "body-parser";
import compress from "compression";
import cookieParser from "cookie-parser";
import methodOverride from "method-override";

const rootDir = __dirname;

@ServerSettings({
  rootDir,
  acceptMimes: ["application/json"],
  httpPort: 8000,
  httpsPort: false,
})
export class Server extends ServerLoader {
  /**
   * This method let you configure the express middleware required by your application to works.
   * @returns {Server}
   */
  public $beforeRoutesInit(): void | Promise {
    this.use(GlobalAcceptMimesMiddleware)
      .use(cookieParser())
      .use(compress({}))
      .use(methodOverride())
      .use(bodyParser.json())
github replicatedhq / kots / kotsadm / api / src / server / server.ts View on Github external
import fs from "fs";
import { KurlStore } from "../kurl/kurl_store";
import { ReplicatedError } from "./errors";
import { MetricStore } from "../monitoring/metric_store";
import { ParamsStore } from "../params/params_store";
import { ensureBucket } from "../util/s3";
import { SnapshotScheduler } from "../snapshots/schedule";

let mount = {
  "/": "${rootDir}/../controllers/{*.*s,!(ship)/*.*s}"
};
let componentsScan = [
  "${rootDir}/../middlewares/**/*.ts",
];

@ServerSettings({
  rootDir: path.resolve(__dirname),
  httpPort: 3000,
  httpsPort: false,
  mount,
  componentsScan,
  acceptMimes: ["application/json"],
  logger: {
    logRequest: false,
  },
  multer: {
    dest: "${rootDir}/uploads"
  },
  socketIO: {},
})
export class Server extends ServerLoader {
  async $onMountingMiddlewares(): Promise {
github TypedProject / ts-express-decorators / integration / typeorm / src / Server.ts View on Github external
import {GlobalAcceptMimesMiddleware, ServerLoader, ServerSettings} from "@tsed/common";
import "@tsed/swagger";
import "@tsed/typeorm";

const cookieParser = require("cookie-parser");
const bodyParser = require("body-parser");
const compress = require("compression");
const methodOverride = require("method-override");
const session = require("express-session");
const rootDir = __dirname;

@ServerSettings({
  rootDir,
  port: 3000,
  acceptMimes: ["application/json"],
  mount: {
    "/v1": `${rootDir}/controllers/**/**Ctrl.{ts,js}`
  },
  typeorm: [
    {
      name: "default",
      type: "postgres",
      host: "localhost",
      port: 5432,
      username: "postgres",
      password: "",
      database: "romain.lenzotti",
      synchronize: true,
github TypedProject / ts-express-decorators / integration / socketio / src / Server.ts View on Github external
import {GlobalAcceptMimesMiddleware, ServerLoader, ServerSettings} from "@tsed/common";
import "@tsed/socketio";
import "@tsed/swagger";

const bodyParser = require("body-parser");
const methodOverride = require("method-override");
const cons = require("consolidate");
const rootDir = __dirname;

@ServerSettings({
  rootDir,
  viewsDir: `${rootDir}/views`,
  port: 3000,
  acceptMimes: ["application/json"],
  mount: {
    "/": `${rootDir}/controllers/pages/**/*.ts`,
    "/rest": `${rootDir}/controllers/rest/**/*.ts`
  },
  statics: {
    "/": [
      "./public",
      "./node_modules"
    ]
  },
  swagger: {
    path: "/docs"