-
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.
- Loading branch information
Showing
67 changed files
with
3,545 additions
and
3,555 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
{ | ||
"presets": ["next/babel"], | ||
"plugins": [["@babel/plugin-proposal-decorators", { "legacy": true }]] | ||
"presets": ["next/babel"], | ||
"plugins": [["@babel/plugin-proposal-decorators", { "legacy": true }]] | ||
} |
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,23 +1,23 @@ | ||
module.exports = { | ||
extends: ["react-app", "plugin:jsx-a11y/recommended"], | ||
plugins: ["jsx-a11y"], | ||
rules: { | ||
"import/no-anonymous-default-export": "error", | ||
extends: ["react-app", "plugin:jsx-a11y/recommended"], | ||
plugins: ["jsx-a11y"], | ||
rules: { | ||
"import/no-anonymous-default-export": "error", | ||
|
||
/** | ||
* React does not have to be in scope with Next.js | ||
*/ | ||
"react/react-in-jsx-scope": "off", | ||
/** | ||
* React does not have to be in scope with Next.js | ||
*/ | ||
"react/react-in-jsx-scope": "off", | ||
|
||
/** | ||
* `next/link` puts the href on the `<Link>` tag instead of the `<a>` tag. | ||
*/ | ||
"jsx-a11y/anchor-is-valid": "off", | ||
/** | ||
* `next/link` puts the href on the `<Link>` tag instead of the `<a>` tag. | ||
*/ | ||
"jsx-a11y/anchor-is-valid": "off", | ||
|
||
/** | ||
* This rule is deprecated and does not apply to modern browsers, which | ||
* we are targeting here. | ||
*/ | ||
"jsx-a11y/no-onchange": "off", | ||
}, | ||
/** | ||
* This rule is deprecated and does not apply to modern browsers, which | ||
* we are targeting here. | ||
*/ | ||
"jsx-a11y/no-onchange": "off", | ||
}, | ||
}; |
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,6 +1,6 @@ | ||
module.exports = { | ||
hooks: { | ||
// Run lint-staged before committing, config is defined in lintstagedrc. | ||
"pre-commit": "lint-staged", | ||
}, | ||
hooks: { | ||
// Run lint-staged before committing, config is defined in lintstagedrc. | ||
"pre-commit": "lint-staged", | ||
}, | ||
}; |
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,3 @@ | ||
{ | ||
"overrides": [ | ||
{ | ||
"files": ["*.md", "*.mdx"], | ||
"options": { | ||
"tabWidth": 2, | ||
"useTabs": false | ||
} | ||
} | ||
], | ||
"proseWrap": "always", | ||
"useTabs": true | ||
"proseWrap": "always" | ||
} |
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
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,42 +1,42 @@ | ||
import { | ||
BadRequestException, | ||
Bind, | ||
Controller, | ||
Delete, | ||
Dependencies, | ||
Param, | ||
BadRequestException, | ||
Bind, | ||
Controller, | ||
Delete, | ||
Dependencies, | ||
Param, | ||
} from "@nestjs/common"; | ||
import { FirebaseService } from "api/firebase/firebase.service"; | ||
import { FormsService } from "./forms.service"; | ||
|
||
@Controller("forms") | ||
@Dependencies(FormsService, FirebaseService) | ||
export class FormsController { | ||
constructor( | ||
private readonly formsService: FormsService, | ||
private readonly firebaseService: FirebaseService | ||
) {} | ||
constructor( | ||
private readonly formsService: FormsService, | ||
private readonly firebaseService: FirebaseService | ||
) {} | ||
|
||
@Delete(":id") | ||
@Bind(Param("id")) | ||
async deleteForm(formId: string) { | ||
if (!formId) { | ||
throw new BadRequestException("You have to provide a non-empty form id."); | ||
} | ||
@Delete(":id") | ||
@Bind(Param("id")) | ||
async deleteForm(formId: string) { | ||
if (!formId) { | ||
throw new BadRequestException("You have to provide a non-empty form id."); | ||
} | ||
|
||
const doc = await this.firebaseService.firestore | ||
.collection("forms") | ||
.doc(formId) | ||
.get(); | ||
const doc = await this.firebaseService.firestore | ||
.collection("forms") | ||
.doc(formId) | ||
.get(); | ||
|
||
if (!doc.exists) { | ||
throw new BadRequestException( | ||
`A form with the id \`${formId}\` does not exist.` | ||
); | ||
} | ||
if (!doc.exists) { | ||
throw new BadRequestException( | ||
`A form with the id \`${formId}\` does not exist.` | ||
); | ||
} | ||
|
||
await this.formsService.deleteFormWithSubmissions(formId); | ||
await this.formsService.deleteFormWithSubmissions(formId); | ||
|
||
return "Successfully deleted form."; | ||
} | ||
return "Successfully deleted form."; | ||
} | ||
} |
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
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,35 +1,35 @@ | ||
import { | ||
BadRequestException, | ||
Bind, | ||
Body, | ||
Controller, | ||
Dependencies, | ||
Param, | ||
Post, | ||
BadRequestException, | ||
Bind, | ||
Body, | ||
Controller, | ||
Dependencies, | ||
Param, | ||
Post, | ||
} from "@nestjs/common"; | ||
import { JsonValue } from "type-fest"; | ||
import { SubmissionService } from "./submission.service"; | ||
|
||
@Controller("forms/:formId/submissions") | ||
@Dependencies(SubmissionService) | ||
export class SubmissionController { | ||
constructor(private submissionService: SubmissionService) {} | ||
constructor(private submissionService: SubmissionService) {} | ||
|
||
@Post() | ||
@Bind(Param("formId"), Body()) | ||
async submit(formId: string | undefined, body: JsonValue) { | ||
if (!formId) { | ||
throw new BadRequestException("No form id specified specified."); | ||
} | ||
@Post() | ||
@Bind(Param("formId"), Body()) | ||
async submit(formId: string | undefined, body: JsonValue) { | ||
if (!formId) { | ||
throw new BadRequestException("No form id specified specified."); | ||
} | ||
|
||
if (typeof body !== "object" || body === null || Array.isArray(body)) { | ||
throw new BadRequestException( | ||
"The request body has to contain a JSON object." | ||
); | ||
} | ||
if (typeof body !== "object" || body === null || Array.isArray(body)) { | ||
throw new BadRequestException( | ||
"The request body has to contain a JSON object." | ||
); | ||
} | ||
|
||
await this.submissionService.create(formId, body); | ||
await this.submissionService.create(formId, body); | ||
|
||
return "Successfully submitted form."; | ||
} | ||
return "Successfully submitted form."; | ||
} | ||
} |
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
Oops, something went wrong.