generated from cds-snc/project-template
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: follow all Biome established rules
- Loading branch information
Showing
18 changed files
with
71 additions
and
84 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,6 @@ | ||
async function main(formId: string, submissionId: string) { | ||
export function getSubmission(formId: string, submissionId: string) { | ||
return { | ||
formId, | ||
submissionId, | ||
}; | ||
} | ||
|
||
export default main; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,9 @@ | ||
import { NextFunction, Request, Response } from "express"; | ||
import type { NextFunction, Request, Response } from "express"; | ||
|
||
async function main(request: Request, response: Response, next: NextFunction) { | ||
export function authenticationMiddleware( | ||
_request: Request, | ||
_response: Response, | ||
next: NextFunction, | ||
) { | ||
next(); | ||
} | ||
|
||
export default main; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,11 @@ | ||
import { Request, Response, NextFunction } from "express"; | ||
import type { Request, Response, NextFunction } from "express"; | ||
|
||
function main(error: Error, _request: Request, response: Response, _next: NextFunction) { | ||
export function globalErrorHandlerMiddleware( | ||
error: Error, | ||
_request: Request, | ||
response: Response, | ||
_next: NextFunction, | ||
) { | ||
console.error(JSON.stringify(error, Object.getOwnPropertyNames(error))); | ||
response.sendStatus(500); | ||
} | ||
|
||
export default main; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,9 @@ | ||
import { NextFunction, Request, Response } from "express"; | ||
import type { NextFunction, Request, Response } from "express"; | ||
|
||
async function main(request: Request, response: Response, next: NextFunction) { | ||
export function rateLimiterMiddleware( | ||
_request: Request, | ||
_response: Response, | ||
next: NextFunction, | ||
) { | ||
next(); | ||
} | ||
|
||
export default main; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,5 @@ | ||
import { Request, Response } from "express"; | ||
import type { Request, Response } from "express"; | ||
|
||
function main(_request: Request, response: Response) { | ||
export function routeNotFoundMiddleware(_request: Request, response: Response) { | ||
response.sendStatus(404); | ||
} | ||
|
||
export default main; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,11 @@ | ||
import { Router } from "express"; | ||
import submissionRouter from "./submission/router"; | ||
import authenticationMiddleware from "../../middleware/authentication/middleware"; | ||
import rateLimiterMiddleware from "../../middleware/rateLimiter/middleware"; | ||
import { submissionRouter } from "./submission/router"; | ||
import { authenticationMiddleware } from "../../middleware/authentication/middleware"; | ||
import { rateLimiterMiddleware } from "../../middleware/rateLimiter/middleware"; | ||
|
||
const router = Router(); | ||
export const formsRouter = Router(); | ||
|
||
router | ||
formsRouter | ||
.use(authenticationMiddleware) | ||
.use(rateLimiterMiddleware) | ||
.use("/:formId/submission", submissionRouter); | ||
|
||
export default router; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,11 @@ | ||
import { Request, Response, Router } from "express"; | ||
import { type Request, type Response, Router } from "express"; | ||
|
||
const router = Router({ | ||
export const downloadedRouter = Router({ | ||
mergeParams: true, | ||
}); | ||
|
||
router.get("/", async (request: Request, response: Response) => { | ||
downloadedRouter.get("/", (request: Request, response: Response) => { | ||
response.json({ | ||
formId: request.params.formId, | ||
}); | ||
}); | ||
|
||
export default router; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,11 @@ | ||
import { Request, Response, Router } from "express"; | ||
import { type Request, type Response, Router } from "express"; | ||
|
||
const router = Router({ | ||
export const newRouter = Router({ | ||
mergeParams: true, | ||
}); | ||
|
||
router.get("/", async (request: Request, response: Response) => { | ||
newRouter.get("/", (request: Request, response: Response) => { | ||
response.json({ | ||
formId: request.params.formId, | ||
}); | ||
}); | ||
|
||
export default router; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,13 @@ | ||
import { Router } from "express"; | ||
import newRouter from "./new/router"; | ||
import downloadedRouter from "./downloaded/router"; | ||
import submissionIdRouter from "./submissionId/router"; | ||
import { newRouter } from "./new/router"; | ||
import { downloadedRouter } from "./downloaded/router"; | ||
import { submissionIdRouter } from "./submissionId/router"; | ||
|
||
const router = Router({ | ||
export const submissionRouter = Router({ | ||
mergeParams: true, | ||
}); | ||
|
||
router | ||
submissionRouter | ||
.use("/new", newRouter) | ||
.use("/downloaded", downloadedRouter) | ||
.use("/:submissionId", submissionIdRouter); | ||
|
||
export default router; |
8 changes: 3 additions & 5 deletions
8
src/routes/forms/submission/submissionId/confirm/confirmationCode/router.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,13 @@ | ||
import { Request, Response, Router } from "express"; | ||
import { type Request, type Response, Router } from "express"; | ||
|
||
const router = Router({ | ||
export const confirmationCodeRouter = Router({ | ||
mergeParams: true, | ||
}); | ||
|
||
router.put("/", async (request: Request, response: Response) => { | ||
confirmationCodeRouter.put("/", (request: Request, response: Response) => { | ||
response.json({ | ||
formId: request.params.formId, | ||
submissionId: request.params.submissionId, | ||
confirmationCode: request.params.confirmationCode, | ||
}); | ||
}); | ||
|
||
export default router; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,8 @@ | ||
import { Router } from "express"; | ||
import confirmationCodeRouter from "./confirmationCode/router"; | ||
import { confirmationCodeRouter } from "./confirmationCode/router"; | ||
|
||
const router = Router({ | ||
export const confirmRouter = Router({ | ||
mergeParams: true, | ||
}); | ||
|
||
router.use("/:confirmationCode", confirmationCodeRouter); | ||
|
||
export default router; | ||
confirmRouter.use("/:confirmationCode", confirmationCodeRouter); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,16 @@ | ||
import { Request, Response, Router } from "express"; | ||
import confirmRouter from "./confirm/router"; | ||
import getSubmission from "../../../../lib/vault/getSubmission"; | ||
import { type Request, type Response, Router } from "express"; | ||
import { confirmRouter } from "./confirm/router"; | ||
import { getSubmission } from "../../../../lib/vault/getSubmission"; | ||
|
||
const router = Router({ | ||
export const submissionIdRouter = Router({ | ||
mergeParams: true, | ||
}); | ||
|
||
router.get("/", async (request: Request, response: Response) => { | ||
submissionIdRouter.get("/", (request: Request, response: Response) => { | ||
const formId = request.params.formId; | ||
const submissionId = request.params.submissionId; | ||
const submission = await getSubmission(formId, submissionId); | ||
const submission = getSubmission(formId, submissionId); | ||
response.json(submission); | ||
}); | ||
|
||
router.use("/confirm", confirmRouter); | ||
|
||
export default router; | ||
submissionIdRouter.use("/confirm", confirmRouter); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,9 @@ | ||
import { Response, Router } from "express"; | ||
import { type Response, Router } from "express"; | ||
|
||
const router = Router(); | ||
export const statusRouter = Router(); | ||
|
||
router.get("/", (_, response: Response) => { | ||
statusRouter.get("/", (_, response: Response) => { | ||
response.json({ | ||
status: "running", | ||
}); | ||
}); | ||
|
||
export default router; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,11 @@ | ||
import express, { Express } from "express"; | ||
import express, { type Express } from "express"; | ||
import { SERVER_PORT } from "./config"; | ||
import router from "./router"; | ||
import { router } from "./router"; | ||
|
||
const server: Express = express(); | ||
|
||
server.use("/", router); | ||
|
||
server.listen(SERVER_PORT, () => { | ||
console.log(`>>> API server listening on port ${SERVER_PORT} <<<`); | ||
console.info(`>>> API server listening on port ${SERVER_PORT} <<<`); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters