Commit Graph

221 Commits

Author SHA1 Message Date
Muhammed Mustafa 1e6b3cfa70 refactor(test): remove extra undefined mark (#50428) 2023-05-18 10:40:31 -07:00
Muhammed Mustafa 2fdaeaf550 fix(api): socials endpoint test (#50423)
fix(api): uocials endpoint textt
2023-05-18 14:08:40 +00:00
Niraj Nandish 999d8a6c03 feat(api): create account delete endpoint (#50304)
* feat(api): create account delete endpoint

---------

Co-authored-by: Oliver Eyton-Williams <ojeytonwilliams@gmail.com>
2023-05-18 17:01:21 +03:00
Muhammed Mustafa 885cf86cd6 feat(api): add socials links endpoint (#50332)
* feat(api): add socials links endpoint

* Sort the typo in body call

Co-authored-by: Naomi Carrigan <nhcarrigan@gmail.com>

* Revert "Sort the typo in body call"

This reverts commit 0588d3d70d.

---------

Co-authored-by: Naomi Carrigan <nhcarrigan@gmail.com>
2023-05-18 17:29:43 +04:00
Muhammed Mustafa 9e905b58e1 feat(api): add json protocol to prisma client (#50418) 2023-05-18 17:16:53 +04:00
Oliver Eyton-Williams c3c912db07 feat(api): add csrf protection (#50275)
Co-authored-by: Sboonny <muhammed@freecodecamp.org>
2023-05-18 17:06:40 +05:30
Oliver Eyton-Williams df12c72f46 test: stop mocking FREECODECAMP_NODE_ENV (#50406)
While this lets us write slightly better tests, I don't think it's worth
the extra complexity. For example, it interferes with the creation of
test databases. We could work around this, but I'd rather keep things
simple.
2023-05-17 22:36:22 +04:00
Niraj Nandish 5bc14c21b9 feat: deprecated endpoint (#50403)
* feat: deprecated endpoints
2023-05-17 10:24:57 +03:00
renovate[bot] 0fef335292 fix(deps): update dependency @immobiliarelabs/fastify-sentry to v6 (#50388)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2023-05-16 15:21:28 -07:00
Oliver Eyton-Williams f6df0f3aed docs: improve new api's mongodb setup guide (#50392)
* docs: improve new api's mongodb setup guide

* docs: give example variable

Co-authored-by: Naomi Carrigan <nhcarrigan@gmail.com>

* Update api/README.md

---------

Co-authored-by: Naomi Carrigan <nhcarrigan@gmail.com>
Co-authored-by: Tom <20648924+moT01@users.noreply.github.com>
2023-05-16 20:04:41 +04:00
Naomi Carrigan cdcea13d5f fix(tools): api settings test (#50394) 2023-05-16 07:32:17 +03:00
Shaun Hamilton 651e1905fd chore(api): pull prod db schema (#49735)
* chore(api): pull prod db schema

* manual user model schema

* adjust json types

* temp: fix object type

* adjust schema with Json types

* fix: oliver found my bugs 🐛

Co-authored-by: Oliver Eyton-Williams <ojeytonwilliams@gmail.com>

* ttl to int, remove github from user

Co-authored-by: Oliver Eyton-Williams <ojeytonwilliams@gmail.com>

* fix: remove unused parts of the prisma schema

---------

Co-authored-by: Oliver Eyton-Williams <ojeytonwilliams@gmail.com>
2023-05-16 07:28:39 +03:00
Niraj Nandish 032f9d95ae feat(api): add update privacy terms endpoint (#50300)
* feat: move update privacy terms route

* test: update privacy terms route tests

* feat: add /settings prefix to settings route

* fix: updated routes in tests

* Revert "fix: updated routes in tests"

This reverts commit 4a1305e135.

* Revert "feat: add /settings prefix to settings route"

This reverts commit 2a0d4566fe.
2023-05-15 13:21:32 -07:00
renovate[bot] dd7e7b58f2 fix(deps): update dependency @fastify/middie to 8.3 (#50384)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2023-05-15 13:43:53 +03:00
renovate[bot] decb2e87b6 fix(deps): update dependency fastify to v4.17.0 (#50230)
* fix(deps): update dependency fastify to v4.17.0

* add missing code in error object

---------

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: Sboonny <muhammed@freecodecamp.org>
2023-05-15 11:17:09 +03:00
renovate[bot] e2716c35ea fix(deps): update prisma monorepo to v4.14.0 (#50377)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2023-05-15 11:12:59 +03:00
Muhammed Mustafa c7f5a4cf8b feat(api): add update IsHonest value endpoint (#50281)
Co-authored-by: Oliver Eyton-Williams <ojeytonwilliams@gmail.com>
2023-05-09 09:29:48 -07:00
Muhammed Mustafa afd4402a49 feat(api): add subscribe to quincy email endpoint (#50305) 2023-05-09 09:10:39 +00:00
Muhammed Mustafa d502ff973b feat(api): add keyboard shortcut endpoint (#50286) 2023-05-09 09:55:36 +02:00
Oliver Eyton-Williams c2cb818f87 chore(api): add test utilities (#50289) 2023-05-09 11:15:54 +05:30
Muhammed Mustafa 0d98f28b9e feat(client): delete generic success message in the alert (#49780)
* change the flash message in profileui endpoint

Co-authored-by: Oliver Eyton-Williams <ojeytonwilliams@gmail.com>
2023-05-08 16:58:06 +02:00
renovate[bot] 427414a24b chore(deps): update dependency @fastify/type-provider-typebox to v3.2.0 2023-05-07 08:05:16 +00:00
renovate[bot] dd931ab4a1 fix(deps): update dependency @fastify/middie to 8.2 2023-05-07 05:43:12 +00:00
Oliver Eyton-Williams 5e17868c74 fix(api): allow fastify to set content-type dynamically (#50248)
fix: allow fastify to set content-type dynamically

We can set content-type: application/json for specific routes, but
doing so ends up with confusing, over-engineered code.

Instead we should take care when auditing the endpoints.
2023-05-02 10:15:31 -07:00
Oliver Eyton-Williams 7572f99f74 refactor(api): remove unused endpoints (#50252)
Also adds "dev" as an alias because I keep trying to use it.
2023-05-02 19:54:05 +03:00
Oliver Eyton-Williams 1567894c36 fix(api): use connection string from .env (#50201) 2023-04-27 23:06:43 +01:00
renovate[bot] cf8dc73fae fix(deps): update prisma monorepo to v4.13.0 2023-04-27 05:32:16 +00:00
Oliver Eyton-Williams 46cdfd7802 feat(api): add CORS headers (#50120)
* test: allow mocking of env vars

Since utils/env is a module, we can mock it to control env vars in
tests. However, it's not compatible with building the server in
setupFilesAfterEnv, so, instead, we can use a utility function to keep
things DRY.

* fix: update type of fastifyTestInstance

* chore: add comment about sts preload

* chore: rename header plugin

* test: add get util + provide origin on request

* feat: add cors headers

* chore: add TODO
2023-04-26 09:02:12 +02:00
Sem Bauke a1504eed2a feat: update my theme endpoint (#50183)
Co-authored-by: Shaun Hamilton <ShaunSHamilton@users.noreply.github.com>
Co-authored-by: Oliver Eyton-Williams <ojeytonwilliams@gmail.com>
Co-authored-by: Muhammed Mustafa <muhammed@freecodecamp.org>
Co-authored-by: Tom <moT01@users.noreply.github.com>
2023-04-25 18:01:32 +02:00
Oliver Eyton-Williams 5f12720ad2 fix: use onRequest to add headers (#50125)
* fix: use onrequest to add headers

We want to add them no-matter what, so we should use the earliest hook
available.
2023-04-24 11:08:19 +02:00
renovate[bot] 998069441e chore(deps): update dependency @fastify/type-provider-typebox to v3.1.0 2023-04-23 22:27:54 +00:00
Sem Bauke a980ac03e5 feat: introduce /update-my-profileui route in new API (#49827)
* feat: add response codes

* fix: update TypeBox imports

* refactor: convert inject based tests to supertest

* feat: require authentication to use route

* test: confirm db is updated as expected

* fix: respond appropriately on error

Co-authored-by: Oliver Eyton-Williams <ojeytonwilliams@gmail.com>
Co-authored-by: Niraj Nandish <nirajnandish@icloud.com>
Co-authored-by: Tom <20648924+moT01@users.noreply.github.com>
2023-04-18 15:01:26 +00:00
Muhammed Mustafa daa23a3d83 feat(api): swap to immobiliarelabs sentry plugin (#50041) 2023-04-17 13:10:23 -07:00
Muhammed Mustafa 01b9bd9245 fix(api): fix eslint error (#50080) 2023-04-17 20:21:36 +05:30
Oliver Eyton-Williams 6289efbbad test(api): always start server before testing (#49994) 2023-04-17 17:54:50 +07:00
renovate[bot] 59743ad3fb fix(deps): update dependency @sentry/node to v7.48.0 2023-04-15 22:45:37 +00:00
Oliver Eyton-Williams 71d5a67745 feat(api): add security headers (#49995)
* feat(api): add security headers

Includes the OWASP recommended headers for REST APIs. Taken from
https://cheatsheetseries.owasp.org/cheatsheets/REST_Security_Cheat_Sheet.html#security-headers

* test: check OWASP headers appear on GET / request

* fix: only enable Strict-Transport-Security in prod
2023-04-13 10:16:58 +02:00
renovate[bot] 9d3bf49ed8 fix(deps): update prisma monorepo to v4.12.0 (#50018)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2023-04-10 19:26:23 +05:30
renovate[bot] ad1ba2e982 fix(deps): update dependency @sentry/node to v7.47.0 2023-04-09 13:58:10 +00:00
renovate[bot] 5b2c82d29f chore(deps): update dependency ts-jest to v29.1.0 2023-04-09 03:31:24 +00:00
Muhammed Mustafa 1d8e9fb0b7 feat(api): create sentry plugin (#49731)
* feat(api): add sentry plugin

Apply suggestions from code review

Revert "feat(api): add sentry plugin"

This reverts commit fcde4ee03e9b83e335a6a2bccd490490e9993597.

install sentryNode

WIP: create sentry debug

WIP: find out why use errorhandler isn't typed correct

install sentry

add the deleted sentry code

create sentry plugin

* fix error found through sentry

* Polish sentry plugin

Co-authored-by: Niraj Nandish <nirajnandish@icloud.com>

* duplicate the changes made in the other plugin

* add done to seterrorHandler

* Fix a typo in sentry option

Co-authored-by: Naomi Carrigan <nhcarrigan@gmail.com>

* Stop the dns from running if a DSN wasn't provided

Co-authored-by: Naomi Carrigan <nhcarrigan@gmail.com>

* Polish the function and check the variable value

Co-authored-by: Oliver Eyton-Williams <ojeytonwilliams@gmail.com>

* check the dsn dashboard in the env

* export dsn value if it isn't sentrydashboard

Co-authored-by: Naomi Carrigan <nhcarrigan@gmail.com>

* when the value is undefined init errors

* revert the if statement

* throw an error whenever an environment variable is not right

---------

Co-authored-by: Niraj Nandish <nirajnandish@icloud.com>
Co-authored-by: Naomi Carrigan <nhcarrigan@gmail.com>
Co-authored-by: Oliver Eyton-Williams <ojeytonwilliams@gmail.com>
2023-04-05 08:35:23 -07:00
renovate[bot] b48d12714a fix(deps): update dependency @sinclair/typebox to v0.26.6 (#49855)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: Oliver Eyton-Williams <ojeytonwilliams@gmail.com>
2023-04-03 09:13:36 +00:00
Oliver Eyton-Williams 06d4076a45 feat(api): dev login (#49880)
Co-authored-by: Mrugesh Mohapatra <hi@mrugesh.dev>
2023-03-29 18:08:38 +05:30
Oliver Eyton-Williams a128dd8fcd chore(api): compile TS into /dist (#49812
* chore: compile TS into /dist

Having the output co-located with the source meant that the js would be
imported by default. Given that we don't recompile on source changes,
this means the server got 'stuck' at the point of compilation and would
only register changes on build.

Also, compiling to a dist directory should make it easier to build when
we want to deploy. That said, the motivation is mostly DX.

* fix: put schema.prisma in the default location
2023-03-28 19:42:20 +05:30
renovate[bot] afa246942e fix(deps): update dependency fastify to v4.15.0 2023-03-26 15:59:50 +00:00
renovate[bot] 7f21c5b4ae fix(deps): update dependency nodemon to v2.0.22 2023-03-26 03:01:14 +00:00
Niraj Nandish 1dcba784fd feat(api): API documentation with Swagger UI (#49791) 2023-03-24 10:00:51 +01:00
Oliver Eyton-Williams a0f958189e chore: update api test suite and include it in run test (#49794) 2023-03-23 16:57:11 +00:00
Oliver Eyton-Williams 36b06be8ce chore: extend lint:ts to cover api (#49793)
* fix: include express-session types + suppress err

* chore: add api to lint:ts

* fix: remove unnecessary typeRoots config
2023-03-22 17:59:46 +05:30
renovate[bot] 607111978a fix(deps): update prisma monorepo to v4.11.0 (#49758)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2023-03-19 12:25:26 +05:30