Skip to content

Commit efb113c

Browse files
committed
[server] Unimplemented user service on internal port
1 parent 5430d90 commit efb113c

File tree

3 files changed

+70
-5
lines changed

3 files changed

+70
-5
lines changed

components/server/src/api/server.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,16 @@
44
* See License.AGPL.txt in the project root for license information.
55
*/
66
import { ConnectRouter } from "@bufbuild/connect";
7-
import { WorkspacesService as WorkspacesServiceDefinition } from "@gitpod/public-api/lib/gitpod/experimental/v1/workspaces_connectweb";
7+
import { UserService as UserServiceDefinition } from "@gitpod/public-api/lib/gitpod/experimental/v1/workspaces_connectweb";
88
import { inject, injectable } from "inversify";
9-
import { WorkspacesService } from "./workspaces";
9+
import { UserService } from "./user";
1010

1111
@injectable()
1212
export class Router {
13-
@inject(WorkspacesService)
14-
protected workspaces: WorkspacesService;
13+
@inject(UserService)
14+
protected user: UserService;
1515

1616
public routes(router: ConnectRouter) {
17-
router.service(WorkspacesServiceDefinition, this.workspaces);
17+
router.service(UserServiceDefinition, this.user);
1818
}
1919
}

components/server/src/api/user.ts

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
/**
2+
* Copyright (c) 2023 Gitpod GmbH. All rights reserved.
3+
* Licensed under the GNU Affero General Public License (AGPL).
4+
* See License.AGPL.txt in the project root for license information.
5+
*/
6+
7+
import { ServiceImpl, ConnectError, Code } from "@bufbuild/connect";
8+
import { UserService as UserServiceInterface } from "@gitpod/public-api/lib/gitpod/experimental/v1/user_connectweb";
9+
import {
10+
GetAuthenticatedUserRequest,
11+
ListSSHKeysRequest,
12+
CreateSSHKeyRequest,
13+
GetSSHKeyRequest,
14+
DeleteSSHKeyRequest,
15+
GetGitTokenRequest,
16+
BlockUserRequest,
17+
GetAuthenticatedUserResponse,
18+
ListSSHKeysResponse,
19+
CreateSSHKeyResponse,
20+
GetSSHKeyResponse,
21+
DeleteSSHKeyResponse,
22+
GetGitTokenResponse,
23+
BlockUserResponse,
24+
} from "@gitpod/public-api/lib/gitpod/experimental/v1/user_pb";
25+
26+
export class UserService implements ServiceImpl<typeof UserServiceInterface> {
27+
getAuthenticatedUser(req: GetAuthenticatedUserRequest): Promise<GetAuthenticatedUserResponse> {
28+
throw new ConnectError("unimplemented", Code.Unimplemented);
29+
}
30+
31+
listSSHKeysGetAuthenticatedUserRequest(req: ListSSHKeysRequest): Promise<ListSSHKeysResponse> {
32+
throw new ConnectError("unimplemented", Code.Unimplemented);
33+
}
34+
35+
createSSHKeyGetAuthenticatedUserRequest(req: CreateSSHKeyRequest): Promise<CreateSSHKeyResponse> {
36+
throw new ConnectError("unimplemented", Code.Unimplemented);
37+
}
38+
39+
getSSHKeyGetAuthenticatedUserRequest(req: GetSSHKeyRequest): Promise<GetSSHKeyResponse> {
40+
throw new ConnectError("unimplemented", Code.Unimplemented);
41+
}
42+
43+
deleteSSHKeyGetAuthenticatedUserRequest(req: DeleteSSHKeyRequest): Promise<DeleteSSHKeyResponse> {
44+
throw new ConnectError("unimplemented", Code.Unimplemented);
45+
}
46+
47+
getGitTokenGetAuthenticatedUserRequest(req: GetGitTokenRequest): Promise<GetGitTokenResponse> {
48+
throw new ConnectError("unimplemented", Code.Unimplemented);
49+
}
50+
51+
blockUserGetAuthenticatedUserRequest(req: BlockUserRequest): Promise<BlockUserResponse> {
52+
throw new ConnectError("unimplemented", Code.Unimplemented);
53+
}
54+
}

components/server/src/server.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,7 @@ export class Server<C extends GitpodClient, S extends GitpodServer> {
9696
protected iamSessionAppServer?: http.Server;
9797

9898
@inject(Router) protected readonly apiRouter: Router;
99+
protected apiServer?: http.Server;
99100

100101
protected readonly eventEmitter = new EventEmitter();
101102
protected app?: express.Application;
@@ -311,6 +312,7 @@ export class Server<C extends GitpodClient, S extends GitpodServer> {
311312
.catch((err) => log.error("webhook-event-gc: error during startup", err));
312313

313314
this.app = app;
315+
314316
log.info("server initialized.");
315317
}
316318

@@ -392,6 +394,14 @@ export class Server<C extends GitpodClient, S extends GitpodServer> {
392394
});
393395
}
394396

397+
{
398+
const apiApp = express();
399+
apiApp.use(expressConnectMiddleware(this.apiRouter.routes));
400+
this.apiServer = apiApp.listen(9877, () => {
401+
log.info(`Connect API server listening on: ${<AddressInfo>this.apiServer!.address()}`);
402+
});
403+
}
404+
395405
this.debugApp.start();
396406
}
397407

@@ -401,6 +411,7 @@ export class Server<C extends GitpodClient, S extends GitpodServer> {
401411
await this.stopServer(this.monitoringHttpServer);
402412
await this.stopServer(this.installationAdminHttpServer);
403413
await this.stopServer(this.httpServer);
414+
await this.stopServer(this.apiServer);
404415
this.disposables.dispose();
405416
log.info("server stopped.");
406417
}

0 commit comments

Comments
 (0)