@teambit/express 0.0.960 → 0.0.962
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/artifacts/__bit_junit.xml +1 -1
- package/artifacts/preview/teambit_harmony_express-preview.js +1 -1
- package/artifacts/schema.json +983 -850
- package/dist/express.aspect.d.ts +2 -0
- package/dist/express.composition.d.ts +1 -0
- package/dist/express.main.runtime.d.ts +72 -0
- package/dist/index.d.ts +7 -0
- package/dist/middleware-manifest.d.ts +5 -0
- package/dist/middlewares/error.d.ts +8 -0
- package/dist/middlewares/index.d.ts +1 -0
- package/dist/{preview-1712805335812.js → preview-1714533890836.js} +2 -2
- package/dist/types/index.d.ts +4 -0
- package/dist/types/next.d.ts +2 -0
- package/dist/types/request.d.ts +1 -0
- package/dist/types/response.d.ts +2 -0
- package/dist/types/route.d.ts +24 -0
- package/package.json +5 -5
- package/tsconfig.json +1 -10
@@ -0,0 +1 @@
|
|
1
|
+
export declare const Logo: () => import("react/jsx-runtime").JSX.Element;
|
@@ -0,0 +1,72 @@
|
|
1
|
+
/// <reference types="node" />
|
2
|
+
import { Server } from 'http';
|
3
|
+
import { SlotRegistry } from '@teambit/harmony';
|
4
|
+
import { Logger, LoggerMain } from '@teambit/logger';
|
5
|
+
import { Express } from 'express';
|
6
|
+
import { Route } from './types';
|
7
|
+
import { MiddlewareManifest } from './middleware-manifest';
|
8
|
+
export type ExpressConfig = {
|
9
|
+
port: number;
|
10
|
+
namespace: string;
|
11
|
+
loggerIgnorePath: string[];
|
12
|
+
};
|
13
|
+
export type MiddlewareSlot = SlotRegistry<MiddlewareManifest[]>;
|
14
|
+
export type RouteSlot = SlotRegistry<Route[]>;
|
15
|
+
export declare class ExpressMain {
|
16
|
+
/**
|
17
|
+
* extension config
|
18
|
+
*/
|
19
|
+
readonly config: ExpressConfig;
|
20
|
+
/**
|
21
|
+
* slot for registering graphql modules
|
22
|
+
*/
|
23
|
+
private moduleSlot;
|
24
|
+
/**
|
25
|
+
* logger extension.
|
26
|
+
*/
|
27
|
+
readonly logger: Logger;
|
28
|
+
readonly middlewareSlot: MiddlewareSlot;
|
29
|
+
static runtime: import("@teambit/harmony").RuntimeDefinition;
|
30
|
+
constructor(
|
31
|
+
/**
|
32
|
+
* extension config
|
33
|
+
*/
|
34
|
+
config: ExpressConfig,
|
35
|
+
/**
|
36
|
+
* slot for registering graphql modules
|
37
|
+
*/
|
38
|
+
moduleSlot: RouteSlot,
|
39
|
+
/**
|
40
|
+
* logger extension.
|
41
|
+
*/
|
42
|
+
logger: Logger, middlewareSlot: MiddlewareSlot);
|
43
|
+
/**
|
44
|
+
* start an express server.
|
45
|
+
*/
|
46
|
+
listen(port?: number): Promise<Server>;
|
47
|
+
/**
|
48
|
+
* register a new express routes.
|
49
|
+
* route will be added as `/api/${route}`
|
50
|
+
*/
|
51
|
+
register(routes: Route[]): this;
|
52
|
+
/**
|
53
|
+
* register a new middleware into express.
|
54
|
+
*/
|
55
|
+
registerMiddleware(middlewares: MiddlewareManifest[]): this;
|
56
|
+
private createRootRoutes;
|
57
|
+
createApp(expressApp?: Express, options?: {
|
58
|
+
disableBodyParser: true;
|
59
|
+
}): Express;
|
60
|
+
private createRoutes;
|
61
|
+
private verbValidation;
|
62
|
+
private catchErrorsMiddlewares;
|
63
|
+
private bodyParser;
|
64
|
+
static slots: (((registerFn: () => string) => SlotRegistry<Route[]>) | ((registerFn: () => string) => SlotRegistry<MiddlewareManifest[]>))[];
|
65
|
+
static dependencies: import("@teambit/harmony").Aspect[];
|
66
|
+
static defaultConfig: {
|
67
|
+
port: number;
|
68
|
+
namespace: string;
|
69
|
+
loggerIgnorePath: string[];
|
70
|
+
};
|
71
|
+
static provider([loggerFactory]: [LoggerMain], config: ExpressConfig, [routeSlot, middlewareSlot]: [RouteSlot, MiddlewareSlot]): Promise<ExpressMain>;
|
72
|
+
}
|
package/dist/index.d.ts
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
export type { RouteSlot } from './express.main.runtime';
|
2
|
+
export type { Route } from './types';
|
3
|
+
export { Verb } from './types';
|
4
|
+
export type { Request, Response, NextFunction, Middleware } from './types';
|
5
|
+
export type { MiddlewareManifest } from './middleware-manifest';
|
6
|
+
export type { ExpressMain } from './express.main.runtime';
|
7
|
+
export { ExpressAspect } from './express.aspect';
|
@@ -0,0 +1,8 @@
|
|
1
|
+
import * as express from 'express';
|
2
|
+
interface ResponseError {
|
3
|
+
status?: number;
|
4
|
+
message?: string;
|
5
|
+
}
|
6
|
+
export declare const catchErrors: (action: any) => (req: express.Request, res: express.Response, next: express.NextFunction) => any;
|
7
|
+
export declare function errorHandle(err: ResponseError, req: express.Request, res: express.Response, next: express.NextFunction): express.Response<any, Record<string, any>>;
|
8
|
+
export {};
|
@@ -0,0 +1 @@
|
|
1
|
+
export { catchErrors, errorHandle } from './error';
|
@@ -1,5 +1,5 @@
|
|
1
|
-
import * as compositions_0 from '/home/circleci/Library/Caches/Bit/capsules/
|
2
|
-
import * as overview_0 from '/home/circleci/Library/Caches/Bit/capsules/
|
1
|
+
import * as compositions_0 from '/home/circleci/Library/Caches/Bit/capsules/8891be5ad/teambit.harmony_express@0.0.962/dist/express.composition.js';
|
2
|
+
import * as overview_0 from '/home/circleci/Library/Caches/Bit/capsules/8891be5ad/teambit.harmony_express@0.0.962/dist/express.docs.mdx';
|
3
3
|
|
4
4
|
export const compositions = [compositions_0];
|
5
5
|
export const overview = [overview_0];
|
@@ -0,0 +1 @@
|
|
1
|
+
export type { Request } from 'express';
|
@@ -0,0 +1,24 @@
|
|
1
|
+
/// <reference types="express" />
|
2
|
+
import { NextFunction } from './next';
|
3
|
+
import { Request } from './request';
|
4
|
+
import { Response } from './response';
|
5
|
+
/**
|
6
|
+
* define express Middleware
|
7
|
+
*/
|
8
|
+
export type Middleware = (req: Request, res: Response, next: NextFunction) => void | Promise<any>;
|
9
|
+
export declare enum Verb {
|
10
|
+
WRITE = "write",
|
11
|
+
READ = "read"
|
12
|
+
}
|
13
|
+
/**
|
14
|
+
* express new Route
|
15
|
+
*/
|
16
|
+
export interface Route {
|
17
|
+
method: string;
|
18
|
+
route: string | RegExp;
|
19
|
+
disableNamespace?: boolean;
|
20
|
+
verb?: Verb;
|
21
|
+
middlewares: Middleware[];
|
22
|
+
/** route priority if 2 route with the same name default is 0 */
|
23
|
+
priority?: number;
|
24
|
+
}
|
package/package.json
CHANGED
@@ -1,27 +1,27 @@
|
|
1
1
|
{
|
2
2
|
"name": "@teambit/express",
|
3
|
-
"version": "0.0.
|
3
|
+
"version": "0.0.962",
|
4
4
|
"homepage": "https://bit.cloud/teambit/harmony/express",
|
5
5
|
"main": "dist/index.js",
|
6
6
|
"componentId": {
|
7
7
|
"scope": "teambit.harmony",
|
8
8
|
"name": "express",
|
9
|
-
"version": "0.0.
|
9
|
+
"version": "0.0.962"
|
10
10
|
},
|
11
11
|
"dependencies": {
|
12
12
|
"body-parser": "1.19.0",
|
13
13
|
"express": "4.17.1",
|
14
14
|
"lodash": "4.17.21",
|
15
15
|
"@teambit/harmony": "0.4.6",
|
16
|
-
"@teambit/cli": "0.0.
|
17
|
-
"@teambit/logger": "0.0.
|
16
|
+
"@teambit/cli": "0.0.863",
|
17
|
+
"@teambit/logger": "0.0.956"
|
18
18
|
},
|
19
19
|
"devDependencies": {
|
20
20
|
"@types/express": "4.17.13",
|
21
21
|
"@types/lodash": "4.14.165",
|
22
22
|
"@types/mocha": "9.1.0",
|
23
23
|
"chai": "4.3.0",
|
24
|
-
"@teambit/harmony.envs.core-aspect-env": "0.0.
|
24
|
+
"@teambit/harmony.envs.core-aspect-env": "0.0.33"
|
25
25
|
},
|
26
26
|
"peerDependencies": {
|
27
27
|
"react": "^17.0.0 || ^18.0.0",
|
package/tsconfig.json
CHANGED
@@ -20,8 +20,7 @@
|
|
20
20
|
"emitDeclarationOnly": true,
|
21
21
|
"strict": true,
|
22
22
|
"strictPropertyInitialization": false,
|
23
|
-
"noImplicitAny": false
|
24
|
-
"composite": true
|
23
|
+
"noImplicitAny": false
|
25
24
|
},
|
26
25
|
"exclude": [
|
27
26
|
"artifacts",
|
@@ -36,13 +35,5 @@
|
|
36
35
|
"include": [
|
37
36
|
"**/*",
|
38
37
|
"**/*.json"
|
39
|
-
],
|
40
|
-
"references": [
|
41
|
-
{
|
42
|
-
"path": "/home/circleci/Library/Caches/Bit/capsules/8891be5ad3d35bfc38b9cd90c0e05b598a5a55af/teambit.harmony_cli@0.0.861"
|
43
|
-
},
|
44
|
-
{
|
45
|
-
"path": "/home/circleci/Library/Caches/Bit/capsules/8891be5ad3d35bfc38b9cd90c0e05b598a5a55af/teambit.harmony_logger@0.0.954"
|
46
|
-
}
|
47
38
|
]
|
48
39
|
}
|