card-drop/src/webhooks.ts
Ethan Lane 5dd50a3f3b
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
Add logger to project (#183)
# Description

Please include a summary of the change and which issue is fixed. Please also include relevant motivation and context. List any dependencies that are required for this change.

- Add the winston package to handle logging
- Add logging to the project's logic

#146

## Type of change

Please delete options that are not relevant.

- [x] New feature (non-breaking change which adds functionality)

# How Has This Been Tested?

Please describe the tests that you ran to verify the changes. Provide instructions so we can reproduce. Please also list any relevant details to your test configuration.

# Checklist

- [ ] My code follows the style guidelines of this project
- [ ] I have performed a self-review of my own code
- [ ] I have commented my code, particularly in hard-to-understand areas
- [ ] I have made corresponding changes to the documentation
- [ ] My changes generate no new warnings
- [ ] I have added tests that provde my fix is effective or that my feature works
- [ ] New and existing unit tests pass locally with my changes
- [ ] Any dependent changes have been merged and published in downstream modules

Reviewed-on: https://gitea.vylpes.xyz/External/card-drop/pulls/183
Reviewed-by: VylpesTester <tester@vylpes.com>
Co-authored-by: Ethan Lane <ethan@vylpes.com>
Co-committed-by: Ethan Lane <ethan@vylpes.com>
2024-03-15 17:33:12 +00:00

31 lines
No EOL
751 B
TypeScript

import bodyParser from "body-parser";
import express, { Application } from "express";
import ReloadDB from "./hooks/ReloadDB";
import AppLogger from "./client/appLogger";
export default class Webhooks {
private app: Application;
private port = process.env.EXPRESS_PORT!;
public start() {
this.setupApp();
this.setupRoutes();
this.setupListen();
}
private setupApp() {
this.app = express();
this.app.use(bodyParser.json());
}
private setupRoutes() {
this.app.post("/api/reload-db", ReloadDB);
}
private setupListen() {
this.app.listen(this.port, () => {
AppLogger.LogInfo("Webhooks", `API listening on port ${this.port}`);
});
}
}