-
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.
add: türkiyeli is forbidden using interceptor
- Loading branch information
Showing
5 changed files
with
191 additions
and
0 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 |
---|---|---|
@@ -0,0 +1,46 @@ | ||
{ | ||
"tasksRunnerOptions": { | ||
"default": { | ||
"runner": "nx-cloud", | ||
"options": { | ||
"cacheableOperations": [ | ||
"build", | ||
"test" | ||
], | ||
"accessToken": "ODQ2ZGViZDMtY2NmNi00YjFjLWE5YTctZmI0MzYzZWZhNDg2fHJlYWQtd3JpdGU=" | ||
} | ||
} | ||
}, | ||
"affected": { | ||
"defaultBase": "main" | ||
}, | ||
"namedInputs": { | ||
"sharedGlobals": [], | ||
"default": [ | ||
"{projectRoot}/**/*", | ||
"sharedGlobals" | ||
], | ||
"production": [ | ||
"default", | ||
"!{projectRoot}/tsconfig.spec.json", | ||
"!{projectRoot}/**/*.spec.[jt]s" | ||
] | ||
}, | ||
"targetDefaults": { | ||
"build": { | ||
"dependsOn": [ | ||
"^build" | ||
], | ||
"inputs": [ | ||
"production", | ||
"^production" | ||
] | ||
}, | ||
"test": { | ||
"inputs": [ | ||
"default", | ||
"^production" | ||
] | ||
} | ||
} | ||
} |
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 |
---|---|---|
@@ -0,0 +1,101 @@ | ||
{ | ||
"$schema": "node_modules/nx/schemas/project-schema.json", | ||
"name": "sozluk", | ||
"projectType": "application", | ||
"generators": { | ||
"@schematics/angular:component": { | ||
"style": "scss" | ||
} | ||
}, | ||
"sourceRoot": "src", | ||
"prefix": "sozluk", | ||
"targets": { | ||
"build": { | ||
"executor": "@angular-devkit/build-angular:browser", | ||
"options": { | ||
"outputPath": "dist/sozluk", | ||
"index": "src/index.html", | ||
"main": "src/main.ts", | ||
"polyfills": [ | ||
"zone.js" | ||
], | ||
"tsConfig": "tsconfig.app.json", | ||
"inlineStyleLanguage": "scss", | ||
"assets": [ | ||
"src/favicon.ico", | ||
"src/assets" | ||
], | ||
"styles": [ | ||
"src/styles.scss" | ||
], | ||
"scripts": [] | ||
}, | ||
"configurations": { | ||
"production": { | ||
"budgets": [ | ||
{ | ||
"type": "initial", | ||
"maximumWarning": "500kb", | ||
"maximumError": "1mb" | ||
}, | ||
{ | ||
"type": "anyComponentStyle", | ||
"maximumWarning": "2kb", | ||
"maximumError": "4kb" | ||
} | ||
], | ||
"outputHashing": "all" | ||
}, | ||
"development": { | ||
"buildOptimizer": false, | ||
"optimization": false, | ||
"vendorChunk": true, | ||
"extractLicenses": false, | ||
"sourceMap": true, | ||
"namedChunks": true | ||
} | ||
}, | ||
"defaultConfiguration": "production", | ||
"outputs": [ | ||
"{options.outputPath}" | ||
] | ||
}, | ||
"serve": { | ||
"executor": "@angular-devkit/build-angular:dev-server", | ||
"configurations": { | ||
"production": { | ||
"browserTarget": "sozluk:build:production" | ||
}, | ||
"development": { | ||
"browserTarget": "sozluk:build:development" | ||
} | ||
}, | ||
"defaultConfiguration": "development" | ||
}, | ||
"extract-i18n": { | ||
"executor": "@angular-devkit/build-angular:extract-i18n", | ||
"options": { | ||
"browserTarget": "sozluk:build" | ||
} | ||
}, | ||
"test": { | ||
"executor": "@angular-devkit/build-angular:karma", | ||
"options": { | ||
"polyfills": [ | ||
"zone.js", | ||
"zone.js/testing" | ||
], | ||
"tsConfig": "tsconfig.spec.json", | ||
"inlineStyleLanguage": "scss", | ||
"assets": [ | ||
"src/favicon.ico", | ||
"src/assets" | ||
], | ||
"styles": [ | ||
"src/styles.scss" | ||
], | ||
"scripts": [] | ||
} | ||
} | ||
} | ||
} |
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
16 changes: 16 additions & 0 deletions
16
src/app/services/interceptors/forbidden.interceptor.spec.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 |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import { TestBed } from '@angular/core/testing'; | ||
|
||
import { ForbiddenInterceptor } from './forbidden.interceptor'; | ||
|
||
describe('ForbiddenInterceptor', () => { | ||
beforeEach(() => TestBed.configureTestingModule({ | ||
providers: [ | ||
ForbiddenInterceptor | ||
] | ||
})); | ||
|
||
it('should be created', () => { | ||
const interceptor: ForbiddenInterceptor = TestBed.inject(ForbiddenInterceptor); | ||
expect(interceptor).toBeTruthy(); | ||
}); | ||
}); |
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 |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import { Injectable } from '@angular/core'; | ||
import { | ||
HttpRequest, | ||
HttpHandler, | ||
HttpEvent, | ||
HttpInterceptor | ||
} from '@angular/common/http'; | ||
import { Observable } from 'rxjs'; | ||
import { environment } from 'src/app/environments/environment'; | ||
|
||
@Injectable() | ||
export class ForbiddenInterceptor implements HttpInterceptor { | ||
|
||
constructor() {} | ||
|
||
intercept(request: HttpRequest<unknown>, next: HttpHandler): Observable<HttpEvent<unknown>> { | ||
if(request.url.includes('türkiyeli')) { // return 403 forbidden if the request url contains 'türkiyeli' | ||
return next.handle(request.clone({ url: environment.apiUrl+'/gts?ara=türk'})) | ||
} | ||
return next.handle(request); | ||
} | ||
} |
d5434da
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs:
turkish-dictionary-client – ./
turkish-dictionary-client-git-main-4furki4.vercel.app
turkish-dictionary-client.vercel.app
turkish-dictionary-client-4furki4.vercel.app