Skip to content

Commit

Permalink
Add webhook endpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
ggodlewski committed Jul 26, 2024
1 parent adbd690 commit a4b0145
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/containers/server/ServerContainer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ import {GoogleTreeProcessor} from '../google_folder/GoogleTreeProcessor.ts';
import {initStaticDistPages} from './static.ts';
import {initUiServer} from './vuejs.ts';
import {initErrorHandler} from './error.ts';
import {WebHookController} from './routes/WebHookController.js';

const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);
Expand Down Expand Up @@ -256,6 +257,9 @@ export class ServerContainer extends Container {
const driveUiController = new DriveUiController('/driveui', this.logger, this.filesService, <GoogleApiContainer>this.authContainer);
app.use('/driveui', await driveUiController.getRouter());

const webHookController = new WebHookController('/webhook', this.logger);
app.use('/webhook', await webHookController.getRouter());

app.use('/api/share-token', authenticate(this.logger), (req, res) => {
if ('POST' !== req.method) {
throw new Error('Incorrect method');
Expand Down
19 changes: 19 additions & 0 deletions src/containers/server/routes/WebHookController.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import {Logger} from 'winston';

import {
Controller, RouteParamBody, RoutePost,
} from './Controller.ts';

export class WebHookController extends Controller {

constructor(subPath: string, private readonly queryLogger: Logger) {
super(subPath);
}

@RoutePost('/')
async postEvent(@RouteParamBody() body: undefined) {
this.queryLogger.info(`WebHookController.postEvent ${JSON.stringify(body)}`);

return {};
}
}

0 comments on commit a4b0145

Please sign in to comment.