Skip to content

Commit

Permalink
allow access the server router
Browse files Browse the repository at this point in the history
  • Loading branch information
thiagobustamante committed Feb 11, 2020
1 parent 6d43e26 commit e3b45df
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 12 deletions.
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "typescript-rest",
"version": "2.2.5",
"version": "2.2.6",
"description": "A Library to create RESTFul APIs with Typescript",
"author": "Thiago da Rosa de Bustamante <[email protected]>",
"keywords": [
Expand Down
34 changes: 24 additions & 10 deletions src/server/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,6 @@ const serverDebugger = debug('typescript-rest:server:build');
* The Http server main class.
*/
export class Server {

/**
* Makes the server immutable. Any configuration change request to the Server
* is ignored when immutable is true
* @param value true to make immutable
*/
public static immutable(value: boolean) {
Server.locked = value;
}

/**
* Create the routes for all classes decorated with our decorators
*/
Expand Down Expand Up @@ -79,6 +69,30 @@ export class Server {
}
}

/**
* Makes the server immutable. Any configuration change request to the Server
* is ignored when immutable is true
* @param value true to make immutable
*/
public static immutable(value: boolean) {
Server.locked = value;
}

/**
* Return true if the server is immutable. Any configuration change request to the Server
* is ignored when immutable is true
*/
public static isImmutable() {
return Server.locked;
}

/**
* Retrieve the express router that serves the rest endpoints
*/
public static server() {
return ServerContainer.get().router;
}

/**
* Return all paths accepted by the Server
*/
Expand Down
1 change: 1 addition & 0 deletions test/unit/server.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ describe('Server', () => {
Server.removeParameterConverter(null);
Server.ignoreNextMiddlewares(false);
expect(serverContainerStub.get).to.not.have.been.called;
expect(Server.isImmutable()).to.be.true;
});

});

0 comments on commit e3b45df

Please sign in to comment.