
Security News
Axios Maintainer Confirms Social Engineering Attack Behind npm Compromise
Axios compromise traced to social engineering, showing how attacks on maintainers can bypass controls and expose the broader software supply chain.
@softeq/angular-http-data
Advanced tools
@softeq/angular-http-data provides
HttpClient with @softeq/data-mappers libraryThis library provides helpers to implement REST-like communications.
First of all you have to setup this library.
@NgModule({
imports: [
SofteqHttpDataModule.forRoot({
baseUrl: 'https://api.example.com',
}),
...
],
...
})
where baseUrl points to basic part of URL all subsequent requests will be resolved upon.
Create service that extends AbstractRestService
class EmployeeRest extends AbstractRestService {
get(id: number): Observable<Employee> {
return this.httpGet(`/employees/${id}`, optimisticLockingOf(employeeMapper));
}
update(employee: Employee): Observable<Employee> {
return this.httpPut(`/employees/${employee.id}`, employee, optimisticLockingOf(employeeMapper));
}
}
where httpGet and httpPut methods accept
baseUrl.httpPut method)DataMapper (the last parameter for all http* methods)There are several http* methods defined in AbstractRestService:
httpGet for GET requesthttpPost for POST requesthttpPut for PUT requesthttpDelete for DELETE requesthttpRequest allows to send request of any method.HttpClient with @softeq/data-mappersIf you want to use DataMappers, but do not like AbstractRestService you can use DataMappers directly with HttpClient,
but in this case you have to map requests/responses manually.
HttpRequest
mergeRequestWithMapper<S, R>(request: HttpRequest<S>,
body?: S,
requestMapper?: HttpDataMapper<S>,
responesMapper?: HttpDataMapper<R>): HttpRequest<any>
transforms body of request using given requestMapper,responseMapper is optional here,
but sometimes it is necessary to define correct responseType of HttpRequest (only for non-json responseType).HttpResponse
parseResponseWithMapper<T>(response: HttpResponse<T>,
responseMapper?: HttpDataMapper<T>): T
transforms response using provided responseMapper.Tables often show data by pages or have infinite scroll, where only visible part of content is fetched from the server.
In both cases we have to return data by chunks. @softeq/angular-http-data library provides AbstractPaginationRestService
to implement such behavior.
Look at the following example
class EmployeeRest extends AbstractPaginationRestService {
findAllByNameAsDataSource(name: string): SlicedDataSource {
return this.createSlicedDataSourceGet(`/employees`, { name }, identityMapper(), arrayMapperOf(employeeMapper));
}
}
Here we use createSlicedDataSourceGet method which
GET request body is merged into URL as query parameters)DataMapper for request bodyDataMapper for response body (body is always array of data)SlicedDataSource.SlicedDataSource allows to select data by chunks
const dataSource = this.employeeRest.findAllByNameAsDataSource('John');
const slicedData$ = dataSource.select({
from: 0,
to: 25,
sorting: { field: 'name', direction: SortDirection.Descending },
});
slicedData$.subscribe((slicedData: SlicedData) => {
slicedData.data; // chunk of returned data
slicedData.total; // total number of data
});
There are several createSlicedDataSource* methods defined in AbstractPaginationRestService:
createSlicedDataSourceGet for GET requestcreateSlicedDataSourcePut for PUT requestcreateSlicedDataSourcePost for POST requestcreateSlicedDataSource allows to send request of any methodAbstractPaginationRestService relies onAbstractPaginationRestService is opinionated regarding protocol used for paging.
It uses Range header to perform request.
Range: items=0-24
The server should respond with a Content-Range header to indicate how many items are being returned
and how many total items exist.
Content-Range: items 0-24/66
Body of response should be a chunk (Array) of retrieved data.
[
{
"id": 1,
"name": "John"
},
{
"id": 2,
"name": "Mark"
},
...
]
FAQs
Angular support of @softeq/data-mappers
We found that @softeq/angular-http-data demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
Axios compromise traced to social engineering, showing how attacks on maintainers can bypass controls and expose the broader software supply chain.

Security News
Node.js has paused its bug bounty program after funding ended, removing payouts for vulnerability reports but keeping its security process unchanged.

Security News
The Axios compromise shows how time-dependent dependency resolution makes exposure harder to detect and contain.