@fy-stack/fullstack-construct 0.0.128 → 0.0.129
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/README.md +61 -4
- package/dist/lib/fullstack-construct.d.ts +4 -0
- package/dist/lib/fullstack-construct.d.ts.map +1 -1
- package/dist/lib/fullstack-construct.js +17 -3
- package/dist/lib/types.d.ts +3 -1
- package/dist/lib/types.d.ts.map +1 -1
- package/dist/lib/types.js +1 -0
- package/package.json +10 -10
package/README.md
CHANGED
|
@@ -1,7 +1,64 @@
|
|
|
1
|
-
#
|
|
1
|
+
# Fullstack Construct Documentation
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
## `FullstackConstruct`
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
### Example
|
|
6
|
+
```typescript
|
|
7
|
+
import {
|
|
8
|
+
AppGrant,
|
|
9
|
+
AppType,
|
|
10
|
+
FullStackConstruct,
|
|
11
|
+
} from '@fy-stack/fullstack-construct';
|
|
6
12
|
|
|
7
|
-
|
|
13
|
+
new FullStackConstruct(this, 'FullstackApp', {
|
|
14
|
+
appId: `unique-app-id`,
|
|
15
|
+
apps: {
|
|
16
|
+
api: {
|
|
17
|
+
type: AppType.NODE_API,
|
|
18
|
+
output: process.cwd() + '/dist/apps/api',
|
|
19
|
+
buildParams: { command: 'node main.js' },
|
|
20
|
+
attachment: { secrets: true },
|
|
21
|
+
grant: [AppGrant.EVENT, AppGrant.SECRETS],
|
|
22
|
+
},
|
|
23
|
+
eventHandler: {
|
|
24
|
+
type: AppType.NODE_APP,
|
|
25
|
+
output: process.cwd() + '/dist/apps/event-handler',
|
|
26
|
+
buildParams: { handler: 'main.handler' },
|
|
27
|
+
attachment: { secrets: true, queue: { batchSize: 10 } },
|
|
28
|
+
grant: [AppGrant.SECRETS],
|
|
29
|
+
},
|
|
30
|
+
web: {
|
|
31
|
+
type: AppType.NEXT_PAGE_EXPORT,
|
|
32
|
+
output: process.cwd() + '/dist/apps/web',
|
|
33
|
+
},
|
|
34
|
+
},
|
|
35
|
+
secrets: {
|
|
36
|
+
SOME_OTHER_ENV: "envValue"
|
|
37
|
+
},
|
|
38
|
+
events: {
|
|
39
|
+
messages: [
|
|
40
|
+
{ messages: [EventType.DAILY_SPOOL], $resource: 'eventHandler' },
|
|
41
|
+
],
|
|
42
|
+
cron: [
|
|
43
|
+
{
|
|
44
|
+
messages: [EventType.DAILY_SPOOL],
|
|
45
|
+
cron: { hour: '0', minute: '0' },
|
|
46
|
+
},
|
|
47
|
+
],
|
|
48
|
+
},
|
|
49
|
+
cdn: {
|
|
50
|
+
routes: {
|
|
51
|
+
'/*': { $resource: 'web' },
|
|
52
|
+
},
|
|
53
|
+
domains: [
|
|
54
|
+
{ domain: 'example.com', records: ['*', 'www'] },
|
|
55
|
+
{ domain: 'example.com.ng', records: ['*', 'www'] },
|
|
56
|
+
],
|
|
57
|
+
},
|
|
58
|
+
api: {
|
|
59
|
+
routes: {
|
|
60
|
+
'/*': { $resource: 'api' },
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
})
|
|
64
|
+
```
|
|
@@ -8,9 +8,13 @@ import { SecretsConstruct } from '@fy-stack/secret-construct';
|
|
|
8
8
|
import { StorageConstruct } from '@fy-stack/storage-construct';
|
|
9
9
|
import { Construct } from 'constructs';
|
|
10
10
|
import { FullStackConstructProps } from './types';
|
|
11
|
+
/**
|
|
12
|
+
*
|
|
13
|
+
*/
|
|
11
14
|
export declare class FullStackConstruct extends Construct {
|
|
12
15
|
auth?: AuthConstruct;
|
|
13
16
|
storage?: StorageConstruct;
|
|
17
|
+
storagePolicy?: string;
|
|
14
18
|
database?: DatabaseConstruct;
|
|
15
19
|
event?: EventConstruct;
|
|
16
20
|
apps?: Record<string, AppConstruct>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fullstack-construct.d.ts","sourceRoot":"","sources":["../../src/lib/fullstack-construct.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE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
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.FullStackConstruct = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
4
5
|
const apigateway_construct_1 = require("@fy-stack/apigateway-construct");
|
|
5
6
|
const app_construct_1 = require("@fy-stack/app-construct");
|
|
6
7
|
const auth_construct_1 = require("@fy-stack/auth-construct");
|
|
@@ -9,6 +10,7 @@ const database_construct_1 = require("@fy-stack/database-construct");
|
|
|
9
10
|
const event_construct_1 = require("@fy-stack/event-construct");
|
|
10
11
|
const secret_construct_1 = require("@fy-stack/secret-construct");
|
|
11
12
|
const storage_construct_1 = require("@fy-stack/storage-construct");
|
|
13
|
+
const ec2 = tslib_1.__importStar(require("aws-cdk-lib/aws-ec2"));
|
|
12
14
|
const constructs_1 = require("constructs");
|
|
13
15
|
const types_1 = require("./types");
|
|
14
16
|
const AppBuilds = {
|
|
@@ -17,10 +19,15 @@ const AppBuilds = {
|
|
|
17
19
|
[types_1.AppType.NODE_APP]: app_construct_1.NodeAppConstruct,
|
|
18
20
|
[types_1.AppType.NODE_API]: app_construct_1.NodeApiConstruct,
|
|
19
21
|
[types_1.AppType.IMAGE_APP]: app_construct_1.ImageAppConstruct,
|
|
22
|
+
[types_1.AppType.STATIC_WEBSITE]: app_construct_1.StaticWebsiteConstruct,
|
|
20
23
|
};
|
|
24
|
+
/**
|
|
25
|
+
*
|
|
26
|
+
*/
|
|
21
27
|
class FullStackConstruct extends constructs_1.Construct {
|
|
22
28
|
auth;
|
|
23
29
|
storage;
|
|
30
|
+
storagePolicy;
|
|
24
31
|
database;
|
|
25
32
|
event;
|
|
26
33
|
apps;
|
|
@@ -29,6 +36,7 @@ class FullStackConstruct extends constructs_1.Construct {
|
|
|
29
36
|
secret;
|
|
30
37
|
constructor(scope, id, props) {
|
|
31
38
|
super(scope, id);
|
|
39
|
+
const vpc = ec2.Vpc.fromLookup(this, 'VPC', props.vpcId ? { vpcId: props.vpcId } : { isDefault: true });
|
|
32
40
|
if (props.auth) {
|
|
33
41
|
this.auth = new auth_construct_1.AuthConstruct(this, props.appId + 'AuthConstruct', {
|
|
34
42
|
groups: props.auth.groups,
|
|
@@ -39,7 +47,10 @@ class FullStackConstruct extends constructs_1.Construct {
|
|
|
39
47
|
}
|
|
40
48
|
/* create secrets for test or production environments */
|
|
41
49
|
if (props.database) {
|
|
42
|
-
this.database = new database_construct_1.DatabaseConstruct(this, 'DatabaseConstruct',
|
|
50
|
+
this.database = new database_construct_1.DatabaseConstruct(this, 'DatabaseConstruct', {
|
|
51
|
+
...props.database,
|
|
52
|
+
vpcId: vpc.vpcId,
|
|
53
|
+
});
|
|
43
54
|
}
|
|
44
55
|
if (props.apps) {
|
|
45
56
|
const apps = {};
|
|
@@ -91,6 +102,9 @@ class FullStackConstruct extends constructs_1.Construct {
|
|
|
91
102
|
secrets: this.secret,
|
|
92
103
|
event: this.event,
|
|
93
104
|
};
|
|
105
|
+
if (this.storage && this.cdn) {
|
|
106
|
+
this.storagePolicy = JSON.stringify(this.storage.cloudfrontPolicy(this.cdn.distribution.distributionId));
|
|
107
|
+
}
|
|
94
108
|
for (const i in props.apps) {
|
|
95
109
|
const attachments = Object.entries(props.apps[i]?.attachment ?? {})
|
|
96
110
|
.map(([key]) => [key, resources[key]])
|
|
@@ -98,9 +112,9 @@ class FullStackConstruct extends constructs_1.Construct {
|
|
|
98
112
|
if (attachments.length) {
|
|
99
113
|
this.apps?.[i]?.attach(Object.fromEntries(attachments));
|
|
100
114
|
}
|
|
101
|
-
const grants =
|
|
115
|
+
const grants = props.apps[i]?.grant
|
|
102
116
|
?.map((val) => resources[val])
|
|
103
|
-
.filter((v) => !!v) ?? []
|
|
117
|
+
.filter((v) => !!v) ?? [];
|
|
104
118
|
if (grants.length) {
|
|
105
119
|
this.apps?.[i]?.grant(...grants);
|
|
106
120
|
}
|
package/dist/lib/types.d.ts
CHANGED
|
@@ -7,7 +7,8 @@ export declare enum AppType {
|
|
|
7
7
|
NODE_API = "nestApi",
|
|
8
8
|
IMAGE_APP = "imageApp",
|
|
9
9
|
NEXT_APP_ROUTER = "nextAppRouter",
|
|
10
|
-
NEXT_PAGE_EXPORT = "nextPageExport"
|
|
10
|
+
NEXT_PAGE_EXPORT = "nextPageExport",
|
|
11
|
+
STATIC_WEBSITE = "staticWebsite"
|
|
11
12
|
}
|
|
12
13
|
export type AppAttachment = {
|
|
13
14
|
auth?: boolean;
|
|
@@ -40,6 +41,7 @@ export type AppCron = {
|
|
|
40
41
|
cron: events.CronOptions;
|
|
41
42
|
};
|
|
42
43
|
export type FullStackConstructProps = {
|
|
44
|
+
vpcId?: string;
|
|
43
45
|
appId: string;
|
|
44
46
|
auth?: {
|
|
45
47
|
groups?: string[];
|
package/dist/lib/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/lib/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,sBAAsB,EAAE,MAAM,8BAA8B,CAAC;AACtE,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAC9C,OAAO,KAAK,MAAM,MAAM,wBAAwB,CAAC;AACjD,OAAO,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAE5D,oBAAY,OAAO;IACjB,QAAQ,YAAY;IACpB,QAAQ,YAAY;IACpB,SAAS,aAAa;IACtB,eAAe,kBAAkB;IACjC,gBAAgB,mBAAmB;
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/lib/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,sBAAsB,EAAE,MAAM,8BAA8B,CAAC;AACtE,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAC9C,OAAO,KAAK,MAAM,MAAM,wBAAwB,CAAC;AACjD,OAAO,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAE5D,oBAAY,OAAO;IACjB,QAAQ,YAAY;IACpB,QAAQ,YAAY;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E,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IAC3B,MAAM,CAAC,EAAE;QACP,QAAQ,CAAC,EAAE,UAAU,EAAE,CAAC;QACxB,IAAI,CAAC,EAAE,OAAO,EAAE,CAAC;KAClB,CAAC;IACF,GAAG,CAAC,EAAE,IAAI,CAAC,iBAAiB,EAAE,WAAW,CAAC,CAAC;IAC3C,GAAG,CAAC,EAAE;QAAE,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,WAAW,CAAC,CAAA;KAAE,CAAC;IAC9C,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC,CAAC;CAC9C,CAAC"}
|
package/dist/lib/types.js
CHANGED
|
@@ -8,6 +8,7 @@ var AppType;
|
|
|
8
8
|
AppType["IMAGE_APP"] = "imageApp";
|
|
9
9
|
AppType["NEXT_APP_ROUTER"] = "nextAppRouter";
|
|
10
10
|
AppType["NEXT_PAGE_EXPORT"] = "nextPageExport";
|
|
11
|
+
AppType["STATIC_WEBSITE"] = "staticWebsite";
|
|
11
12
|
})(AppType || (exports.AppType = AppType = {}));
|
|
12
13
|
var AppGrant;
|
|
13
14
|
(function (AppGrant) {
|
package/package.json
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fy-stack/fullstack-construct",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.129",
|
|
4
4
|
"dependencies": {
|
|
5
5
|
"tslib": "^2.3.0",
|
|
6
|
-
"@fy-stack/auth-construct": "0.0.
|
|
7
|
-
"@fy-stack/storage-construct": "0.0.
|
|
8
|
-
"@fy-stack/database-construct": "0.0.
|
|
9
|
-
"@fy-stack/event-construct": "0.0.
|
|
10
|
-
"@fy-stack/secret-construct": "0.0.
|
|
11
|
-
"@fy-stack/cdn-construct": "0.0.
|
|
12
|
-
"@fy-stack/apigateway-construct": "0.0.
|
|
13
|
-
"@fy-stack/types": "0.0.
|
|
14
|
-
"@fy-stack/app-construct": "0.0.
|
|
6
|
+
"@fy-stack/auth-construct": "0.0.129",
|
|
7
|
+
"@fy-stack/storage-construct": "0.0.129",
|
|
8
|
+
"@fy-stack/database-construct": "0.0.129",
|
|
9
|
+
"@fy-stack/event-construct": "0.0.129",
|
|
10
|
+
"@fy-stack/secret-construct": "0.0.129",
|
|
11
|
+
"@fy-stack/cdn-construct": "0.0.129",
|
|
12
|
+
"@fy-stack/apigateway-construct": "0.0.129",
|
|
13
|
+
"@fy-stack/types": "0.0.129",
|
|
14
|
+
"@fy-stack/app-construct": "0.0.129"
|
|
15
15
|
},
|
|
16
16
|
"peerDependencies": {
|
|
17
17
|
"aws-cdk-lib": "2.166.0",
|