Skip to content

Commit

Permalink
Nyan (#68)
Browse files Browse the repository at this point in the history
* fix: nyan

* fix: nyan

---------

Co-authored-by: Esurio <[email protected]>
  • Loading branch information
1673beta and Esurio authored Jul 5, 2024
1 parent 3b35470 commit 9191000
Show file tree
Hide file tree
Showing 4 changed files with 66 additions and 42 deletions.
1 change: 1 addition & 0 deletions packages/backend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@
"@fastify/express": "3.0.0",
"@fastify/http-proxy": "9.5.0",
"@fastify/multipart": "8.2.0",
"@fastify/rate-limit": "^9.1.0",
"@fastify/static": "7.0.3",
"@fastify/view": "9.1.0",
"@google-cloud/logging": "^10.5.0",
Expand Down
2 changes: 1 addition & 1 deletion packages/backend/src/misc/sql-like-escape.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@
*/

export function sqlLikeEscape(s: string) {
return s.replace(/([%_])/g, '\\$1');
return s.replace(/([%_\\])/g, '\\$1');
}
6 changes: 6 additions & 0 deletions packages/backend/src/server/oauth/OAuth2ProviderService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import oauth2orize, { type OAuth2, AuthorizationError, ValidateFunctionArity2, O
import oauth2Pkce from 'oauth2orize-pkce';
import fastifyCors from '@fastify/cors';
import fastifyView from '@fastify/view';
import rateLimit from '@fastify/rate-limit';
import pug from 'pug';
import bodyParser from 'body-parser';
import fastifyExpress from '@fastify/express';
Expand Down Expand Up @@ -393,6 +394,11 @@ export class OAuth2ProviderService {
},
});

fastify.register(rateLimit, {
max: 100,
timeWindow: '1 hour'
});

await fastify.register(fastifyExpress);
fastify.use('/authorize', this.#server.authorize(((areq, done) => {
(async (): Promise<Parameters<typeof done>> => {
Expand Down
Loading

0 comments on commit 9191000

Please sign in to comment.