Last active
November 30, 2023 15:19
-
-
Save luismendes070/905e3202ec714c24cdd17dee5e722acb to your computer and use it in GitHub Desktop.
Angular course https://photos.app.goo.gl/p5N7heqVNYjvAEtQ9 Novas aulas serão lançadas em breve! #SonarQube #ChatGPT #VirtualBox #Ubuntu 18 #thunderclient #vscode #extension
This file contains hidden or 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
// Angular HTTP API | Part 27 - Sending PATCH Request 2 https://youtu.be/if90tYBdCsg | |
patchXml(course:Course): Observable<Course>{ | |
return this.http.patch<Course>('${this.apiUrl}/courses/id/${courses.id}', course); | |
} | |
// git fork curso especialista Angular Loiane Groner | |
git clone https://github.com/luismendes070/curso-angular.git | |
new repo git pull large file system | |
https://github.com/luismendes070/crud-xml-git-pull/tree/master | |
node --version | |
v18.12.1 | |
SCSS or CSS | |
https://sass-lang.com/documentation/syntax#scss | |
Set-ExecutionPolicy -Scope CurrentUser -ExecutionPolicy RemoteSigned | |
ng --version | |
VSCode Extension Java + Spring | |
VSCode Extension TypeScript Hero | |
cd my-app | |
ng serve --open | |
ng add @angular/material | |
ng g m courses | |
ng g m courses --routing | |
ng g c courses/courses | |
@angular/core 15.0.4 | |
Problem https://stackoverflow.com/questions/73639394/ng0303-cant-bind-to-ngforof-since-it-isnt-a-known-property-of-div-used-i | |
Solution ? | |
Problem https://stackoverflow.com/questions/56597917/need-help-in-connecting-mongodb-to-vs-code | |
Solution IntelliJ Ultimate |
Vercel CORS
const express = require('express');
const app = express();
// Set CORS headers
app.use((req, res, next) => {
res.setHeader('Access-Control-Allow-Origin', '*');
res.setHeader('Access-Control-Allow-Methods', 'GET, POST, PUT, DELETE, OPTIONS');
res.setHeader('Access-Control-Allow-Headers', 'Content-Type, Authorization');
if (req.method === 'OPTIONS') {
return res.sendStatus(200);
}
next();
});
// Your API routes go here...
import { Injectable } from '@angular/core';
import { HttpInterceptor, HttpRequest, HttpHandler, HttpEvent } from '@angular/common/http';
import { Observable } from 'rxjs';
@Injectable()
export class CorsInterceptor implements HttpInterceptor {
intercept(req: HttpRequest<any>, next: HttpHandler): Observable<HttpEvent<any>> {
const headers = req.headers
.set('Access-Control-Allow-Origin', '*')
.set('Access-Control-Allow-Methods', 'GET, POST, PUT, DELETE, OPTIONS')
.set('Access-Control-Allow-Headers', 'Content-Type, Authorization');
const corsReq = req.clone({ headers });
return next.handle(corsReq);
}
}
import { Injectable } from '@angular/core';
import { HttpClient } from '@angular/common/http';
import { Observable } from 'rxjs';
@Injectable({
providedIn: 'root'
})
export class MyCrudService {
private apiUrl = 'http://example.com/api';
constructor(private http: HttpClient) { }
getAll(): Observable<any> {
return this.http.get(`${this.apiUrl}/items`);
}
create(data: any): Observable<any> {
return this.http.post(`${this.apiUrl}/items`, data);
}
update(id: number, data: any): Observable<any> {
return this.http.put(`${this.apiUrl}/items/${id}`, data);
}
delete(id: number): Observable<any> {
return this.http.delete(`${this.apiUrl}/items/${id}`);
}
}
ng generate interceptor auth --skip-tests=true
import { Injectable } from '@angular/core';
import { HttpInterceptor, HttpRequest, HttpHandler } from '@angular/common/http';
@Injectable()
export class AuthInterceptor implements HttpInterceptor {
intercept(req: HttpRequest<any>, next: HttpHandler) {
const authToken = 'my-auth-token';
const authReq = req.clone({
headers: req.headers.set('Authorization', `Bearer ${authToken}`)
});
return next.handle(authReq);
}
}
import { NgModule } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import { HttpClientModule, HTTP_INTERCEPTORS } from '@angular/common/http';
import { AppComponent } from './app.component';
import { AuthInterceptor } from './auth.interceptor';
@NgModule({
declarations: [AppComponent],
imports: [BrowserModule, HttpClientModule],
providers: [
{ provide: HTTP_INTERCEPTORS, useClass: AuthInterceptor, multi: true }
],
bootstrap: [AppComponent]
})
export class AppModule {}
NextJS Secure XML loading for Angular CRUD XML #ChatGPT
import { HttpClient } from '@angular/common/http';
constructor(private http: HttpClient) {}
this.http.get('https://example.com/api/xml-data').subscribe(data => {
console.log(data); // logs the fetched XML data
});
import { HttpClient, HttpHeaders } from '@angular/common/http';
const headers = new HttpHeaders({
'Content-Type': 'application/xml', // or any other appropriate content type
'Access-Control-Allow-Origin': '*', // or the domain of your Angular app
});
this.http.get('https://example.com/api/xml-data', { headers }).subscribe(data => {
console.log(data); // logs the fetched XML data
});
Insomnia stress testing k6, locust, loader #BingChat
[ ] Angular
[ ] Java Spring Boot
k6 JavaScript
`import http from 'k6/http';
import {sleep} from 'k6';
export const options = {
stages: [
{ duration: '10m', target: 200 }, // ramp-up from 1 to 200 users over 10 minutes.
{ duration: '30m', target: 200 }, // stay at 200 users for 30 minutes
{ duration: '5m', target: 0 }, // ramp-down to 0 users
],
};
export default () => {
const urlRes = http.get('https://test-api.k6.io');
};
`
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Spring Security wihout the websecurity adapter