How to use the typescript-rest.Server function in typescript-rest

To help you get started, we’ve selected a few typescript-rest 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 vellengs / typerx / dist / api-server.js View on Github external
constructor() {
        this.server = null;
        this.PORT = parseInt(process.env.PORT, 0) || 3600;
        this.app = express();
        this.config();
        mongoose.connect(config.db, {
            useMongoClient: true,
        });
        const db = mongoose.connection;
        autoIncrement.initialize(db);
        db.on('error', (err) => {
            throw new Error('unable to connect to database at ' + config.db + err);
        });
        typescript_rest_1.Server.buildServices(this.app, ...controllers_1.default);
        // TODO: enable for Swagger generation error
        // Server.loadServices(this.app, 'controllers/*', __dirname);
        typescript_rest_1.Server.swagger(this.app, './dist/swagger.json', '/api-docs', 'localhost:3600', ['http']);
        this.app.use((err, req, res, next) => {
            if (res.headersSent) {
                return next(err);
            }
            if (err && err.statusCode) {
                res.status(err.statusCode);
            }
            else {
                res.status(500);
            }
            res.send({ error: err });
        });
    }
github vellengs / typerx / dist / api-server.js View on Github external
this.server = null;
        this.PORT = parseInt(process.env.PORT, 0) || 3600;
        this.app = express();
        this.config();
        mongoose.connect(config.db, {
            useMongoClient: true,
        });
        const db = mongoose.connection;
        autoIncrement.initialize(db);
        db.on('error', (err) => {
            throw new Error('unable to connect to database at ' + config.db + err);
        });
        typescript_rest_1.Server.buildServices(this.app, ...controllers_1.default);
        // TODO: enable for Swagger generation error
        // Server.loadServices(this.app, 'controllers/*', __dirname);
        typescript_rest_1.Server.swagger(this.app, './dist/swagger.json', '/api-docs', 'localhost:3600', ['http']);
        this.app.use((err, req, res, next) => {
            if (res.headersSent) {
                return next(err);
            }
            if (err && err.statusCode) {
                res.status(err.statusCode);
            }
            else {
                res.status(500);
            }
            res.send({ error: err });
        });
    }
    /**
github vellengs / typerx / packages / server / dist / application.js View on Github external
hostSwaggerDocs() {
        const swaggerPath = process.env.SWAGGER;
        if (fs_1.existsSync(path.resolve(process.env.SWAGGER))) {
            typescript_rest_1.Server.swagger(this.app, swaggerPath, '/docs', 'localhost:' + this.PORT, ['http', 'https']);
        }
    }
    config() {
github vellengs / typerx / packages / server / dist / application.js View on Github external
setUploadsFolder() {
        const uploads = path.resolve(process.cwd(), 'public', 'uploads');
        typescript_rest_1.Server.setFileDest(uploads);
    }
    hostSwaggerDocs() {
github TreeGateway / tree-gateway / bin / lib / gateway.js View on Github external
Gateway.prototype.configureAdminServer = function () {
        this.adminApp = express();
        this.adminApp.disable('x-powered-by');
        this.adminApp.use(compression());
        this.adminApp.use(logger('dev'));
        admin_server_1.APIService.gateway = this;
        typescript_rest_1.Server.buildServices(this.adminApp, admin_server_1.APIService);
    };
    Gateway.prototype.getApiKey = function (api) {