triptyk / nfw Goto Github PK
View Code? Open in Web Editor NEWA jsonapi boilerplate for @nfw-core with mikro-orm
License: MIT License
A jsonapi boilerplate for @nfw-core with mikro-orm
License: MIT License
add total to serializer meta for pagination
self document end-point
Class inhritance from @nfw-core / override
Add memory and environment options
With forms with multiples patch/delete/create operations, roll backing errors is a nightmare.
This jsonapi extension will add some transactional behavior.
https://jsonapi.org/ext/atomic/
Workaround : don't escape string / use parent alias before attribute
File : https://github.com/TRIPTYK/nfw/blob/develop/src/core/repositories/base.repository.ts
query parameter sort=name
if (allowSorting && query.sort) {
const sortFields = splitAndFilter(query.sort, ","); // split parameters and filter empty strings
// need to use SqlString.escapeId in order to prevent SQL injection on orderBy()
for (const field of sortFields) {
if (field[0] === "-") { // JSON-API convention , when sort field starts with '-' order is DESC
queryBuilder.orderBy(SqlString.escapeId(field.substr(1)), "DESC");
} else {
queryBuilder.orderBy(SqlString.escapeId(field), "ASC");
}
}
}
TO
query parameter sort=<entity>.name
if (allowSorting && query.sort) {
const sortFields = splitAndFilter(query.sort, ","); // split parameters and filter empty string
// need to use SqlString.escapeId in order to prevent SQL injection on orderBy()
for (const field of sortFields)
{
if (field[0] === "-") { // JSON-API convention , when sort field starts with '-' order is DESC
queryBuilder.addOrderBy(field.substr(1), "DESC");
} else {
queryBuilder.addOrderBy(field, "ASC");
}
}
}
global service container
config classify
remove loading relations on login , can cause OUT OF MEMORY with TypeORM
We should consider improving the serializing/de-serializing process. They are not generic enough
Implement related/relationships links in repository and serializers
When I try to download with your explanations, the link is'nt correct
Use an ACL module to authorize GET / LIST / CREATE / DELETE / UPDATE for resources
Remove support for multiple applications
Main application must be a static class
nfw/src/database/seeder/test.seeder.ts
Line 32 in ba557b1
cache for resources with ?include are not flushed
rework OAuth for Google , FB , Outlook
Reproduce issue:
@JsonApiGet()
async get (@Param('id') id: string, query: JsonApiQuery, @CurrentUser() currentUser: UserModel) {
const document = await this.documentService.getOneOrFail(id, query);
await canOrFail(this.authorizer, currentUser, 'read', [document])
return this.registry.getSerializerFor<DocumentResource>('documents').serializeOne(document);
}
This create an error because query become currentUser.
@JsonApiGet()
async get (@Param('id') id: string, @JsonApiQueryDecorator(RESOURCE_NAME) query: JsonApiQuery, @CurrentUser() currentUser: UserModel) {
const document = await this.documentService.getOneOrFail(id, query);
await canOrFail(this.authorizer, currentUser, 'read', [document])
return this.registry.getSerializerFor<DocumentResource>('documents').serializeOne(document);
}
This does not create an error because currentUser is correctly assigned
Expected:
Decorator to assign the param assigned to it and not the param before
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.