Skip to content

Commit 4272e67

Browse files
stojanovicsimalexan
authored andcommitted
Serverless application without hexagonal architecture
0 parents  commit 4272e67

15 files changed

+13335
-0
lines changed

.eslintrc.js

Lines changed: 138 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,138 @@
1+
module.exports = {
2+
"env": {
3+
"browser": true,
4+
"es6": true,
5+
"node": true
6+
},
7+
"extends": [
8+
"plugin:@typescript-eslint/recommended",
9+
"plugin:@typescript-eslint/recommended-requiring-type-checking"
10+
],
11+
"parser": "@typescript-eslint/parser",
12+
"parserOptions": {
13+
"project": "tsconfig.json",
14+
"sourceType": "module"
15+
},
16+
"plugins": [
17+
"@typescript-eslint",
18+
"@typescript-eslint/tslint"
19+
],
20+
"rules": {
21+
"@typescript-eslint/array-type": "error",
22+
"@typescript-eslint/ban-types": "off",
23+
"@typescript-eslint/indent": [
24+
"error",
25+
2
26+
],
27+
"@typescript-eslint/interface-name-prefix": "off",
28+
"@typescript-eslint/member-delimiter-style": [
29+
"error",
30+
{
31+
"multiline": {
32+
"delimiter": "none",
33+
"requireLast": true
34+
},
35+
"singleline": {
36+
"delimiter": "semi",
37+
"requireLast": false
38+
}
39+
}
40+
],
41+
"@typescript-eslint/no-explicit-any": "off",
42+
"@typescript-eslint/no-parameter-properties": "off",
43+
"@typescript-eslint/no-use-before-define": "off",
44+
"@typescript-eslint/prefer-for-of": "error",
45+
"@typescript-eslint/prefer-function-type": "error",
46+
"@typescript-eslint/quotes": [
47+
"error",
48+
"single",
49+
{
50+
"avoidEscape": true
51+
}
52+
],
53+
"@typescript-eslint/semi": [
54+
"error",
55+
"never"
56+
],
57+
"@typescript-eslint/unified-signatures": "error",
58+
"camelcase": "error",
59+
"comma-dangle": [
60+
"error",
61+
{
62+
"objects": "always-multiline",
63+
"arrays": "always-multiline",
64+
"functions": "never"
65+
}
66+
],
67+
"complexity": "off",
68+
"constructor-super": "error",
69+
"dot-notation": "error",
70+
"eqeqeq": [
71+
"error",
72+
"smart"
73+
],
74+
"guard-for-in": "error",
75+
"id-blacklist": [
76+
"error",
77+
"any",
78+
"Number",
79+
"number",
80+
"String",
81+
"string",
82+
"Boolean",
83+
"boolean",
84+
"Undefined",
85+
"undefined"
86+
],
87+
"id-match": "error",
88+
"max-classes-per-file": "off",
89+
"max-len": [
90+
"error",
91+
{
92+
"code": 180
93+
}
94+
],
95+
"new-parens": "error",
96+
"no-bitwise": "error",
97+
"no-caller": "error",
98+
"no-cond-assign": "error",
99+
"no-console": "off",
100+
"no-debugger": "error",
101+
"no-empty": "error",
102+
"no-eval": "error",
103+
"no-fallthrough": "off",
104+
"no-invalid-this": "off",
105+
"no-new-wrappers": "error",
106+
"no-shadow": [
107+
"error",
108+
{
109+
"hoist": "all"
110+
}
111+
],
112+
"no-throw-literal": "error",
113+
"no-trailing-spaces": "error",
114+
"no-undef-init": "error",
115+
"no-underscore-dangle": "error",
116+
"no-unsafe-finally": "error",
117+
"no-unused-expressions": "error",
118+
"no-unused-labels": "error",
119+
"object-shorthand": "error",
120+
"one-var": [
121+
"off",
122+
"never"
123+
],
124+
"radix": "error",
125+
"spaced-comment": "error",
126+
"use-isnan": "error",
127+
"valid-typeof": "off",
128+
"@typescript-eslint/tslint/config": [
129+
"error",
130+
{
131+
"rules": {
132+
"jsdoc-format": true,
133+
"no-reference-import": true
134+
}
135+
}
136+
]
137+
}
138+
};

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
build
2+
samconfig.toml
3+
node_modules
4+
info

LICENSE

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
MIT License
2+
3+
Copyright 2020 Gojko Adzic <https://gojko.net>
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
6+
7+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
8+
9+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

README.md

Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
# Sample Serverless app for Senzo course
2+
3+
This is a sample serverless app for [Testing Serverless Applications course on Senzon Homeschool](https://homeschool.dev/class/testing-serverless-apps/).
4+
5+
## Folder structure
6+
7+
This project has the following folder structure:
8+
9+
```bash
10+
.
11+
├── LICENSE
12+
├── README.md # This file
13+
├── WHO-COVID-19-global-data.csv # Sample data
14+
├── build # Build folder
15+
│   └── parse-covid-csv # Each function has its own folder
16+
│   ├── lambda.js # Function source code
17+
│   └── lambda.js.map # Source maps
18+
├── jest.config.js # Jest configuration for testing
19+
├── package-lock.json
20+
├── package.json
21+
├── samconfig.toml # AWS SAM config file, generated by SAM
22+
├── src # Source code for all functions
23+
│   └── parse-covid-csv # Fuction source code
24+
│   ├── events # Events for local testing
25+
│   │   ├── context.ts
26+
│   │   └── event.json
27+
│   └── lambda.ts # Function source code
28+
├── template.yaml # Main CloudFormation file
29+
├── tsconfig.json
30+
├── webpack.config.js # Webpack config
31+
└── yarn.lock
32+
```
33+
34+
## Usage
35+
36+
To use this template, make sure you have the following prerequisites:
37+
38+
- AWS profile
39+
- AWS SAM installed and configured
40+
- Node.js version 8 or more (version 12 is recommended)
41+
42+
### Build TypeScript
43+
44+
To build TypeScript, run the `npm install` or `yarn install` command to install the dependencies, then run the following command:
45+
46+
```bash
47+
npm run build
48+
```
49+
50+
If you want to build a project and run the webpack bundle analyzer, run the following command:
51+
52+
```bash
53+
npm run build-analyze
54+
```
55+
56+
### First time deploy
57+
58+
To deploy the project, run the following command:
59+
60+
```bash
61+
sam deploy --guided
62+
```
63+
64+
This will run an interactive deployment process and ask you for the Amazon S3 bucket name. Amazon S3 bucket must have unique names, so try to be creative. If the deployment fails, you'll need to go to the AWS CloudFormation and delete the stack manually.
65+
66+
After the deployment is done, SAM will save your configuration to the `samconfig.toml` file.
67+
68+
_NOTE: The `samconfig.toml` file is on git ignore list._
69+
70+
See the initial deployment flow video [here](./flow.mp4).
71+
72+
### Next deployments
73+
74+
To deploy the app again, build TypeScript and simply run the following command:
75+
76+
```bash
77+
sam deploy
78+
```
79+
80+
### Testing
81+
82+
This section will be added tomorrow.
83+
84+
## License
85+
86+
MIT, see [LICENSE](LICENSE).

0 commit comments

Comments
 (0)