just-dandi / dandi Goto Github PK
View Code? Open in Web Editor NEW๐ปA modular DI, MVC, and Model binding/validation framework for NodeJS and TypeScript or ES6
License: MIT License
๐ปA modular DI, MVC, and Model binding/validation framework for NodeJS and TypeScript or ES6
License: MIT License
Similar to @RequestBody()
, @QueryParam()
, and @PathParam()
, @RequestHeader()
will allow a header value to be injected into a method or class constructor.
HttpHeader
value as an argumentHttpRequestHeaders
We should not be doing any modification of the data coming out of data clients from within the data client libraries. This is causing problems with JSON blob columns that use UUID style keys, since the data mapper is trying to convert them to camelCase.
@Json
decorator to optionally ignore transforms for JSON fieldsBuffer
, etc)HttpBodyParser
implementation that supports receiving the application/octet-stream
MIME typemultipart/form-data
requests@dandi/core
to @dandi/common
@dandi/di-core
to @dandi-core
Angular uses a customized wrapper around tsc
to extract type data and allow it to be used at runtime. Dandi would benefit from the same functionality.
Container
to infer injected types from type data@Inject
optional@Accept()
decorator, which can take one or more MIME type strings as input@Accept()
can be applied at controller or method level@Accept()
, any configured renderer will be used@Accept()
, content type rendering will be limited to the route's specified content typesDepends on #24
@QueryParam
should be treated as optionalIt'd be good to have an automated check that changes to the library don't break the examples
Add test coverage for the following items:
PgDbQueryableBase
PgDbClient
PgDbPool
PgDbPoolClient
PgDbTransactionClient
PgDbConfig
Resolver
implementation based on existing logic in Container
resolve
and resolveInContext
to inject
/injectInContext
, with additional injectSingle
and injectMulti
variantsContainer
-> DandiApplication
DandiApplication
will retain the startup/bootstrapping logicSELECT
expansion for modelsdepends on #24
@ErrorHandler
method decoratorDefaultRouteExecutor
The existing implementation using of @ListRelation
and @Relation
does not work when two resources have interdependent relations (e.g. a parent with an array of children, and the children with a relation to the parent).
A solution would be to allow offloading the decoration of relations to a class defined in a separate file. The @Relations(forModel)
decorator links the relation data defined in the "relations" class to the specified model.
Example:
// parent.resource.ts
export class ParentResource {
// decorating without referencing ChildResource acts as a placeholder, and
// prevents a circular reference at runtime
@ListRelation()
public children: ChildResource[];
}
// parent.resource.relations.ts
@Relations(ParentResource)
export class ParentResourceRelations {
// fills in the placeholder with the correct class reference
@ListRelation(ChildResource)
children: ChildResource[];
}
// child.resource.ts
export class ChildResource {
// decorating without referencing ParentResource acts as a placeholder, and
// prevents a circular reference at runtime
@Relation()
public parent: ParentResource;
}
// child.resource.relations.ts
@Relations(ChildResource)
export class ChildResourceRelations {
// fills in the placeholder with the correct class reference
@Relation(ParentResource)
public parent: ParentResource;
}
Doesn't this still has circular dependencies?
Technically yes, but since the circularity is only referenced for typing (e.g. we aren't referencing the circularly referenced types as classes/values), and not at runtime, it still works.
How do the "relations" files get referenced naturally? As it is, they'll need to get explicitly imported somewhere just for their side effects, which is not ideal.
Option A:
parent.resource.model.ts // export class ParentResource
parent.resource.relations.ts // export class ResourceResourceRelations
parent.resource.ts // export * from './parent.resource.model'; export * from './parent.resource.relations'
Caveat: "relations" must import directly from the "model" file, all other references must import from "resource" file
similar to rendering content negotiation:
Disposable.useAsync
accepts a promise for the source object and resolves it before invoking the usage functionSince "invalid registration target" can mean different things, including a bad/missing default value or configuration, it can be very difficult to track down the actual problem, requiring debugging in @dandi/core itself, add tooling to make it easier to narrow down the source of the bad target.
Symbol
property that identifies its source and what it is// @dandi/common
export class DandiModule extends Array<any> {
public static readonly package = Symbol.for('@dandi/common#DandiModule.package');
public static readonly name = Symbol.for('@dandi/common#DandiModule.Name');
constructor(package: string, name: string, ...providers: any[]) {
super(providers);
this[DandiModulePackage] = package;
this[DandiModuleName] = name;
}
providers[DandiModulePackage] = package;
providers[DandiModuleName] = name;
}
// @dandi/some-pkg
export const SomePkgModule = dandiModule(SomePkgService, AnotherPkgService];
The current validation scheme actually does two jobs:
The goals of this change are:
This most likely means moving the "reconstitution" logic into @dandi/model
, which will not be a problem after #12. Alternatively, use a new package (e.g. @dandi/model-builder
)
disableRequired
to @RequestBody()
decoratordisableRequired
is set, don't fail on missing required propertiesAdd test coverage for the following items:
DecoratorRouteGenerator
mergeAuthorization
in authorization.metadata.ts
authorizedDecorator
DefaultRouteInitializer
requestBodyProvider
in request.body.decorator.ts
getCorsConfig
@dandi/core
@dandi/mvc
@dandi/mvc-hal
add @dandi/mvc-autodocs
package
text/html
requestsAdd test coverage for the following items:
DecoratorModelValidator
UuidTypeValidator
fs-extra
is only used by FileSystemScanner
, but prevents @dandi/core
and anything dependent on it from being used in the browser.
@dandi/core-node
packageFileSystemScanner
into @dandi/core-node
, remove fs-extra
dependency@dandi/mvc-express
-> @dandi-contrib/mvc-express
)@dandi/mvc-view
ViewEngine
interface and injection tokenViewResult
classRenderOptions
interfaceview(path: string, options: RenderOptions) => ViewResult
methodViewEngine
implementation for pug in @dandi-contrib/mvc-view-pug
ViewEngine
implementation for ejs @dandi-contrib/mvc-view-ejs
dependent on #34
features TBD
Disposable
in @dandi/core
PgDbTransactionClient
in @dandi/data-pg
LogStream
is an Observable
of log itemsLogger
becomes an implementation that broadcasts to LogStream
LogListeners
subscribe to LogStream
NoopLogger
ConsoleLogger
becomes ConsoleLogListener
ConsoleLogListener
formattingConsoleLogListener
high water mark spacing featureLogger
APIPrettyColorsLogging
LoggerFixture
for testing Logger
usage@dandi/model-schema
package@QueryParam
@PathParam
@RequestBody
dependent on #34
Add a validator for Angular that maps an input/ngModel binding to @dandi/model validation information.
new package: @dandi/ng-forms
Currently, the framework does differentiate between pipeline results with errors and those without - it will attempt to render the response regardless. This is fine for data responses, as the appropriate error information will be rendered in the format requested by the client, however, it doesn't work as well when using views, since it will attempt to render the requested view, which will often fail due to missing required data.
MvcViewRenderer
to check for errors in the HttpPipelineResult
, and use error rendering if errors are presentRequestError.internalMessage
(if defined) only for non-production environmentsinnerError
dataA 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.