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
51 changes: 51 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
"author": "",
"license": "ISC",
"dependencies": {
"@asteasolutions/zod-to-openapi": "^7.0.0",
"@prisma/client": "^5.12.1",
"@prisma/extension-accelerate": "^1.0.0",
"@types/jsonwebtoken": "^9.0.5",
Expand All @@ -27,6 +28,7 @@
"jose": "^5.1.1",
"resend": "^2.0.0",
"simple-statistics": "^7.8.3",
"swagger-ui-express": "^5.0.0",
"zod": "^3.22.4",
"zod-validation-error": "^2.1.0"
},
Expand Down
64 changes: 62 additions & 2 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,23 @@ import { scouterScoutReports } from "./handler/analysis/scoutingLead/scouterScou
import { pitDisplay } from "./handler/manager/pitDisplay";
import { addTournamentMatchesOneTime } from "./handler/manager/addTournamentMatchesOneTime";
import { getCSV } from "./handler/manager/getCSV";
import swaggerUi from 'swagger-ui-express';
import { generateOpenAPI } from "./lib/swagger";
import swaggerValidationMiddleware from "./lib/middleware/swaggerMiddleware";
import { z } from "zod";

declare global {
namespace Express {
interface Request {
swaggerDoc: any
openapi: any
clientInfo: any
auth?: {
},
apiUser: any
}
}
}

const resendEmailLimiter = rateLimit({
windowMs: 2 * 60 * 1000,
Expand All @@ -105,6 +122,47 @@ const port = process.env.PORT || 3000;

app.use(bodyParser.json());

app.use(
'/hello',
swaggerValidationMiddleware({
path: '/hello',
description: 'Test',
summary: 'Test',
tags: ['Test'],
method: 'get',
validateInput: true,
validateOutput: true,
response200: {
description: 'Test',
schema: z.object({
message: z.string()
})
},
})
.handle(async (req, res) => {
return res.send({ message: 'Hello, world!' })
})
)

app.use('/swagger.json', (req, res) => {
// const settings = getAuthObj(req.query.url)

return res.json(generateOpenAPI({}))
})


app.use('/hello', (req, res) => {
return res.send('Hello, world!')
})
app.use('/swagger', swaggerUi.serve,
(req, res, next) => {

const options = {}

req.swaggerDoc = generateOpenAPI({})
swaggerUi.setup(req.swaggerDoc, options)(req, res, next)
})


//general endpoints
app.get('/v1/manager/tournament/:tournament/teams', requireAuth, getTeamsInTournament)
Expand Down Expand Up @@ -242,6 +300,8 @@ app.get('/v1/analysis/csvplain', requireAuth, getCSV) // tested



getTBAData();
// getTBAData();

app.listen(port);
app.listen(port, () => {
console.log(`Server is running on port ${port}`);
})
Loading