@marblejs/core
Advanced tools
Comparing version 1.0.0-rc.1 to 1.0.0-rc.2
import { Observable } from 'rxjs'; | ||
import { HttpRequest, HttpResponse } from '../http.interface'; | ||
export { HttpRequest, HttpResponse, Observable }; | ||
export declare const combineMiddlewareEffects: (effects: ((request$: Observable<HttpRequest>, response: HttpResponse, metadata: any) => Observable<HttpRequest>)[]) => (request$: Observable<HttpRequest>, response: HttpResponse, metadata: any) => Observable<HttpRequest>; | ||
export declare const combineMiddlewareEffects: (effects: import("packages/core/src/effects/effects.interface").Effect<HttpRequest, any>[]) => import("packages/core/src/effects/effects.interface").Effect<HttpRequest, any>; |
@@ -1,2 +0,1 @@ | ||
import { HttpMethod } from '../http.interface'; | ||
import { Effect, EffectResponse } from './effects.interface'; | ||
@@ -6,3 +5,3 @@ import { RouteEffect } from '../router/router.interface'; | ||
const matchPath: (path: string) => { | ||
matchType: (method: HttpMethod) => { | ||
matchType: (method: "POST" | "PUT" | "PATCH" | "GET" | "HEAD" | "DELETE" | "CONNECT" | "OPTIONS" | "TRACE" | "*") => { | ||
use: (effect: Effect<EffectResponse, any>) => RouteEffect; | ||
@@ -9,0 +8,0 @@ }; |
@@ -0,1 +1,2 @@ | ||
/// <reference types="node" /> | ||
import { HttpStatus } from '../http.interface'; | ||
@@ -9,5 +10,12 @@ export declare class ExtendableError extends Error { | ||
readonly status: HttpStatus; | ||
readonly data: object | undefined; | ||
readonly data?: object | undefined; | ||
constructor(message: string, status: HttpStatus, data?: object | undefined); | ||
} | ||
export declare class CoreError extends ExtendableError { | ||
readonly message: string; | ||
constructor(message: string, options: { | ||
stackTraceFactory: (message: string, stack: NodeJS.CallSite[]) => string; | ||
context: any; | ||
}); | ||
} | ||
export declare const isHttpError: (error: Error) => error is HttpError; |
@@ -19,3 +19,15 @@ /// <reference types="node" /> | ||
export declare type HttpHeaders = Record<string, string>; | ||
export declare type HttpMethod = 'POST' | 'PUT' | 'PATCH' | 'GET' | 'HEAD' | 'DELETE' | 'CONNECT' | 'OPTIONS' | 'TRACE' | '*'; | ||
export declare enum HttpMethodType { | ||
POST = 0, | ||
PUT = 1, | ||
PATCH = 2, | ||
GET = 3, | ||
HEAD = 4, | ||
DELETE = 5, | ||
CONNECT = 6, | ||
OPTIONS = 7, | ||
TRACE = 8, | ||
'*' = 9 | ||
} | ||
export declare type HttpMethod = keyof typeof HttpMethodType; | ||
export declare type Http = { | ||
@@ -45,3 +57,3 @@ req: HttpRequest; | ||
SERVICE_UNAVAILABLE = 503, | ||
GATEWAY_TIMEOUT = 504, | ||
GATEWAY_TIMEOUT = 504 | ||
} |
/// <reference types="node" /> | ||
import { IncomingMessage, OutgoingMessage } from 'http'; | ||
import { Observable } from 'rxjs'; | ||
import { EffectResponse } from './effects/effects.interface'; | ||
import { HttpRequest, HttpResponse } from './http.interface'; | ||
import { Middleware, ErrorEffect } from './effects/effects.interface'; | ||
import { RouteEffect, RouteEffectGroup } from './router/router.interface'; | ||
export { Observable }; | ||
export declare const httpListener: ({ middlewares, effects, errorEffect, }: { | ||
middlewares?: ((request$: Observable<HttpRequest>, response: HttpResponse, metadata: any) => Observable<HttpRequest>)[] | undefined; | ||
declare type HttpListenerConfig = { | ||
middlewares?: Middleware[]; | ||
effects: (RouteEffect | RouteEffectGroup)[]; | ||
errorEffect?: ((request$: Observable<HttpRequest>, response: HttpResponse, metadata: Error) => Observable<EffectResponse>) | undefined; | ||
}) => (req: IncomingMessage, res: OutgoingMessage) => void; | ||
errorEffect?: ErrorEffect; | ||
}; | ||
export declare const httpListener: ({ middlewares, effects, errorEffect, }: HttpListenerConfig) => (req: IncomingMessage, res: OutgoingMessage) => void; | ||
export {}; |
@@ -10,3 +10,3 @@ export { EffectFactory } from './effects/effects.factory'; | ||
export * from './operators'; | ||
export { compose } from './util/compose.util'; | ||
export { ContentType } from './util/contentType.util'; | ||
import * as internal from './+internal'; | ||
export { internal }; |
@@ -1,5 +0,3 @@ | ||
import { Observable } from 'rxjs'; | ||
import { EffectResponse } from '../effects/effects.interface'; | ||
import { HttpRequest, HttpResponse } from '../http.interface'; | ||
export { Observable }; | ||
export declare const handleResponse: (res: HttpResponse) => (req: HttpRequest) => (effect: EffectResponse) => Observable<never>; | ||
export declare const handleResponse: (res: HttpResponse) => (req: HttpRequest) => (effect: EffectResponse) => import("rxjs/internal/Observable").Observable<never>; |
import { HttpStatus } from '../http.interface'; | ||
import { ContentType } from '../util/contentType.util'; | ||
import { ContentType } from '../+internal'; | ||
export declare const DEFAULT_CONTENT_TYPE: ContentType; | ||
@@ -4,0 +4,0 @@ export declare const getMimeType: (body: any, path: string) => string; |
import { Observable } from 'rxjs'; | ||
import { HttpMethod, HttpRequest, HttpResponse } from '../http.interface'; | ||
import { HttpRequest, HttpResponse } from '../http.interface'; | ||
import { EffectResponse } from '../effects/effects.interface'; | ||
import { RouteMatched, RoutingItem } from './router.interface'; | ||
export { RoutingItem }; | ||
export declare const findRoute: (routing: RoutingItem[], url: string, method: HttpMethod) => RouteMatched | undefined; | ||
export declare const findRoute: (routing: RoutingItem[], url: string, method: "POST" | "PUT" | "PATCH" | "GET" | "HEAD" | "DELETE" | "CONNECT" | "OPTIONS" | "TRACE" | "*") => RouteMatched | undefined; | ||
export declare const resolveRouting: (routing: RoutingItem[]) => (res: HttpResponse) => (req: HttpRequest) => Observable<EffectResponse>; |
{ | ||
"name": "@marblejs/core", | ||
"version": "1.0.0-rc.1", | ||
"version": "1.0.0-rc.2", | ||
"description": "Reactive Node APIs made easy", | ||
@@ -8,7 +8,8 @@ "main": "./dist/index.js", | ||
"scripts": { | ||
"start": "npm run watch", | ||
"watch": "tsc -w", | ||
"build": "tsc", | ||
"prepare": "npm run build", | ||
"prepack": "cp ../../README.md ./ && npm run build" | ||
"start": "yarn watch", | ||
"watch": "webpack -w", | ||
"build": "webpack", | ||
"prepare": "yarn build", | ||
"clean": "rimraf dist", | ||
"prepack": "cp ../../README.md ./ && yarn build" | ||
}, | ||
@@ -24,2 +25,3 @@ "files": [ | ||
"node": ">= 8.0.0", | ||
"yarn": ">= 1.7.0", | ||
"npm": ">= 5.0.0" | ||
@@ -42,7 +44,9 @@ }, | ||
"@types/file-type": "^5.2.1", | ||
"@types/mime": "^2.0.0" | ||
"@types/mime": "^2.0.0", | ||
"webpack": "^4.17.2" | ||
}, | ||
"publishConfig": { | ||
"access": "public" | ||
} | ||
}, | ||
"gitHead": "9b8565f636217fc4f69eca50203bcf05fab2fc4c" | ||
} |
@@ -42,20 +42,19 @@ <p align="center"> | ||
To view the example project structure, clone the **Marble.js** repository and install the dependencies: | ||
To view the example project structure, visit the [example](https://github.com/marblejs/example) repository. | ||
```bash | ||
$ git clone git://github.com/marblejs/marble.git | ||
$ cd marble | ||
$ npm i | ||
$ cd example | ||
``` | ||
## <a name="roadmap"></a> Roadmap | ||
To run example just execute following command inside root repository folder: | ||
**Marble.js** is not yet a final and production ready product. Its APIs can improve over time when reaching stable version `1.0.0`. But in the meantime you can play easily and contribute to the growing community of functional reactive programming freaks. | ||
```bash | ||
$ npm run start | ||
``` | ||
## Contributing | ||
## <a name="roadmap"></a> Roadmap | ||
We strongly believe that open source is all about the people. Thats why we are looking for brave passionates of RxJS and Node.js who can help us with creating new middlewares for Marble.js. There are many things that you can help us with! We've got a [list](https://github.com/marblejs/marble/projects/2) of middlewares that we would like to see in future releases, but we are open for new cool ideas! | ||
**Marble.js** is not yet a final and production ready product. Its APIs can improve over time when reaching stable version `1.0.0`. But in the meantime you can play easily and contribute to the growing community of functional reactive programming freaks. | ||
**So, how can I contribute to Marble.js middlewares?** 🤔 | ||
- Read the [CONTRIBUTING](https://github.com/marblejs/marble/blob/master/.github/CONTRIBUTING.md) guideance first! | ||
- We use monorepo architecture for entire framework-related packages - each middleware resides in main Marble.js repository | ||
- For reference code structure just look at [example](https://github.com/marblejs/marble/tree/master/packages/middleware-joi) middleware implementation. | ||
- Each middleware package should follow the naming convention: `@marblejs/middleware-{example_name}` | ||
- If you have an idea and would like to contribute, just open an [issue](https://github.com/marblejs/marble/issues/new?template=feature_request.md) and describe the middelware idea that you would like to work on. We'll discuss the internals and proposed features there. | ||
- Open a Pull Request and... 🚀 | ||
@@ -62,0 +61,0 @@ ## Authors |
Sorry, the diff of this file is too big to display
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
Minified code
QualityThis package contains minified code. This may be harmless in some cases where minified code is included in packaged libraries, however packages on npm should not minify code.
Found 1 instance in 1 package
97599
3
57
374
2
111
1
1