@fy-stack/fullstack-construct 0.0.1
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 +7 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +9 -0
- package/dist/lib/fullstack-construct.d.ts +18 -0
- package/dist/lib/fullstack-construct.d.ts.map +1 -0
- package/dist/lib/fullstack-construct.js +104 -0
- package/dist/lib/types.d.ts +67 -0
- package/dist/lib/types.d.ts.map +1 -0
- package/dist/lib/types.js +22 -0
- package/package.json +28 -0
package/README.md
ADDED
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,2BAA2B,CAAC;AAC/D,OAAO,EAAE,QAAQ,EAAE,KAAK,aAAa,EAAE,eAAe,EAAE,OAAO,EAAE,MAAM,aAAa,CAAA"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.AppType = exports.AppResourceType = exports.AppGrant = exports.FullStackConstruct = void 0;
|
|
4
|
+
var fullstack_construct_1 = require("./lib/fullstack-construct");
|
|
5
|
+
Object.defineProperty(exports, "FullStackConstruct", { enumerable: true, get: function () { return fullstack_construct_1.FullStackConstruct; } });
|
|
6
|
+
var types_1 = require("./lib/types");
|
|
7
|
+
Object.defineProperty(exports, "AppGrant", { enumerable: true, get: function () { return types_1.AppGrant; } });
|
|
8
|
+
Object.defineProperty(exports, "AppResourceType", { enumerable: true, get: function () { return types_1.AppResourceType; } });
|
|
9
|
+
Object.defineProperty(exports, "AppType", { enumerable: true, get: function () { return types_1.AppType; } });
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { Construct } from 'constructs';
|
|
2
|
+
import { FullStackConstructProps } from './types';
|
|
3
|
+
import { AuthConstruct } from '@fy-stack/auth-construct';
|
|
4
|
+
import { StorageConstruct } from '@fy-stack/storage-construct';
|
|
5
|
+
import { DatabaseConstruct } from '@fy-stack/database-construct';
|
|
6
|
+
import { EventConstruct } from '@fy-stack/event-construct';
|
|
7
|
+
import { CDNConstruct } from '@fy-stack/cdn-construct';
|
|
8
|
+
import { type AppConstruct } from '@fy-stack/app-construct';
|
|
9
|
+
export declare class FullStackConstruct extends Construct {
|
|
10
|
+
auth?: AuthConstruct;
|
|
11
|
+
storage?: StorageConstruct;
|
|
12
|
+
database?: DatabaseConstruct;
|
|
13
|
+
event?: EventConstruct;
|
|
14
|
+
apps?: Record<string, AppConstruct>;
|
|
15
|
+
cdn?: CDNConstruct;
|
|
16
|
+
constructor(scope: Construct, id: string, props: FullStackConstructProps);
|
|
17
|
+
}
|
|
18
|
+
//# sourceMappingURL=fullstack-construct.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fullstack-construct.d.ts","sourceRoot":"","sources":["../../src/lib/fullstack-construct.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAEvC,OAAO,EAAW,uBAAuB,EAAE,MAAM,SAAS,CAAC;AAC3D,OAAO,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AACzD,OAAO,EAAE,gBAAgB,EAAE,MAAM,6BAA6B,CAAC;AAC/D,OAAO,EAAE,iBAAiB,EAAE,MAAM,8BAA8B,CAAC;AACjE,OAAO,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAC;AAE3D,OAAO,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AACvD,OAAO,EAIL,KAAK,YAAY,EAClB,MAAM,yBAAyB,CAAC;AAQjC,qBAAa,kBAAmB,SAAQ,SAAS;IACxC,IAAI,CAAC,EAAE,aAAa,CAAC;IACrB,OAAO,CAAC,EAAE,gBAAgB,CAAC;IAC3B,QAAQ,CAAC,EAAE,iBAAiB,CAAC;IAC7B,KAAK,CAAC,EAAE,cAAc,CAAC;IACvB,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,YAAY,CAAC,CAAC;IACpC,GAAG,CAAC,EAAE,YAAY,CAAC;gBAEd,KAAK,EAAE,SAAS,EAAE,EAAE,EAAE,MAAM,EAAE,KAAK,EAAE,uBAAuB;CA4GzE"}
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.FullStackConstruct = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const cdk = tslib_1.__importStar(require("aws-cdk-lib"));
|
|
6
|
+
const constructs_1 = require("constructs");
|
|
7
|
+
const types_1 = require("./types");
|
|
8
|
+
const auth_construct_1 = require("@fy-stack/auth-construct");
|
|
9
|
+
const storage_construct_1 = require("@fy-stack/storage-construct");
|
|
10
|
+
const database_construct_1 = require("@fy-stack/database-construct");
|
|
11
|
+
const event_construct_1 = require("@fy-stack/event-construct");
|
|
12
|
+
const secret_construct_1 = require("@fy-stack/secret-construct");
|
|
13
|
+
const cdn_construct_1 = require("@fy-stack/cdn-construct");
|
|
14
|
+
const app_construct_1 = require("@fy-stack/app-construct");
|
|
15
|
+
const AppBuilds = {
|
|
16
|
+
[types_1.AppType.NEXT_APP_ROUTER]: app_construct_1.NextAppRouterConstruct,
|
|
17
|
+
[types_1.AppType.NEST]: app_construct_1.NestConstruct,
|
|
18
|
+
[types_1.AppType.NEST_API]: app_construct_1.NestApiConstruct,
|
|
19
|
+
};
|
|
20
|
+
class FullStackConstruct extends constructs_1.Construct {
|
|
21
|
+
auth;
|
|
22
|
+
storage;
|
|
23
|
+
database;
|
|
24
|
+
event;
|
|
25
|
+
apps;
|
|
26
|
+
cdn;
|
|
27
|
+
constructor(scope, id, props) {
|
|
28
|
+
super(scope, id);
|
|
29
|
+
if (props.auth) {
|
|
30
|
+
this.auth = new auth_construct_1.AuthConstruct(this, props.appId + 'AuthStack', {
|
|
31
|
+
groups: props.auth.groups,
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
if (props.storage) {
|
|
35
|
+
this.storage = new storage_construct_1.StorageConstruct(this, 'StorageStack', props.storage);
|
|
36
|
+
}
|
|
37
|
+
/* create secrets for test or production environments */
|
|
38
|
+
if (props.database) {
|
|
39
|
+
this.database = new database_construct_1.DatabaseConstruct(this, 'DatabaseStack');
|
|
40
|
+
new cdk.CfnOutput(this, 'Database Secrets', {
|
|
41
|
+
key: 'dbSecrets',
|
|
42
|
+
value: this.database.dbSecrets.secretName,
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
if (props.apps) {
|
|
46
|
+
const apps = {};
|
|
47
|
+
Object.assign(apps, Object.fromEntries(Object.entries(props.apps).map(([key, app]) => {
|
|
48
|
+
return [
|
|
49
|
+
key,
|
|
50
|
+
new AppBuilds[app.type](this, `${key}App`, {
|
|
51
|
+
queue: app.attachment?.queue,
|
|
52
|
+
output: app.output,
|
|
53
|
+
buildPaths: AppBuilds[app.type].clean(app.output, key, app.command),
|
|
54
|
+
}),
|
|
55
|
+
];
|
|
56
|
+
})));
|
|
57
|
+
this.apps = apps;
|
|
58
|
+
}
|
|
59
|
+
if (props.events) {
|
|
60
|
+
this.event = new event_construct_1.EventConstruct(this, 'EventStack', {
|
|
61
|
+
resources: this.apps,
|
|
62
|
+
events: props.events,
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
const secret = new secret_construct_1.SecretsConstruct(this, 'SecretsStack', {
|
|
66
|
+
resources: {
|
|
67
|
+
auth: this.auth,
|
|
68
|
+
database: this.database,
|
|
69
|
+
storage: this.storage,
|
|
70
|
+
event: this.event,
|
|
71
|
+
},
|
|
72
|
+
secrets: props.secrets,
|
|
73
|
+
});
|
|
74
|
+
if (props.cdn) {
|
|
75
|
+
this.cdn = new cdn_construct_1.CDNConstruct(this, 'CDNStack', {
|
|
76
|
+
routes: props.cdn.routes,
|
|
77
|
+
apps: this.apps,
|
|
78
|
+
resources: { uploads: this.storage },
|
|
79
|
+
});
|
|
80
|
+
new cdk.CfnOutput(this, 'App Url', {
|
|
81
|
+
key: 'appUrl',
|
|
82
|
+
value: 'https://' + this.cdn.distribution.domainName,
|
|
83
|
+
});
|
|
84
|
+
}
|
|
85
|
+
const resources = {
|
|
86
|
+
storage: this.storage,
|
|
87
|
+
database: this.database,
|
|
88
|
+
auth: this.auth,
|
|
89
|
+
};
|
|
90
|
+
for (const i in props.apps) {
|
|
91
|
+
this.apps?.[i]?.attach(Object.fromEntries(Object.entries(props.apps[i]?.attachment ?? {})
|
|
92
|
+
.map(([key]) => [key, resources[key]])
|
|
93
|
+
.filter((v) => !!v)));
|
|
94
|
+
this.apps?.[i]?.grant(...(props.apps[i]?.grant
|
|
95
|
+
?.map(val => resources[val])
|
|
96
|
+
.filter((v) => !!v) ?? []));
|
|
97
|
+
}
|
|
98
|
+
new cdk.CfnOutput(this, 'App Secrets', {
|
|
99
|
+
key: 'appSecrets',
|
|
100
|
+
value: secret.secrets.secretName,
|
|
101
|
+
});
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
exports.FullStackConstruct = FullStackConstruct;
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import * as events from 'aws-cdk-lib/aws-events';
|
|
2
|
+
export declare enum AppType {
|
|
3
|
+
NEST = "nest",
|
|
4
|
+
NEST_API = "nestApi",
|
|
5
|
+
NEXT_APP_ROUTER = "nextAppRouter"
|
|
6
|
+
}
|
|
7
|
+
export type AppAttachment = {
|
|
8
|
+
auth?: boolean;
|
|
9
|
+
storage?: boolean;
|
|
10
|
+
database?: boolean;
|
|
11
|
+
secrets?: boolean;
|
|
12
|
+
queue?: {
|
|
13
|
+
batchSize?: number;
|
|
14
|
+
};
|
|
15
|
+
};
|
|
16
|
+
export declare enum AppGrant {
|
|
17
|
+
AUTH = "auth",
|
|
18
|
+
STORAGE = "storage",
|
|
19
|
+
DATABASE = "database",
|
|
20
|
+
SECRETS = "secrets",
|
|
21
|
+
EVENT = "event"
|
|
22
|
+
}
|
|
23
|
+
export type App = {
|
|
24
|
+
type: AppType;
|
|
25
|
+
output: string;
|
|
26
|
+
attachment?: AppAttachment;
|
|
27
|
+
grant?: AppGrant[];
|
|
28
|
+
command: string;
|
|
29
|
+
};
|
|
30
|
+
export declare enum AppResourceType {
|
|
31
|
+
UPLOADS = "uploads",
|
|
32
|
+
AUTH = "auth"
|
|
33
|
+
}
|
|
34
|
+
export type AppRef = {
|
|
35
|
+
$app: string;
|
|
36
|
+
};
|
|
37
|
+
export type ResourceRef = {
|
|
38
|
+
$resource: AppResourceType;
|
|
39
|
+
};
|
|
40
|
+
export type AppMessage = AppRef & {
|
|
41
|
+
messages: string[];
|
|
42
|
+
publish?: boolean;
|
|
43
|
+
};
|
|
44
|
+
export type AppCron = {
|
|
45
|
+
messages: string[];
|
|
46
|
+
cron: events.CronOptions;
|
|
47
|
+
};
|
|
48
|
+
export type FullStackConstructProps = {
|
|
49
|
+
appId: string;
|
|
50
|
+
auth?: {
|
|
51
|
+
groups?: string[];
|
|
52
|
+
};
|
|
53
|
+
storage?: {
|
|
54
|
+
retainOnDelete?: boolean;
|
|
55
|
+
};
|
|
56
|
+
database?: boolean;
|
|
57
|
+
apps?: Record<string, App>;
|
|
58
|
+
events?: {
|
|
59
|
+
messages?: AppMessage[];
|
|
60
|
+
cron?: AppCron[];
|
|
61
|
+
};
|
|
62
|
+
cdn?: {
|
|
63
|
+
routes: Record<string, AppRef | ResourceRef>;
|
|
64
|
+
};
|
|
65
|
+
secrets?: Record<string, string | undefined>;
|
|
66
|
+
};
|
|
67
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/lib/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,MAAM,wBAAwB,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EAAE,MAAM,EAAE,CAAA;KAAE,CAAC;IAC7B,OAAO,CAAC,EAAE;QAAE,cAAc,CAAC,EAAE,OAAO,CAAA;KAAE,CAAC;IACvC,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,IAAI,CAAC,EAAE,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;QAAE,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,WAAW,CAAC,CAAA;KAAE,CAAC;IACvD,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC,CAAC;CAC9C,CAAC"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.AppResourceType = exports.AppGrant = exports.AppType = void 0;
|
|
4
|
+
var AppType;
|
|
5
|
+
(function (AppType) {
|
|
6
|
+
AppType["NEST"] = "nest";
|
|
7
|
+
AppType["NEST_API"] = "nestApi";
|
|
8
|
+
AppType["NEXT_APP_ROUTER"] = "nextAppRouter";
|
|
9
|
+
})(AppType || (exports.AppType = AppType = {}));
|
|
10
|
+
var AppGrant;
|
|
11
|
+
(function (AppGrant) {
|
|
12
|
+
AppGrant["AUTH"] = "auth";
|
|
13
|
+
AppGrant["STORAGE"] = "storage";
|
|
14
|
+
AppGrant["DATABASE"] = "database";
|
|
15
|
+
AppGrant["SECRETS"] = "secrets";
|
|
16
|
+
AppGrant["EVENT"] = "event";
|
|
17
|
+
})(AppGrant || (exports.AppGrant = AppGrant = {}));
|
|
18
|
+
var AppResourceType;
|
|
19
|
+
(function (AppResourceType) {
|
|
20
|
+
AppResourceType["UPLOADS"] = "uploads";
|
|
21
|
+
AppResourceType["AUTH"] = "auth";
|
|
22
|
+
})(AppResourceType || (exports.AppResourceType = AppResourceType = {}));
|
package/package.json
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@fy-stack/fullstack-construct",
|
|
3
|
+
"version": "0.0.1",
|
|
4
|
+
"dependencies": {
|
|
5
|
+
"tslib": "^2.3.0"
|
|
6
|
+
},
|
|
7
|
+
"peerDependencies": {
|
|
8
|
+
"aws-cdk-lib": "2.164.1",
|
|
9
|
+
"constructs": "10.4.2",
|
|
10
|
+
"@fy-stack/auth-construct": "0.0.1",
|
|
11
|
+
"@fy-stack/storage-construct": "0.0.1",
|
|
12
|
+
"@fy-stack/database-construct": "0.0.1",
|
|
13
|
+
"@fy-stack/event-construct": "0.0.1",
|
|
14
|
+
"@fy-stack/secret-construct": "0.0.1",
|
|
15
|
+
"@fy-stack/cdn-construct": "0.0.1",
|
|
16
|
+
"@fy-stack/types": "0.0.1"
|
|
17
|
+
},
|
|
18
|
+
"type": "commonjs",
|
|
19
|
+
"main": "./dist/index.js",
|
|
20
|
+
"typings": "./dist/index.d.ts",
|
|
21
|
+
"files": [
|
|
22
|
+
"dist",
|
|
23
|
+
"!**/*.tsbuildinfo"
|
|
24
|
+
],
|
|
25
|
+
"nx": {
|
|
26
|
+
"name": "fullstack-construct"
|
|
27
|
+
}
|
|
28
|
+
}
|