Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 3 additions & 4 deletions backend/backend.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@
import bcrypt from 'bcryptjs';
import * as jwt from 'jsonwebtoken';
import * as dotenv from 'dotenv';
// @ts-expect-error Types exist???
import { Send } from "express-serve-static-core";
// TypedResponse interface with proper Express typing
import cors from 'cors';
import rateLimit from 'express-rate-limit';
import { generateSlug } from "random-word-slugs";
Expand Down Expand Up @@ -70,7 +69,7 @@
}

export interface TypedResponse<ResBody> extends Express.Response {
json: Send<ResBody, this>;
json: (body: ResBody) => this;
}

// *************************************************
Expand Down Expand Up @@ -157,7 +156,7 @@
});

// Login Endpoint
app.post('/login', async (req: TypedRequestBody<{ username: string; password: string }>, res: TypedResponse<{ token: string }>) => {
app.post('/login', async (req: TypedRequestBody<{ username: string; password: string }>, res: TypedResponse<{ token: string } | { message: string } | { message: string; error: any }>) => {

Check warning on line 159 in backend/backend.ts

View workflow job for this annotation

GitHub Actions / Build Backend

Unexpected any. Specify a different type
try {
const { username, password } = req.body;
const user = await User.findOne({ username });
Expand Down Expand Up @@ -195,7 +194,7 @@
});

// Save Data Endpoint
app.post('/save', authenticate, async (req: AuthenticatedRequest & TypedRequestBody<{ data: any }>, res: Express.Response) => {

Check warning on line 197 in backend/backend.ts

View workflow job for this annotation

GitHub Actions / Build Backend

Unexpected any. Specify a different type
try {
const { username } = req.user as jwt.JwtPayload & { username: string };
const factoryData: Factory[] = req.body;
Expand Down Expand Up @@ -245,7 +244,7 @@
});

// Load Data Endpoint
app.get('/load', authenticate, async (req: AuthenticatedRequest & TypedRequestBody<{ data: any }>, res: Express.Response) => {

Check warning on line 247 in backend/backend.ts

View workflow job for this annotation

GitHub Actions / Build Backend

Unexpected any. Specify a different type
try {
const { username } = req.user as jwt.JwtPayload & { username: string };

Expand All @@ -260,7 +259,7 @@
});

// Share link create endpoint
app.post('/share', optionalAuthenticate, shareRateLimit, async (req: AuthenticatedRequest & TypedRequestBody<{ data: any }>, res: Express.Response) => {

Check warning on line 262 in backend/backend.ts

View workflow job for this annotation

GitHub Actions / Build Backend

Unexpected any. Specify a different type
try {
const { username } = req.user as jwt.JwtPayload & { username: string };
const factoryData = req.body;
Expand Down
Loading
Loading