mirror of
https://github.com/ZeppelinBot/Zeppelin.git
synced 2025-05-10 12:25:02 +00:00
Add support for API permission expiry
This commit is contained in:
parent
2b8f75b91b
commit
947a49761e
5 changed files with 42 additions and 0 deletions
|
@ -6,6 +6,7 @@ import { initAuth } from "./auth";
|
|||
import { initDocs } from "./docs";
|
||||
import { initGuildsAPI } from "./guilds";
|
||||
import { clientError, error, notFound } from "./responses";
|
||||
import { startBackgroundTasks } from "./tasks";
|
||||
|
||||
const app = express();
|
||||
|
||||
|
@ -47,3 +48,5 @@ app.use((req, res, next) => {
|
|||
|
||||
const port = (process.env.PORT && parseInt(process.env.PORT, 10)) || 3000;
|
||||
app.listen(port, "0.0.0.0", () => console.log(`API server listening on port ${port}`)); // tslint:disable-line
|
||||
|
||||
startBackgroundTasks();
|
||||
|
|
10
backend/src/api/tasks.ts
Normal file
10
backend/src/api/tasks.ts
Normal file
|
@ -0,0 +1,10 @@
|
|||
import { ApiPermissionAssignments } from "../data/ApiPermissionAssignments";
|
||||
import { MINUTES } from "../utils";
|
||||
|
||||
export function startBackgroundTasks() {
|
||||
// Clear expired API permissions every minute
|
||||
const apiPermissions = new ApiPermissionAssignments();
|
||||
setInterval(() => {
|
||||
apiPermissions.clearExpiredPermissions();
|
||||
}, 1 * MINUTES);
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue