Git Product home page Git Product logo

Comments (5)

thiagobustamante avatar thiagobustamante commented on July 29, 2024

Yes.
You can try:

import * as express from "express";
import {Server} from "typescript-rest";
import {ServiceOne} from "./service-one";
import {ServiceTwo} from "./service-two";
import {ServiceThree} from "./service-three";

let app: express.Application = express();
Server.buildServices(app, ServiceOne, ServiceTwo, ServiceThree);

And write your @ ROUTES in each of those files, like:

import {Server, Path, GET, PathParam} from "typescript-rest";

@Path("/hello")
export class ServiceOne {
}

from typescript-rest.

o-matsuo avatar o-matsuo commented on July 29, 2024

oops! i understand. thank you very match.

from typescript-rest.

thiagobustamante avatar thiagobustamante commented on July 29, 2024

If you have many services distributed in many modules, you can also join all of them and re-export, to facilitate the maintenance of the code:

import {StatsRest} from "./stats";
import {MiddlewareRest} from "./middleware";
import {APIRest} from "./api";
import {HealthCheck} from "./health-check";
import {UsersRest} from "./users";
import {GatewayRest} from "./gateway";

export default [StatsRest, MiddlewareRest, APIRest, HealthCheck, UsersRest, GatewayRest];

and then, on your main file:

import adminApi from "./admin-apis";

const app = express();
Server.buildServices(app, ...adminApi);

Or you can also call Server.buildServicesmultiple times, with different classes to register.

import adminApi from "./admin-apis";
import {ServiceOne} from "./service-one";

const app = express();
Server.buildServices(app, ...adminApi);
Server.buildServices(app, ServiceOne);

from typescript-rest.

mrslnv avatar mrslnv commented on July 29, 2024

Nice! It works.

from typescript-rest.

thiagobustamante avatar thiagobustamante commented on July 29, 2024

I created a new issue (#24), proposing a better approach to this.

from typescript-rest.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.