@teambit/express 0.0.959 → 0.0.961
Sign up to get free protection for your applications and to get access to all the features.
- package/artifacts/__bit_junit.xml +1 -1
- package/artifacts/preview/teambit_harmony_express-preview.js +1 -1
- package/artifacts/schema.json +60 -17
- 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-1712719054377.js → preview-1712822929999.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
@@ -1,4 +1,4 @@
|
|
1
1
|
<?xml version="1.0" encoding="UTF-8"?>
|
2
2
|
<testsuites tests="0" failures="0" errors="0" skipped="0">
|
3
|
-
<testsuite name="teambit.harmony/express@0.0.
|
3
|
+
<testsuite name="teambit.harmony/express@0.0.961" tests="0" failures="0" errors="0" skipped="0"/>
|
4
4
|
</testsuites>
|
@@ -1 +1 @@
|
|
1
|
-
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports["teambit.harmony/express-preview"]=t():e["teambit.harmony/express-preview"]=t()}(self,(()=>(()=>{"use strict";var e={
|
1
|
+
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports["teambit.harmony/express-preview"]=t():e["teambit.harmony/express-preview"]=t()}(self,(()=>(()=>{"use strict";var e={73039:(e,t,o)=>{var r={id:"teambit.harmony/express@0.0.961",homepage:"https://bit.cloud/teambit/harmony/express",exported:!0};function n(){const e=i(o(41594));return n=function(){return e},e}function i(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(t,"__esModule",{value:!0}),t.Logo=void 0,n.__bit_component=r,i.__bit_component=r;const s=()=>n().default.createElement("div",{style:{height:"100%",display:"flex",justifyContent:"center"}},n().default.createElement("img",{style:{width:70},src:"https://static.bit.dev/extensions-icons/express.svg"}));s.__bit_component=r,t.Logo=s},41594:e=>{e.exports=React}},t={};function o(r){var n=t[r];if(void 0!==n)return n.exports;var i=t[r]={exports:{}};return e[r](i,i.exports,o),i.exports}o.d=(e,t)=>{for(var r in t)o.o(t,r)&&!o.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},o.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),o.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var r={};return(()=>{o.r(r),o.d(r,{compositions:()=>u,compositions_metadata:()=>l,overview:()=>f});var e={};o.r(e),o.d(e,{default:()=>d});var t=o(73039);o(41594);const n=MdxJsReact,i=TeambitMdxUiMdxScopeContext;var s=["components"];function p(){return p=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var o=arguments[t];for(var r in o)Object.prototype.hasOwnProperty.call(o,r)&&(e[r]=o[r])}return e},p.apply(this,arguments)}var a={},c="wrapper";function d(e){var t=e.components,o=function(e,t){if(null==e)return{};var o,r,n=function(e,t){if(null==e)return{};var o,r,n={},i=Object.keys(e);for(r=0;r<i.length;r++)o=i[r],t.indexOf(o)>=0||(n[o]=e[o]);return n}(e,t);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(r=0;r<i.length;r++)o=i[r],t.indexOf(o)>=0||Object.prototype.propertyIsEnumerable.call(e,o)&&(n[o]=e[o])}return n}(e,s);return(0,n.mdx)(c,p({},a,o,{components:t,mdxType:"MDXLayout"}),(0,n.mdx)(i.MDXScopeProvider,{components:{},mdxType:"MDXScopeProvider"}))}d.isMDXComponent=!0;const u=[t],f=[e],l={compositions:[{displayName:"Logo",identifier:"Logo"}]}})(),r})()));
|
package/artifacts/schema.json
CHANGED
@@ -30,6 +30,11 @@
|
|
30
30
|
"character": 25
|
31
31
|
},
|
32
32
|
"name": "SlotRegistry",
|
33
|
+
"componentId": {
|
34
|
+
"scope": "teambit.harmony",
|
35
|
+
"name": "harmony",
|
36
|
+
"version": "0.4.6"
|
37
|
+
},
|
33
38
|
"typeArgs": [
|
34
39
|
{
|
35
40
|
"__schema": "TypeArraySchema",
|
@@ -572,7 +577,8 @@
|
|
572
577
|
"line": 30,
|
573
578
|
"character": 22
|
574
579
|
},
|
575
|
-
"name": "ExpressConfig"
|
580
|
+
"name": "ExpressConfig",
|
581
|
+
"internalFilePath": "express.main.runtime.ts"
|
576
582
|
},
|
577
583
|
"isOptional": false,
|
578
584
|
"isSpread": false
|
@@ -612,7 +618,11 @@
|
|
612
618
|
"line": 40,
|
613
619
|
"character": 22
|
614
620
|
},
|
615
|
-
"name": "Logger"
|
621
|
+
"name": "Logger",
|
622
|
+
"componentId": {
|
623
|
+
"scope": "teambit.harmony",
|
624
|
+
"name": "logger"
|
625
|
+
}
|
616
626
|
},
|
617
627
|
"isOptional": false,
|
618
628
|
"isSpread": false
|
@@ -632,7 +642,8 @@
|
|
632
642
|
"line": 42,
|
633
643
|
"character": 30
|
634
644
|
},
|
635
|
-
"name": "MiddlewareSlot"
|
645
|
+
"name": "MiddlewareSlot",
|
646
|
+
"internalFilePath": "express.main.runtime.ts"
|
636
647
|
},
|
637
648
|
"isOptional": false,
|
638
649
|
"isSpread": false
|
@@ -706,7 +717,8 @@
|
|
706
717
|
"line": 48,
|
707
718
|
"character": 40
|
708
719
|
},
|
709
|
-
"name": "Server"
|
720
|
+
"name": "Server",
|
721
|
+
"packageName": "http"
|
710
722
|
}
|
711
723
|
]
|
712
724
|
},
|
@@ -859,7 +871,8 @@
|
|
859
871
|
"line": 85,
|
860
872
|
"character": 26
|
861
873
|
},
|
862
|
-
"name": "Express"
|
874
|
+
"name": "Express",
|
875
|
+
"packageName": "express"
|
863
876
|
},
|
864
877
|
"isOptional": true,
|
865
878
|
"isSpread": false
|
@@ -1014,7 +1027,11 @@
|
|
1014
1027
|
"line": 165,
|
1015
1028
|
"character": 23
|
1016
1029
|
},
|
1017
|
-
"name": "LoggerMain"
|
1030
|
+
"name": "LoggerMain",
|
1031
|
+
"componentId": {
|
1032
|
+
"scope": "teambit.harmony",
|
1033
|
+
"name": "logger"
|
1034
|
+
}
|
1018
1035
|
}
|
1019
1036
|
]
|
1020
1037
|
},
|
@@ -1036,7 +1053,8 @@
|
|
1036
1053
|
"line": 166,
|
1037
1054
|
"character": 13
|
1038
1055
|
},
|
1039
|
-
"name": "ExpressConfig"
|
1056
|
+
"name": "ExpressConfig",
|
1057
|
+
"internalFilePath": "express.main.runtime.ts"
|
1040
1058
|
},
|
1041
1059
|
"isOptional": false,
|
1042
1060
|
"isSpread": false
|
@@ -1073,7 +1091,8 @@
|
|
1073
1091
|
"line": 167,
|
1074
1092
|
"character": 46
|
1075
1093
|
},
|
1076
|
-
"name": "MiddlewareSlot"
|
1094
|
+
"name": "MiddlewareSlot",
|
1095
|
+
"internalFilePath": "express.main.runtime.ts"
|
1077
1096
|
}
|
1078
1097
|
]
|
1079
1098
|
},
|
@@ -1242,6 +1261,11 @@
|
|
1242
1261
|
"character": 30
|
1243
1262
|
},
|
1244
1263
|
"name": "SlotRegistry",
|
1264
|
+
"componentId": {
|
1265
|
+
"scope": "teambit.harmony",
|
1266
|
+
"name": "harmony",
|
1267
|
+
"version": "0.4.6"
|
1268
|
+
},
|
1245
1269
|
"typeArgs": [
|
1246
1270
|
{
|
1247
1271
|
"__schema": "TypeArraySchema",
|
@@ -1280,6 +1304,11 @@
|
|
1280
1304
|
"character": 25
|
1281
1305
|
},
|
1282
1306
|
"name": "SlotRegistry",
|
1307
|
+
"componentId": {
|
1308
|
+
"scope": "teambit.harmony",
|
1309
|
+
"name": "harmony",
|
1310
|
+
"version": "0.4.6"
|
1311
|
+
},
|
1283
1312
|
"typeArgs": [
|
1284
1313
|
{
|
1285
1314
|
"__schema": "TypeArraySchema",
|
@@ -1357,7 +1386,8 @@
|
|
1357
1386
|
"line": 30,
|
1358
1387
|
"character": 22
|
1359
1388
|
},
|
1360
|
-
"name": "ExpressConfig"
|
1389
|
+
"name": "ExpressConfig",
|
1390
|
+
"internalFilePath": "express.main.runtime.ts"
|
1361
1391
|
},
|
1362
1392
|
"isOptional": false,
|
1363
1393
|
"isSpread": false
|
@@ -1397,7 +1427,11 @@
|
|
1397
1427
|
"line": 40,
|
1398
1428
|
"character": 22
|
1399
1429
|
},
|
1400
|
-
"name": "Logger"
|
1430
|
+
"name": "Logger",
|
1431
|
+
"componentId": {
|
1432
|
+
"scope": "teambit.harmony",
|
1433
|
+
"name": "logger"
|
1434
|
+
}
|
1401
1435
|
},
|
1402
1436
|
"isOptional": false,
|
1403
1437
|
"isSpread": false
|
@@ -1417,7 +1451,8 @@
|
|
1417
1451
|
"line": 42,
|
1418
1452
|
"character": 30
|
1419
1453
|
},
|
1420
|
-
"name": "MiddlewareSlot"
|
1454
|
+
"name": "MiddlewareSlot",
|
1455
|
+
"internalFilePath": "express.main.runtime.ts"
|
1421
1456
|
},
|
1422
1457
|
"isOptional": false,
|
1423
1458
|
"isSpread": false
|
@@ -1491,7 +1526,8 @@
|
|
1491
1526
|
"line": 48,
|
1492
1527
|
"character": 40
|
1493
1528
|
},
|
1494
|
-
"name": "Server"
|
1529
|
+
"name": "Server",
|
1530
|
+
"packageName": "http"
|
1495
1531
|
}
|
1496
1532
|
]
|
1497
1533
|
},
|
@@ -1644,7 +1680,8 @@
|
|
1644
1680
|
"line": 85,
|
1645
1681
|
"character": 26
|
1646
1682
|
},
|
1647
|
-
"name": "Express"
|
1683
|
+
"name": "Express",
|
1684
|
+
"packageName": "express"
|
1648
1685
|
},
|
1649
1686
|
"isOptional": true,
|
1650
1687
|
"isSpread": false
|
@@ -1799,7 +1836,11 @@
|
|
1799
1836
|
"line": 165,
|
1800
1837
|
"character": 23
|
1801
1838
|
},
|
1802
|
-
"name": "LoggerMain"
|
1839
|
+
"name": "LoggerMain",
|
1840
|
+
"componentId": {
|
1841
|
+
"scope": "teambit.harmony",
|
1842
|
+
"name": "logger"
|
1843
|
+
}
|
1803
1844
|
}
|
1804
1845
|
]
|
1805
1846
|
},
|
@@ -1821,7 +1862,8 @@
|
|
1821
1862
|
"line": 166,
|
1822
1863
|
"character": 13
|
1823
1864
|
},
|
1824
|
-
"name": "ExpressConfig"
|
1865
|
+
"name": "ExpressConfig",
|
1866
|
+
"internalFilePath": "express.main.runtime.ts"
|
1825
1867
|
},
|
1826
1868
|
"isOptional": false,
|
1827
1869
|
"isSpread": false
|
@@ -1858,7 +1900,8 @@
|
|
1858
1900
|
"line": 167,
|
1859
1901
|
"character": 46
|
1860
1902
|
},
|
1861
|
-
"name": "MiddlewareSlot"
|
1903
|
+
"name": "MiddlewareSlot",
|
1904
|
+
"internalFilePath": "express.main.runtime.ts"
|
1862
1905
|
}
|
1863
1906
|
]
|
1864
1907
|
},
|
@@ -1939,7 +1982,7 @@
|
|
1939
1982
|
"componentId": {
|
1940
1983
|
"scope": "teambit.harmony",
|
1941
1984
|
"name": "express",
|
1942
|
-
"version": "0.0.
|
1985
|
+
"version": "0.0.961"
|
1943
1986
|
},
|
1944
1987
|
"taggedModuleExports": []
|
1945
1988
|
}
|
@@ -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/8891be5ad3d35bfc38b9cd90c0e05b598a5a55af/teambit.harmony_express@0.0.
|
2
|
-
import * as overview_0 from '/home/circleci/Library/Caches/Bit/capsules/8891be5ad3d35bfc38b9cd90c0e05b598a5a55af/teambit.harmony_express@0.0.
|
1
|
+
import * as compositions_0 from '/home/circleci/Library/Caches/Bit/capsules/8891be5ad3d35bfc38b9cd90c0e05b598a5a55af/teambit.harmony_express@0.0.961/dist/express.composition.js';
|
2
|
+
import * as overview_0 from '/home/circleci/Library/Caches/Bit/capsules/8891be5ad3d35bfc38b9cd90c0e05b598a5a55af/teambit.harmony_express@0.0.961/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.961",
|
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.961"
|
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.862",
|
17
|
+
"@teambit/logger": "0.0.955"
|
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.860"
|
43
|
-
},
|
44
|
-
{
|
45
|
-
"path": "/home/circleci/Library/Caches/Bit/capsules/8891be5ad3d35bfc38b9cd90c0e05b598a5a55af/teambit.harmony_logger@0.0.953"
|
46
|
-
}
|
47
38
|
]
|
48
39
|
}
|