mirror of
https://github.com/ZeppelinBot/Zeppelin.git
synced 2025-05-10 12:25:02 +00:00
Turn on strict TS compilation. Fix up and tweak types accordingly.
This commit is contained in:
parent
690955a399
commit
629002b8d9
172 changed files with 720 additions and 534 deletions
|
@ -147,7 +147,7 @@ export function initAuth(app: express.Express) {
|
|||
res.json({ valid: true });
|
||||
});
|
||||
app.post("/auth/logout", ...apiTokenAuthHandlers(), async (req: Request, res: Response) => {
|
||||
await apiLogins.expireApiKey(req.user.apiKey);
|
||||
await apiLogins.expireApiKey(req.user!.apiKey);
|
||||
return ok(res);
|
||||
});
|
||||
}
|
||||
|
|
|
@ -19,12 +19,12 @@ export function initGuildsAPI(app: express.Express) {
|
|||
guildRouter.use(...apiTokenAuthHandlers());
|
||||
|
||||
guildRouter.get("/available", async (req: Request, res: Response) => {
|
||||
const guilds = await allowedGuilds.getForApiUser(req.user.userId);
|
||||
const guilds = await allowedGuilds.getForApiUser(req.user!.userId);
|
||||
res.json(guilds);
|
||||
});
|
||||
|
||||
guildRouter.get("/:guildId", async (req: Request, res: Response) => {
|
||||
if (!(await hasGuildPermission(req.user.userId, req.params.guildId, ApiPermissions.ViewGuild))) {
|
||||
if (!(await hasGuildPermission(req.user!.userId, req.params.guildId, ApiPermissions.ViewGuild))) {
|
||||
return unauthorized(res);
|
||||
}
|
||||
|
||||
|
@ -34,7 +34,7 @@ export function initGuildsAPI(app: express.Express) {
|
|||
|
||||
guildRouter.post("/:guildId/check-permission", async (req: Request, res: Response) => {
|
||||
const permission = req.body.permission;
|
||||
const hasPermission = await hasGuildPermission(req.user.userId, req.params.guildId, permission);
|
||||
const hasPermission = await hasGuildPermission(req.user!.userId, req.params.guildId, permission);
|
||||
res.json({ result: hasPermission });
|
||||
});
|
||||
|
||||
|
@ -54,7 +54,7 @@ export function initGuildsAPI(app: express.Express) {
|
|||
config = config.trim() + "\n"; // Normalize start/end whitespace in the config
|
||||
|
||||
const currentConfig = await configs.getActiveByKey(`guild-${req.params.guildId}`);
|
||||
if (config === currentConfig.config) {
|
||||
if (currentConfig && config === currentConfig.config) {
|
||||
return ok(res);
|
||||
}
|
||||
|
||||
|
@ -81,7 +81,7 @@ export function initGuildsAPI(app: express.Express) {
|
|||
return res.status(422).json({ errors: [error] });
|
||||
}
|
||||
|
||||
await configs.saveNewRevision(`guild-${req.params.guildId}`, config, req.user.userId);
|
||||
await configs.saveNewRevision(`guild-${req.params.guildId}`, config, req.user!.userId);
|
||||
|
||||
ok(res);
|
||||
});
|
||||
|
|
|
@ -24,7 +24,7 @@ export const hasGuildPermission = async (userId: string, guildId: string, permis
|
|||
*/
|
||||
export function requireGuildPermission(permission: ApiPermissions) {
|
||||
return async (req: Request, res: Response, next) => {
|
||||
if (!(await hasGuildPermission(req.user.userId, req.params.guildId, permission))) {
|
||||
if (!(await hasGuildPermission(req.user!.userId, req.params.guildId, permission))) {
|
||||
return unauthorized(res);
|
||||
}
|
||||
|
||||
|
|
|
@ -7,7 +7,7 @@ export function initStaff(app: express.Express) {
|
|||
staffRouter.use(...apiTokenAuthHandlers());
|
||||
|
||||
staffRouter.get("/status", (req: Request, res: Response) => {
|
||||
const userIsStaff = isStaff(req.user.userId);
|
||||
const userIsStaff = isStaff(req.user!.userId);
|
||||
res.json({ isStaff: userIsStaff });
|
||||
});
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue