├── .gitignore ├── README.md ├── architecture.png ├── backend ├── .gitignore ├── .npmignore ├── lib │ ├── data.ts │ └── index.ts ├── package-lock.json ├── package.json ├── swagger.yaml ├── tsconfig.json ├── tslint.json └── tst │ ├── todoApi.spec.ts │ └── todoDAO.spec.ts ├── cfn.yaml ├── deploy.sh └── frontend ├── .editorconfig ├── .gitignore ├── README.md ├── angular.json ├── e2e ├── protractor.conf.js ├── src │ ├── app.e2e-spec.ts │ └── app.po.ts └── tsconfig.e2e.json ├── package-lock.json ├── package.json ├── proxy.config.json ├── src ├── app │ ├── app-routing.module.ts │ ├── app.component.html │ ├── app.component.scss │ ├── app.component.spec.ts │ ├── app.component.ts │ ├── app.module.ts │ ├── page-footer │ │ ├── page-footer.component.html │ │ ├── page-footer.component.scss │ │ ├── page-footer.component.spec.ts │ │ └── page-footer.component.ts │ ├── page-header │ │ ├── page-header.component.html │ │ ├── page-header.component.scss │ │ ├── page-header.component.spec.ts │ │ └── page-header.component.ts │ ├── todo-list │ │ ├── todo-list.component.html │ │ ├── todo-list.component.scss │ │ ├── todo-list.component.spec.ts │ │ └── todo-list.component.ts │ ├── todo.service.spec.ts │ └── todo.service.ts ├── assets │ └── .gitkeep ├── browserslist ├── environments │ ├── environment.prod.ts │ └── environment.ts ├── favicon.ico ├── index.html ├── karma.conf.js ├── main.ts ├── polyfills.ts ├── styles.scss ├── test.ts ├── tsconfig.app.json ├── tsconfig.spec.json └── tslint.json ├── tsconfig.json └── tslint.json /.gitignore: -------------------------------------------------------------------------------- 1 | *.packaged.yaml 2 | node_modules/ 3 | .tmp/ 4 | dist/ 5 | backend/.nyc_output -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Purpose 2 | 3 | This repository contains a sample application to show the deployment of a serverless application hosted on AWS. 4 | 5 | It is using the serverless application model to deploy the application using AWS CloudFormation. 6 | 7 | The API backend is implemented using API Gateway and AWS Lambda. 8 | 9 | The frontend is written using Angular JS. 10 | 11 | ![Architecture](architecture.png) 12 | 13 | ## AWS Services used 14 | 15 | * AWS Lambda - to provide the functionality 16 | * API Gateway - as HTTPS endpoint for the backend 17 | * CloudFront - as entry point to serve API and Frontend 18 | * S3 - to store the static files for the web frontend 19 | * DynamoDB - database for the stored tasks 20 | * IAM - for least privilege roles to grant access to the database 21 | 22 | 23 | * CloudFormation - to deploy the application 24 | 25 | # Development 26 | 27 | The `backend` folder contains the Lambda code for the API and the `frontend` folder contains the Angular JS single page application. 28 | 29 | You need NodeJS and NPM to develop in this project. 30 | 31 | # Deployment 32 | 33 | To deploy run the script `deploy.sh` from the command line and have the AWS CLI set up correctly. -------------------------------------------------------------------------------- /architecture.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/taimos/serverless-todo-demo/3ec0de9df428af699b8e5eab3014ceb89bc1c8cb/architecture.png -------------------------------------------------------------------------------- /backend/.gitignore: -------------------------------------------------------------------------------- 1 | coverage/ 2 | dist/ 3 | -------------------------------------------------------------------------------- /backend/.npmignore: -------------------------------------------------------------------------------- 1 | coverage/ 2 | doc/ 3 | lib/ 4 | node_modules/ 5 | tst/ 6 | lib/index.ts 7 | package-lock.json 8 | tsconfig.json 9 | tslint.json 10 | -------------------------------------------------------------------------------- /backend/lib/data.ts: -------------------------------------------------------------------------------- 1 | import { DynamoDB } from 'aws-sdk'; 2 | import { DocumentClient } from 'aws-sdk/lib/dynamodb/document_client'; 3 | import AttributeMap = DocumentClient.AttributeMap; 4 | import ScanOutput = DocumentClient.ScanOutput; 5 | import PutItemInput = DocumentClient.PutItemInput; 6 | import ScanInput = DocumentClient.ScanInput; 7 | 8 | export class ToDo { 9 | public id : string; 10 | public text : string; 11 | public state : string; 12 | 13 | constructor(attr : AttributeMap) { 14 | this.id = attr.id; 15 | this.text = attr.text; 16 | this.state = attr.state; 17 | } 18 | } 19 | 20 | export const save = async (todo : ToDo) : Promise => { 21 | const params : PutItemInput = { 22 | Item: todo, 23 | TableName: process.env.TABLE_NAME, 24 | }; 25 | 26 | const dynamoClient : DocumentClient = new DynamoDB.DocumentClient(); 27 | await dynamoClient.put(params).promise(); 28 | 29 | return todo; 30 | }; 31 | 32 | const scanDynamoDB = async (query : ScanInput) : Promise => { 33 | const dynamoClient : DocumentClient = new DynamoDB.DocumentClient(); 34 | const data : ScanOutput = await dynamoClient.scan(query).promise(); 35 | 36 | if (!data.Items) { 37 | return []; 38 | } 39 | const todos : ToDo[] = data.Items.map((attr : AttributeMap) => new ToDo(attr)); 40 | if (data.LastEvaluatedKey) { 41 | query.ExclusiveStartKey = data.LastEvaluatedKey; 42 | const list = await scanDynamoDB(query); 43 | todos.forEach((item : ToDo) => { 44 | list.push(item); 45 | }); 46 | return list; 47 | } 48 | return todos; 49 | }; 50 | 51 | export const listTodos = () : Promise => { 52 | return scanDynamoDB({ 53 | TableName: process.env.TABLE_NAME, 54 | Limit: 1000, 55 | }); 56 | }; 57 | -------------------------------------------------------------------------------- /backend/lib/index.ts: -------------------------------------------------------------------------------- 1 | import { APIGatewayProxyEvent, APIGatewayProxyResult } from 'aws-lambda'; 2 | import * as uuid from 'node-uuid'; 3 | import { listTodos, save, ToDo } from './data'; 4 | 5 | export const apiAddTodo = async (event : APIGatewayProxyEvent) : Promise => { 6 | const todo : ToDo = JSON.parse(event.body); 7 | todo.id = uuid.v4(); 8 | 9 | const saved : ToDo = await save(todo); 10 | 11 | return { 12 | statusCode: 201, 13 | headers: { 14 | Location: '/todos/' + saved.id, 15 | }, 16 | body: JSON.stringify(saved), 17 | }; 18 | }; 19 | 20 | export const apiGetTodos = async () : Promise => { 21 | return ({ 22 | statusCode: 200, 23 | body: JSON.stringify(await listTodos()), 24 | }); 25 | }; 26 | 27 | export const apiUpdateTodo = async (event : APIGatewayProxyEvent) : Promise => { 28 | const todo = JSON.parse(event.body); 29 | 30 | if (todo.id !== event.pathParameters.id) { 31 | return { 32 | statusCode: 400, 33 | body: '', 34 | }; 35 | } 36 | 37 | return { 38 | statusCode: 200, 39 | body: JSON.stringify(await save(todo)), 40 | }; 41 | }; 42 | -------------------------------------------------------------------------------- /backend/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "serverless-todo-demo", 3 | "version": "1.0.0", 4 | "description": "Serverless ToDo list", 5 | "main": "index.js", 6 | "scripts": { 7 | "test": "tslint -p tsconfig.json -c tslint.json && nyc -x tst -e .ts --temp-directory coverage/nyc-output -r html -r text-summary -r cobertura ./node_modules/.bin/_mocha --require ./node_modules/ts-node/register/index.js 'tst/**/*.spec.ts' --reporter nyan", 8 | "build": "rimraf dist && tsc && claudia pack --force --output dist/bundle.zip" 9 | }, 10 | "author": "Taimos GmbH", 11 | "dependencies": { 12 | "aws-sdk": "^2.430.0", 13 | "node-uuid": "^1.4.8" 14 | }, 15 | "devDependencies": { 16 | "@types/aws-lambda": "^8.10.23", 17 | "@types/chai": "^4.1.7", 18 | "@types/mocha": "^5.2.6", 19 | "@types/node": "^11.12.0", 20 | "@types/sinon": "^7.0.10", 21 | "aws-sdk-mock": "^4.3.1", 22 | "chai": "^4.2.0", 23 | "claudia": "^5", 24 | "lambda-local": "^1.5.2", 25 | "mocha": "^6.0.2", 26 | "nyc": "^13.3.0", 27 | "proxyquire": "^2.1.0", 28 | "rimraf": "^2.6.3", 29 | "ts-node": "^8.0.3", 30 | "tslint": "^5.14.0", 31 | "typedoc": "^0.14.2", 32 | "typescript": "^3.3.4000" 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /backend/swagger.yaml: -------------------------------------------------------------------------------- 1 | openapi: 3.0.0 2 | info: 3 | version: '1.0' 4 | title: Serverless Todo Demo 5 | paths: 6 | /todos: 7 | post: 8 | x-amazon-apigateway-integration: 9 | httpMethod: POST 10 | type: aws_proxy 11 | uri: 12 | 'Fn::Sub': "arn:aws:apigateway:${AWS::Region}:lambda:path/2015-03-31/functions/${ApiAddTodoFunction.Arn}/invocations" 13 | responses: 14 | '201': 15 | $ref: '#/components/responses/ToDo' 16 | requestBody: 17 | $ref: '#/components/requestBodies/ToDo' 18 | get: 19 | x-amazon-apigateway-integration: 20 | httpMethod: POST 21 | type: aws_proxy 22 | uri: 23 | 'Fn::Sub': "arn:aws:apigateway:${AWS::Region}:lambda:path/2015-03-31/functions/${ApiListTodosFunction.Arn}/invocations" 24 | responses: 25 | '200': 26 | $ref: '#/components/responses/ToDoList' 27 | '/todos/{id}': 28 | parameters: 29 | - name: id 30 | in: path 31 | required: true 32 | schema: 33 | type: string 34 | description: The id of the task 35 | put: 36 | x-amazon-apigateway-integration: 37 | httpMethod: POST 38 | type: aws_proxy 39 | uri: 40 | 'Fn::Sub': "arn:aws:apigateway:${AWS::Region}:lambda:path/2015-03-31/functions/${ApiUpdateTodoFunction.Arn}/invocations" 41 | responses: 42 | '200': 43 | $ref: '#/components/responses/ToDo' 44 | requestBody: 45 | $ref: '#/components/requestBodies/ToDo' 46 | components: 47 | responses: 48 | ToDo: 49 | description: A single ToDo entry 50 | content: 51 | application/json: 52 | schema: 53 | $ref: '#/components/schemas/ToDo' 54 | ToDoList: 55 | description: A list of ToDo entries 56 | content: 57 | application/json: 58 | schema: 59 | type: array 60 | items: 61 | $ref: '#/components/schemas/ToDo' 62 | requestBodies: 63 | ToDo: 64 | description: A single ToDo entry 65 | content: 66 | application/json: 67 | schema: 68 | $ref: '#/components/schemas/ToDo' 69 | schemas: 70 | ToDo: 71 | type: object 72 | description: A ToDo entry 73 | properties: 74 | id: 75 | type: string 76 | description: The id of the task 77 | text: 78 | type: string 79 | description: The task title 80 | state: 81 | type: string 82 | description: The state of the task 83 | enum: 84 | - OPEN 85 | - IN_PROGRESS 86 | - DONE -------------------------------------------------------------------------------- /backend/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "target": "es2017", 4 | "module": "commonjs", 5 | "moduleResolution": "node", 6 | "rootDir": "lib", 7 | "outDir": "dist", 8 | "sourceMap": true, 9 | "inlineSources": false, 10 | "alwaysStrict": true, 11 | "removeComments": false, 12 | "declaration": true, 13 | "lib": [ 14 | "es2017", 15 | "es2015" 16 | ] 17 | }, 18 | "include": [ 19 | "lib" 20 | ] 21 | } 22 | -------------------------------------------------------------------------------- /backend/tslint.json: -------------------------------------------------------------------------------- 1 | { 2 | "linterOptions": { 3 | "exclude": [ 4 | "node_modules/**/*" 5 | ] 6 | }, 7 | "rules": { 8 | "adjacent-overload-signatures": true, 9 | "array-type": [ 10 | true, 11 | "array-simple" 12 | ], 13 | "arrow-parens": true, 14 | "arrow-return-shorthand": true, 15 | "align": [ 16 | true, 17 | "statements" 18 | ], 19 | "ban-comma-operator": true, 20 | "ban-types": [ 21 | true, 22 | ["Object", "Use {} instead."], 23 | ["String", "Use string instead."] 24 | ], 25 | "binary-expression-operand-order": true, 26 | "class-name": true, 27 | "comment-format": [ 28 | true, 29 | "check-space" 30 | ], 31 | "curly": true, 32 | "eofline": true, 33 | "forin": true, 34 | "import-spacing": true, 35 | "indent": [ 36 | true, 37 | "spaces", 38 | 2 39 | ], 40 | "interface-over-type-literal": false, 41 | "jsdoc-format": true, 42 | "label-position": true, 43 | "max-line-length": [ 44 | true, 45 | 250 46 | ], 47 | "member-access": [ 48 | true, 49 | "check-accessor" 50 | ], 51 | "member-ordering": [ 52 | true, 53 | { 54 | "order": "statics-first" 55 | } 56 | ], 57 | "new-parens": true, 58 | "no-arg": true, 59 | "no-bitwise": true, 60 | "no-conditional-assignment": true, 61 | "no-consecutive-blank-lines": [ 62 | true, 63 | 1 64 | ], 65 | "no-construct": true, 66 | "no-debugger": true, 67 | "no-default-export": true, 68 | "no-duplicate-imports": true, 69 | "no-duplicate-super": true, 70 | "no-duplicate-switch-case": true, 71 | "no-duplicate-variable": true, 72 | "no-empty": true, 73 | "no-eval": true, 74 | "no-internal-module": true, 75 | "no-invalid-template-strings": true, 76 | "no-invalid-this": [ 77 | true, 78 | "check-function-in-method" 79 | ], 80 | "no-irregular-whitespace": true, 81 | "no-object-literal-type-assertion": true, 82 | "no-namespace": true, 83 | "no-parameter-properties": true, 84 | "no-reference": true, 85 | "no-return-await": true, 86 | "no-shadowed-variable": true, 87 | "no-sparse-arrays": true, 88 | "no-string-literal": true, 89 | "no-switch-case-fall-through": true, 90 | "no-trailing-whitespace": true, 91 | "no-unsafe-finally": true, 92 | "no-unused-expression": true, 93 | "no-var-keyword": true, 94 | "no-var-requires": true, 95 | "object-literal-key-quotes": [ 96 | true, 97 | "consistent-as-needed" 98 | ], 99 | "object-literal-shorthand": true, 100 | "object-literal-sort-keys": false, 101 | "one-line": [ 102 | true, 103 | "check-catch", 104 | "check-else", 105 | "check-finally", 106 | "check-open-brace", 107 | "check-whitespace" 108 | ], 109 | "one-variable-per-declaration": [ 110 | true, 111 | "ignore-for-loop" 112 | ], 113 | "only-arrow-functions": [ 114 | true, 115 | "allow-declarations" 116 | ], 117 | "ordered-imports": [ 118 | true, 119 | { 120 | "import-sources-order": "case-insensitive", 121 | "named-imports-order": "case-insensitive" 122 | } 123 | ], 124 | "prefer-conditional-expression": true, 125 | "prefer-const": true, 126 | "prefer-for-of": true, 127 | "prefer-object-spread": true, 128 | "quotemark": [ 129 | true, 130 | "single", 131 | "avoid-escape" 132 | ], 133 | "radix": true, 134 | "semicolon": [ 135 | true, 136 | "always" 137 | ], 138 | "switch-default": true, 139 | "trailing-comma": [ 140 | true, 141 | { 142 | "multiline": "always", 143 | "singleline": "never" 144 | } 145 | ], 146 | "triple-equals": [ 147 | true, 148 | "allow-null-check" 149 | ], 150 | "typedef": [ 151 | true, 152 | "call-signature", 153 | //"arrow-call-signature", 154 | "parameter", 155 | //"arrow-parameter", 156 | "property-declaration", 157 | "member-variable-declaration" 158 | //"object-destructuring", 159 | //"array-destructuring" 160 | ], 161 | "typedef-whitespace": [ 162 | true, 163 | { 164 | "call-signature": "onespace", 165 | "index-signature": "onespace", 166 | "parameter": "onespace", 167 | "property-declaration": "onespace", 168 | "variable-declaration": "onespace" 169 | }, 170 | { 171 | "call-signature": "onespace", 172 | "index-signature": "onespace", 173 | "parameter": "onespace", 174 | "property-declaration": "onespace", 175 | "variable-declaration": "onespace" 176 | } 177 | ], 178 | "unified-signatures": true, 179 | "use-isnan": true, 180 | "variable-name": [ 181 | true, 182 | "ban-keywords", 183 | "check-format", 184 | "allow-pascal-case", 185 | "allow-leading-underscore" 186 | ], 187 | "whitespace": [ 188 | true, 189 | "check-branch", 190 | "check-decl", 191 | "check-operator", 192 | "check-separator", 193 | "check-type", 194 | "check-typecast", 195 | "check-module" 196 | ] 197 | } 198 | } 199 | -------------------------------------------------------------------------------- /backend/tst/todoApi.spec.ts: -------------------------------------------------------------------------------- 1 | import { APIGatewayProxyEvent, APIGatewayProxyResult } from 'aws-lambda'; 2 | import { expect } from 'chai'; 3 | import * as lambdaLocal from 'lambda-local'; 4 | import { describe, it } from 'mocha'; 5 | import * as proxyquire from 'proxyquire'; 6 | import { ToDo } from '../lib/data'; 7 | 8 | lambdaLocal.getLogger().level = 'error'; 9 | 10 | const todoStub = { 11 | listTodos: undefined, 12 | save: undefined, 13 | }; 14 | const uuidStub = { 15 | v4: undefined, 16 | }; 17 | 18 | const api = proxyquire('../lib/index', { './data': todoStub, 'node-uuid': uuidStub }); 19 | 20 | describe('GetAPI', () => { 21 | beforeEach(() => { 22 | delete todoStub.listTodos; 23 | }); 24 | 25 | it('should return list of todos', async () => { 26 | todoStub.listTodos = () => { 27 | return Promise.resolve([{ 28 | id: 'SomeId', 29 | text: 'Todo text', 30 | state: 'OPEN', 31 | }]); 32 | }; 33 | 34 | const response : APIGatewayProxyResult = await lambdaLocal.execute({ 35 | event: {}, 36 | lambdaFunc: api, 37 | lambdaHandler: 'apiGetTodos', 38 | }); 39 | 40 | expect(response).to.have.property('statusCode', 200); 41 | expect(response).to.have.property('body'); 42 | const list = JSON.parse(response.body); 43 | expect(list).to.be.an('array').that.has.lengthOf(1); 44 | expect(list[0]).to.have.property('id', 'SomeId'); 45 | expect(list[0]).to.have.property('text', 'Todo text'); 46 | expect(list[0]).to.have.property('state', 'OPEN'); 47 | }); 48 | }); 49 | 50 | describe('AddAPI', () => { 51 | beforeEach(() => { 52 | delete todoStub.save; 53 | }); 54 | 55 | it('should save new todo', async () => { 56 | uuidStub.v4 = () => 'randomID'; 57 | todoStub.save = (todoToSave : ToDo) => { 58 | expect(todoToSave).to.have.property('id', 'randomID'); 59 | expect(todoToSave).to.have.property('text', 'SomeText'); 60 | expect(todoToSave).to.have.property('state', 'OPEN'); 61 | return Promise.resolve(todoToSave); 62 | }; 63 | 64 | const event = { 65 | body: JSON.stringify({ 66 | text: 'SomeText', 67 | state: 'OPEN', 68 | }), 69 | }; 70 | 71 | const response : APIGatewayProxyResult = await lambdaLocal.execute({ 72 | event, 73 | lambdaFunc: api, 74 | lambdaHandler: 'apiAddTodo', 75 | }); 76 | 77 | expect(response).to.have.property('statusCode', 201); 78 | expect(response).to.have.property('headers'); 79 | expect(response.headers).to.have.property('Location', '/todos/randomID'); 80 | expect(response).to.have.property('body'); 81 | const todo : ToDo = JSON.parse(response.body); 82 | expect(todo).to.have.property('id', 'randomID'); 83 | expect(todo).to.have.property('text', 'SomeText'); 84 | expect(todo).to.have.property('state', 'OPEN'); 85 | }); 86 | 87 | }); 88 | 89 | describe('UpdateAPI', () => { 90 | beforeEach(() => { 91 | delete todoStub.save; 92 | }); 93 | 94 | it('should update todo', async () => { 95 | todoStub.save = (todoToSave : ToDo) => { 96 | expect(todoToSave).to.have.property('id', 'someId'); 97 | expect(todoToSave).to.have.property('text', 'SomeText'); 98 | expect(todoToSave).to.have.property('state', 'OPEN'); 99 | return Promise.resolve(todoToSave); 100 | }; 101 | 102 | const event : APIGatewayProxyEvent = { 103 | httpMethod: 'PUT', 104 | pathParameters: { 105 | id: 'someId', 106 | }, 107 | queryStringParameters: {}, 108 | multiValueHeaders: {}, 109 | multiValueQueryStringParameters: {}, 110 | stageVariables: {}, 111 | requestContext: undefined, 112 | resource: '', 113 | headers: {}, 114 | body: JSON.stringify({ 115 | id: 'someId', 116 | text: 'SomeText', 117 | state: 'OPEN', 118 | }), 119 | path: '/todos/{id}', 120 | isBase64Encoded: false, 121 | }; 122 | 123 | const response : APIGatewayProxyResult = await lambdaLocal.execute({ 124 | event, 125 | lambdaFunc: api, 126 | lambdaHandler: 'apiUpdateTodo', 127 | }); 128 | 129 | expect(response.statusCode).to.equal(200); 130 | expect(response).to.haveOwnProperty('body'); 131 | const todo = JSON.parse(response.body); 132 | expect(todo).to.have.property('id', 'someId'); 133 | expect(todo).to.have.property('text', 'SomeText'); 134 | expect(todo).to.have.property('state', 'OPEN'); 135 | }); 136 | 137 | it('should fail for invalid id', async () => { 138 | todoStub.save = () => { 139 | expect.fail('Should have never been called'); 140 | }; 141 | 142 | const event = { 143 | pathParameters: { 144 | id: 'otherId', 145 | }, 146 | body: JSON.stringify({ 147 | id: 'someId', 148 | text: 'SomeText', 149 | state: 'OPEN', 150 | }), 151 | }; 152 | 153 | const response : APIGatewayProxyResult = await lambdaLocal.execute({ 154 | event, 155 | lambdaFunc: api, 156 | lambdaHandler: 'apiUpdateTodo', 157 | }); 158 | expect(response).to.have.property('statusCode', 400); 159 | expect(response).to.have.property('body', ''); 160 | }); 161 | 162 | }); 163 | -------------------------------------------------------------------------------- /backend/tst/todoDAO.spec.ts: -------------------------------------------------------------------------------- 1 | import * as AWS from 'aws-sdk-mock'; 2 | import { DocumentClient } from 'aws-sdk/lib/dynamodb/document_client'; 3 | import { expect } from 'chai'; 4 | import * as lambdaLocal from 'lambda-local'; 5 | import ScanOutput = DocumentClient.ScanOutput; 6 | import PutItemInput = DocumentClient.PutItemInput; 7 | import ScanInput = DocumentClient.ScanInput; 8 | import { env } from 'process'; 9 | import { listTodos, save, ToDo } from '../lib/data'; 10 | 11 | lambdaLocal.getLogger().level = 'error'; 12 | env.TABLE_NAME = 'SomeTable'; 13 | 14 | describe('Test ToDo DAO - save', () => { 15 | 16 | it('should save todo', async () => { 17 | 18 | AWS.mock('DynamoDB.DocumentClient', 'put', (params : PutItemInput, callback) => { 19 | expect(params).to.haveOwnProperty('Item'); 20 | expect(params.Item).to.have.property('id', 'todoId'); 21 | expect(params.Item).to.have.property('text', 'ToDoText'); 22 | expect(params.Item).to.have.property('state', 'OPEN'); 23 | expect(params).to.have.property('TableName', 'SomeTable'); 24 | callback(null, {}); 25 | }); 26 | 27 | const todo : ToDo = await save({ 28 | id: 'todoId', 29 | text: 'ToDoText', 30 | state: 'OPEN', 31 | }); 32 | 33 | expect(todo).to.have.property('id', 'todoId'); 34 | expect(todo).to.have.property('text', 'ToDoText'); 35 | expect(todo).to.have.property('state', 'OPEN'); 36 | }); 37 | 38 | afterEach(() => { 39 | AWS.restore(); 40 | }); 41 | 42 | }); 43 | 44 | describe('Test ToDo DAO - list', () => { 45 | it('should list todos', async () => { 46 | 47 | AWS.mock('DynamoDB.DocumentClient', 'scan', (params, callback) => { 48 | expect(params).to.be.an('object'); 49 | expect(params).to.have.property('TableName', 'SomeTable'); 50 | expect(params).to.have.property('Limit', 1000); 51 | callback(null, { 52 | Items: [ 53 | { 54 | id: 'todoId', 55 | text: 'ToDoText', 56 | state: 'OPEN', 57 | }, 58 | ], 59 | }); 60 | }); 61 | 62 | const list : ToDo[] = await listTodos(); 63 | expect(list).to.be.an('array').that.has.lengthOf(1); 64 | expect(list[0]).to.have.property('id', 'todoId'); 65 | expect(list[0]).to.have.property('text', 'ToDoText'); 66 | expect(list[0]).to.have.property('state', 'OPEN'); 67 | }); 68 | 69 | it('should handle empty list', async () => { 70 | 71 | AWS.mock('DynamoDB.DocumentClient', 'scan', (params, callback) => { 72 | expect(params).to.be.an('object'); 73 | expect(params).to.have.property('TableName', 'SomeTable'); 74 | expect(params).to.have.property('Limit', 1000); 75 | callback(null, {}); 76 | }); 77 | 78 | const list : ToDo[] = await listTodos(); 79 | expect(list).to.be.an('array'); 80 | expect(list).to.have.lengthOf(0); 81 | }); 82 | 83 | it('should list todos with paging', async () => { 84 | let queryCount = 0; 85 | 86 | AWS.mock('DynamoDB.DocumentClient', 'scan', (params : ScanInput, callback) => { 87 | expect(params).to.be.an('object'); 88 | expect(params).to.have.property('TableName', 'SomeTable'); 89 | expect(params).to.have.property('Limit', 1000); 90 | if (queryCount === 0) { 91 | expect(params).to.not.have.property('ExclusiveStartKey'); 92 | } else { 93 | expect(params).to.have.property('ExclusiveStartKey'); 94 | expect(params.ExclusiveStartKey).to.have.property('id', 'lastKey'); 95 | } 96 | 97 | const result : ScanOutput = { 98 | Items: [ 99 | { 100 | id: 'todoId', 101 | text: `ToDoText${queryCount}`, 102 | state: 'OPEN', 103 | }, 104 | ], 105 | }; 106 | if (queryCount === 0) { 107 | result.LastEvaluatedKey = { 108 | id: 'lastKey', 109 | }; 110 | queryCount = 1; 111 | } 112 | callback(null, result); 113 | }); 114 | 115 | const list : ToDo[] = await listTodos(); 116 | expect(list).to.be.an('array').that.has.lengthOf(2); 117 | 118 | expect(list[0]).to.have.property('id', 'todoId'); 119 | expect(list[0]).to.have.property('text', 'ToDoText1'); 120 | expect(list[0]).to.have.property('state', 'OPEN'); 121 | 122 | expect(list[1]).to.have.property('id', 'todoId'); 123 | expect(list[1]).to.have.property('text', 'ToDoText0'); 124 | expect(list[1]).to.have.property('state', 'OPEN'); 125 | 126 | expect(queryCount).to.be.equal(1); 127 | }); 128 | 129 | afterEach(() => { 130 | AWS.restore(); 131 | }); 132 | 133 | }); 134 | -------------------------------------------------------------------------------- /cfn.yaml: -------------------------------------------------------------------------------- 1 | AWSTemplateFormatVersion: '2010-09-09' 2 | Transform: AWS::Serverless-2016-10-31 3 | Description: AWS UGS Todo list 4 | Globals: 5 | Function: 6 | Runtime: nodejs8.10 7 | Timeout: 10 8 | MemorySize: 512 9 | Resources: 10 | TodoTable: 11 | Type: AWS::Serverless::SimpleTable 12 | Properties: 13 | PrimaryKey: 14 | Name: id 15 | Type: String 16 | ProvisionedThroughput: 17 | ReadCapacityUnits: 1 18 | WriteCapacityUnits: 1 19 | 20 | ApiListTodosFunction: 21 | Type: AWS::Serverless::Function 22 | Properties: 23 | Handler: dist/index.apiGetTodos 24 | CodeUri: ./backend/dist/bundle.zip 25 | Tracing: Active 26 | Policies: 27 | Statement: 28 | - Effect: "Allow" 29 | Action: "dynamodb:Scan" 30 | Resource: 31 | - !Sub arn:aws:dynamodb:${AWS::Region}:${AWS::AccountId}:table/${TodoTable} 32 | - !Sub arn:aws:dynamodb:${AWS::Region}:${AWS::AccountId}:table/${TodoTable}/index/* 33 | Environment: 34 | Variables: 35 | TABLE_NAME: !Ref TodoTable 36 | Events: 37 | ListDevices: 38 | Type: Api 39 | Properties: 40 | RestApiId: !Ref RestApi 41 | Path: /todos 42 | Method: get 43 | ApiUpdateTodoFunction: 44 | Type: AWS::Serverless::Function 45 | Properties: 46 | Handler: dist/index.apiUpdateTodo 47 | CodeUri: ./backend/dist/bundle.zip 48 | Tracing: Active 49 | Policies: 50 | Statement: 51 | - Effect: "Allow" 52 | Action: "dynamodb:PutItem" 53 | Resource: 54 | - !Sub arn:aws:dynamodb:${AWS::Region}:${AWS::AccountId}:table/${TodoTable} 55 | - !Sub arn:aws:dynamodb:${AWS::Region}:${AWS::AccountId}:table/${TodoTable}/index/* 56 | Environment: 57 | Variables: 58 | TABLE_NAME: !Ref TodoTable 59 | Events: 60 | ListDevices: 61 | Type: Api 62 | Properties: 63 | RestApiId: !Ref RestApi 64 | Path: /todos/{id} 65 | Method: put 66 | ApiAddTodoFunction: 67 | Type: AWS::Serverless::Function 68 | Properties: 69 | Handler: dist/index.apiAddTodo 70 | CodeUri: ./backend/dist/bundle.zip 71 | Tracing: Active 72 | Policies: 73 | Statement: 74 | - Effect: "Allow" 75 | Action: "dynamodb:PutItem" 76 | Resource: 77 | - !Sub arn:aws:dynamodb:${AWS::Region}:${AWS::AccountId}:table/${TodoTable} 78 | - !Sub arn:aws:dynamodb:${AWS::Region}:${AWS::AccountId}:table/${TodoTable}/index/* 79 | Environment: 80 | Variables: 81 | TABLE_NAME: !Ref TodoTable 82 | Events: 83 | ListDevices: 84 | Type: Api 85 | Properties: 86 | RestApiId: !Ref RestApi 87 | Path: /todos 88 | Method: post 89 | 90 | RestApi: 91 | Type: AWS::Serverless::Api 92 | Properties: 93 | StageName: Prod 94 | DefinitionBody: 95 | 'Fn::Transform': 96 | Name: 'AWS::Include' 97 | Parameters: 98 | Location: !Sub s3://${AWS::AccountId}-sam-deploy-${AWS::Region}/${AWS::StackName}/swagger.yaml 99 | 100 | WebappBucket: 101 | Type: 'AWS::S3::Bucket' 102 | Properties: 103 | WebsiteConfiguration: 104 | IndexDocument: index.html 105 | S3BucketPolicy: 106 | Type: 'AWS::S3::BucketPolicy' 107 | Properties: 108 | Bucket: !Ref WebappBucket 109 | PolicyDocument: 110 | Statement: 111 | - Action: 's3:GetObject' 112 | Effect: Allow 113 | Resource: !Sub arn:aws:s3:::${WebappBucket}/* 114 | Principal: 115 | CanonicalUser: !GetAtt OriginAccessIdentity.S3CanonicalUserId 116 | OriginAccessIdentity: 117 | Type: AWS::CloudFront::CloudFrontOriginAccessIdentity 118 | Properties: 119 | CloudFrontOriginAccessIdentityConfig: 120 | Comment: !Ref AWS::StackName 121 | 122 | CloudFrontDistribution: 123 | Type: 'AWS::CloudFront::Distribution' 124 | Properties: 125 | DistributionConfig: 126 | Comment: AWS UGS Todo 127 | DefaultRootObject: index.html 128 | CustomErrorResponses: 129 | - ErrorCode: 403 130 | ResponseCode: 200 131 | ResponsePagePath: /index.html 132 | - ErrorCode: 404 133 | ResponseCode: 200 134 | ResponsePagePath: /index.html 135 | Origins: 136 | - DomainName: !Sub ${WebappBucket}.s3.amazonaws.com 137 | Id: s3origin 138 | S3OriginConfig: 139 | OriginAccessIdentity: !Sub origin-access-identity/cloudfront/${OriginAccessIdentity} 140 | - DomainName: !Sub ${RestApi}.execute-api.${AWS::Region}.amazonaws.com 141 | OriginPath: /Prod 142 | Id: apiOrigin 143 | CustomOriginConfig: 144 | OriginProtocolPolicy: https-only 145 | DefaultCacheBehavior: 146 | AllowedMethods: 147 | - GET 148 | - HEAD 149 | - OPTIONS 150 | DefaultTTL: 0 151 | MinTTL: 0 152 | MaxTTL: 0 153 | ForwardedValues: 154 | QueryString: false 155 | Cookies: 156 | Forward: none 157 | TargetOriginId: s3origin 158 | ViewerProtocolPolicy: redirect-to-https 159 | CacheBehaviors: 160 | - AllowedMethods: 161 | - GET 162 | - PUT 163 | - POST 164 | - HEAD 165 | - DELETE 166 | - OPTIONS 167 | - PATCH 168 | TargetOriginId: apiOrigin 169 | DefaultTTL: 0 170 | MinTTL: 0 171 | MaxTTL: 0 172 | ForwardedValues: 173 | QueryString: true 174 | Cookies: 175 | Forward: none 176 | ViewerProtocolPolicy: redirect-to-https 177 | PathPattern: /todos* 178 | Enabled: true 179 | PriceClass: PriceClass_All 180 | 181 | Outputs: 182 | ApiUrl: 183 | Description: URL of the API endpoint 184 | Value: !Sub 'https://${RestApi}.execute-api.${AWS::Region}.amazonaws.com/Prod' 185 | WebUrl: 186 | Description: URL of the Web endpoint 187 | Value: !Sub 'https://${CloudFrontDistribution.DomainName}' 188 | WebappBucket: 189 | Description: The S3 bucket containing the SPA 190 | Value: !Ref WebappBucket 191 | CloudFrontDistribution: 192 | Description: The CloudFront distribution used as endpoint 193 | Value: !Ref CloudFrontDistribution -------------------------------------------------------------------------------- /deploy.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | export AWS_DEFAULT_REGION=eu-central-1 4 | export AWS_REGION=eu-central-1 5 | 6 | set -e 7 | 8 | ACCOUNT_ID=$(aws sts get-caller-identity --query Account --output text) 9 | SAM_BUCKET=${ACCOUNT_ID}-sam-deploy-${AWS_REGION} 10 | STACK_NAME=serverless-todo-demo-ng7 11 | 12 | if ! aws s3api head-bucket --bucket "${SAM_BUCKET}" 2>/dev/null; then 13 | echo "Please create S3 bucket \"${SAM_BUCKET}\" as deployment bucket" 14 | echo "This bucket can be reused for all your SAM deployments" 15 | echo "" 16 | echo "aws s3 mb s3://${SAM_BUCKET}" 17 | exit 1 18 | fi 19 | 20 | npm install --prefix backend/ 21 | npm test --prefix backend/ 22 | npm run build --prefix backend/ 23 | 24 | aws s3 cp backend/swagger.yaml s3://${SAM_BUCKET}/${STACK_NAME}/swagger.yaml 25 | aws cloudformation package --template-file cfn.yaml --s3-bucket ${SAM_BUCKET} --s3-prefix ${STACK_NAME} --output-template-file cfn.packaged.yaml 26 | 27 | aws cloudformation deploy --template-file cfn.packaged.yaml --stack-name ${STACK_NAME} --capabilities CAPABILITY_IAM --no-fail-on-empty-changeset 28 | 29 | npm install --prefix frontend/ 30 | npm run build:prod --prefix frontend/ 31 | BUCKET=$(aws cloudformation describe-stacks --stack-name ${STACK_NAME} --query "Stacks[0].Outputs[?OutputKey == 'WebappBucket'].OutputValue" --output text) 32 | aws s3 sync --delete --exact-timestamps frontend/dist/frontend/ s3://${BUCKET} 33 | aws s3 cp frontend/dist/frontend/index.html s3://${BUCKET}/index.html 34 | 35 | CFURL=$(aws cloudformation describe-stacks --stack-name ${STACK_NAME} --query "Stacks[0].Outputs[?OutputKey == 'WebUrl'].OutputValue" --output text) 36 | echo "Website is available under: ${CFURL}" -------------------------------------------------------------------------------- /frontend/.editorconfig: -------------------------------------------------------------------------------- 1 | # Editor configuration, see https://editorconfig.org 2 | root = true 3 | 4 | [*] 5 | charset = utf-8 6 | indent_style = space 7 | indent_size = 2 8 | insert_final_newline = true 9 | trim_trailing_whitespace = true 10 | 11 | [*.md] 12 | max_line_length = off 13 | trim_trailing_whitespace = false 14 | -------------------------------------------------------------------------------- /frontend/.gitignore: -------------------------------------------------------------------------------- 1 | # See http://help.github.com/ignore-files/ for more about ignoring files. 2 | 3 | # compiled output 4 | /dist 5 | /tmp 6 | /out-tsc 7 | 8 | # dependencies 9 | /node_modules 10 | 11 | # profiling files 12 | chrome-profiler-events.json 13 | speed-measure-plugin.json 14 | 15 | # IDEs and editors 16 | /.idea 17 | .project 18 | .classpath 19 | .c9/ 20 | *.launch 21 | .settings/ 22 | *.sublime-workspace 23 | 24 | # IDE - VSCode 25 | .vscode/* 26 | !.vscode/settings.json 27 | !.vscode/tasks.json 28 | !.vscode/launch.json 29 | !.vscode/extensions.json 30 | .history/* 31 | 32 | # misc 33 | /.sass-cache 34 | /connect.lock 35 | /coverage 36 | /libpeerconnection.log 37 | npm-debug.log 38 | yarn-error.log 39 | testem.log 40 | /typings 41 | 42 | # System Files 43 | .DS_Store 44 | Thumbs.db 45 | -------------------------------------------------------------------------------- /frontend/README.md: -------------------------------------------------------------------------------- 1 | # Frontend 2 | 3 | This project was generated with [Angular CLI](https://github.com/angular/angular-cli) version 7.2.1. 4 | 5 | ## Development server 6 | 7 | Run `ng serve` for a dev server. Navigate to `http://localhost:4200/`. The app will automatically reload if you change any of the source files. 8 | 9 | ## Code scaffolding 10 | 11 | Run `ng generate component component-name` to generate a new component. You can also use `ng generate directive|pipe|service|class|guard|interface|enum|module`. 12 | 13 | ## Build 14 | 15 | Run `ng build` to build the project. The build artifacts will be stored in the `dist/` directory. Use the `--prod` flag for a production build. 16 | 17 | ## Running unit tests 18 | 19 | Run `ng test` to execute the unit tests via [Karma](https://karma-runner.github.io). 20 | 21 | ## Running end-to-end tests 22 | 23 | Run `ng e2e` to execute the end-to-end tests via [Protractor](http://www.protractortest.org/). 24 | 25 | ## Further help 26 | 27 | To get more help on the Angular CLI use `ng help` or go check out the [Angular CLI README](https://github.com/angular/angular-cli/blob/master/README.md). 28 | -------------------------------------------------------------------------------- /frontend/angular.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "./node_modules/@angular/cli/lib/config/schema.json", 3 | "version": 1, 4 | "newProjectRoot": "projects", 5 | "projects": { 6 | "frontend": { 7 | "root": "", 8 | "sourceRoot": "src", 9 | "projectType": "application", 10 | "prefix": "app", 11 | "schematics": { 12 | "@schematics/angular:component": { 13 | "styleext": "scss" 14 | } 15 | }, 16 | "architect": { 17 | "build": { 18 | "builder": "@angular-devkit/build-angular:browser", 19 | "options": { 20 | "outputPath": "dist/frontend", 21 | "index": "src/index.html", 22 | "main": "src/main.ts", 23 | "polyfills": "src/polyfills.ts", 24 | "tsConfig": "src/tsconfig.app.json", 25 | "assets": [ 26 | "src/favicon.ico", 27 | "src/assets" 28 | ], 29 | "styles": [ 30 | "src/styles.scss" 31 | ], 32 | "scripts": [] 33 | }, 34 | "configurations": { 35 | "production": { 36 | "fileReplacements": [ 37 | { 38 | "replace": "src/environments/environment.ts", 39 | "with": "src/environments/environment.prod.ts" 40 | } 41 | ], 42 | "optimization": true, 43 | "outputHashing": "all", 44 | "sourceMap": false, 45 | "extractCss": true, 46 | "namedChunks": false, 47 | "aot": true, 48 | "extractLicenses": true, 49 | "vendorChunk": false, 50 | "buildOptimizer": true, 51 | "budgets": [ 52 | { 53 | "type": "initial", 54 | "maximumWarning": "2mb", 55 | "maximumError": "5mb" 56 | } 57 | ] 58 | } 59 | } 60 | }, 61 | "serve": { 62 | "builder": "@angular-devkit/build-angular:dev-server", 63 | "options": { 64 | "browserTarget": "frontend:build", 65 | "proxyConfig": "proxy.config.json" 66 | }, 67 | "configurations": { 68 | "production": { 69 | "browserTarget": "frontend:build:production" 70 | } 71 | } 72 | }, 73 | "extract-i18n": { 74 | "builder": "@angular-devkit/build-angular:extract-i18n", 75 | "options": { 76 | "browserTarget": "frontend:build" 77 | } 78 | }, 79 | "test": { 80 | "builder": "@angular-devkit/build-angular:karma", 81 | "options": { 82 | "main": "src/test.ts", 83 | "polyfills": "src/polyfills.ts", 84 | "tsConfig": "src/tsconfig.spec.json", 85 | "karmaConfig": "src/karma.conf.js", 86 | "styles": [ 87 | "src/styles.scss" 88 | ], 89 | "scripts": [], 90 | "assets": [ 91 | "src/favicon.ico", 92 | "src/assets" 93 | ] 94 | } 95 | }, 96 | "lint": { 97 | "builder": "@angular-devkit/build-angular:tslint", 98 | "options": { 99 | "tsConfig": [ 100 | "src/tsconfig.app.json", 101 | "src/tsconfig.spec.json" 102 | ], 103 | "exclude": [ 104 | "**/node_modules/**" 105 | ] 106 | } 107 | } 108 | } 109 | }, 110 | "frontend-e2e": { 111 | "root": "e2e/", 112 | "projectType": "application", 113 | "prefix": "", 114 | "architect": { 115 | "e2e": { 116 | "builder": "@angular-devkit/build-angular:protractor", 117 | "options": { 118 | "protractorConfig": "e2e/protractor.conf.js", 119 | "devServerTarget": "frontend:serve" 120 | }, 121 | "configurations": { 122 | "production": { 123 | "devServerTarget": "frontend:serve:production" 124 | } 125 | } 126 | }, 127 | "lint": { 128 | "builder": "@angular-devkit/build-angular:tslint", 129 | "options": { 130 | "tsConfig": "e2e/tsconfig.e2e.json", 131 | "exclude": [ 132 | "**/node_modules/**" 133 | ] 134 | } 135 | } 136 | } 137 | } 138 | }, 139 | "defaultProject": "frontend" 140 | } 141 | -------------------------------------------------------------------------------- /frontend/e2e/protractor.conf.js: -------------------------------------------------------------------------------- 1 | // Protractor configuration file, see link for more information 2 | // https://github.com/angular/protractor/blob/master/lib/config.ts 3 | 4 | const { SpecReporter } = require('jasmine-spec-reporter'); 5 | 6 | exports.config = { 7 | allScriptsTimeout: 11000, 8 | specs: [ 9 | './src/**/*.e2e-spec.ts' 10 | ], 11 | capabilities: { 12 | 'browserName': 'chrome' 13 | }, 14 | directConnect: true, 15 | baseUrl: 'http://localhost:4200/', 16 | framework: 'jasmine', 17 | jasmineNodeOpts: { 18 | showColors: true, 19 | defaultTimeoutInterval: 30000, 20 | print: function() {} 21 | }, 22 | onPrepare() { 23 | require('ts-node').register({ 24 | project: require('path').join(__dirname, './tsconfig.e2e.json') 25 | }); 26 | jasmine.getEnv().addReporter(new SpecReporter({ spec: { displayStacktrace: true } })); 27 | } 28 | }; -------------------------------------------------------------------------------- /frontend/e2e/src/app.e2e-spec.ts: -------------------------------------------------------------------------------- 1 | import { AppPage } from './app.po'; 2 | 3 | describe('workspace-project App', () => { 4 | let page: AppPage; 5 | 6 | beforeEach(() => { 7 | page = new AppPage(); 8 | }); 9 | 10 | it('should display welcome message', () => { 11 | page.navigateTo(); 12 | expect(page.getTitleText()).toEqual('Welcome to frontend!'); 13 | }); 14 | }); 15 | -------------------------------------------------------------------------------- /frontend/e2e/src/app.po.ts: -------------------------------------------------------------------------------- 1 | import { browser, by, element } from 'protractor'; 2 | 3 | export class AppPage { 4 | navigateTo() { 5 | return browser.get('/'); 6 | } 7 | 8 | getTitleText() { 9 | return element(by.css('app-root h1')).getText(); 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /frontend/e2e/tsconfig.e2e.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../tsconfig.json", 3 | "compilerOptions": { 4 | "outDir": "../out-tsc/app", 5 | "module": "commonjs", 6 | "target": "es5", 7 | "types": [ 8 | "jasmine", 9 | "jasminewd2", 10 | "node" 11 | ] 12 | } 13 | } -------------------------------------------------------------------------------- /frontend/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "frontend", 3 | "version": "0.0.0", 4 | "scripts": { 5 | "ng": "ng", 6 | "start": "ng serve", 7 | "build": "ng build", 8 | "build:prod": "ng build --prod", 9 | "test": "ng test", 10 | "lint": "ng lint", 11 | "e2e": "ng e2e" 12 | }, 13 | "private": true, 14 | "dependencies": { 15 | "@angular/animations": "~7.2.0", 16 | "@angular/common": "~7.2.0", 17 | "@angular/compiler": "~7.2.0", 18 | "@angular/core": "~7.2.0", 19 | "@angular/forms": "~7.2.0", 20 | "@angular/platform-browser": "~7.2.0", 21 | "@angular/platform-browser-dynamic": "~7.2.0", 22 | "@angular/router": "~7.2.0", 23 | "@fortawesome/angular-fontawesome": "^0.3.0", 24 | "@fortawesome/fontawesome-svg-core": "^1.2.12", 25 | "@fortawesome/free-brands-svg-icons": "^5.6.3", 26 | "@fortawesome/free-solid-svg-icons": "^5.6.3", 27 | "@ng-bootstrap/ng-bootstrap": "4.0.1", 28 | "bootstrap": "^4.2.1", 29 | "core-js": "^2.5.4", 30 | "rxjs": "~6.3.3", 31 | "tslib": "^1.9.0", 32 | "zone.js": "~0.8.26" 33 | }, 34 | "devDependencies": { 35 | "@angular-devkit/build-angular": "~0.12.0", 36 | "@angular/cli": "~7.2.1", 37 | "@angular/compiler-cli": "~7.2.0", 38 | "@angular/language-service": "~7.2.0", 39 | "@types/node": "~8.9.4", 40 | "@types/jasmine": "~2.8.8", 41 | "@types/jasminewd2": "~2.0.3", 42 | "codelyzer": "~4.5.0", 43 | "jasmine-core": "~2.99.1", 44 | "jasmine-spec-reporter": "~4.2.1", 45 | "karma": "~3.1.1", 46 | "karma-chrome-launcher": "~2.2.0", 47 | "karma-coverage-istanbul-reporter": "~2.0.1", 48 | "karma-jasmine": "~1.1.2", 49 | "karma-jasmine-html-reporter": "^0.2.2", 50 | "protractor": "~5.4.0", 51 | "ts-node": "~7.0.0", 52 | "tslint": "~5.11.0", 53 | "typescript": "~3.2.2" 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /frontend/proxy.config.json: -------------------------------------------------------------------------------- 1 | { 2 | "/todos": { 3 | "target": "https://d35eplr25bjhrs.cloudfront.net", 4 | "secure": true, 5 | "changeOrigin": true 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /frontend/src/app/app-routing.module.ts: -------------------------------------------------------------------------------- 1 | import {NgModule} from '@angular/core'; 2 | import {RouterModule, Routes} from '@angular/router'; 3 | import {TodoListComponent} from './todo-list/todo-list.component'; 4 | 5 | const routes : Routes = [ 6 | {path: '', pathMatch: 'full', redirectTo: 'todolist'}, 7 | {path: 'todolist', component: TodoListComponent}, 8 | ]; 9 | 10 | @NgModule({ 11 | imports: [RouterModule.forRoot(routes)], 12 | exports: [RouterModule] 13 | }) 14 | export class AppRoutingModule { 15 | } 16 | -------------------------------------------------------------------------------- /frontend/src/app/app.component.html: -------------------------------------------------------------------------------- 1 | 2 | 3 |
4 | 5 | -------------------------------------------------------------------------------- /frontend/src/app/app.component.scss: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/taimos/serverless-todo-demo/3ec0de9df428af699b8e5eab3014ceb89bc1c8cb/frontend/src/app/app.component.scss -------------------------------------------------------------------------------- /frontend/src/app/app.component.spec.ts: -------------------------------------------------------------------------------- 1 | import {async, TestBed} from '@angular/core/testing'; 2 | import {RouterTestingModule} from '@angular/router/testing'; 3 | import {AppComponent} from './app.component'; 4 | 5 | describe('AppComponent', () => { 6 | beforeEach(async(() => { 7 | TestBed.configureTestingModule({ 8 | imports: [ 9 | RouterTestingModule 10 | ], 11 | declarations: [ 12 | AppComponent 13 | ], 14 | }).compileComponents(); 15 | })); 16 | 17 | it('should create the app', () => { 18 | const fixture = TestBed.createComponent(AppComponent); 19 | const app = fixture.debugElement.componentInstance; 20 | expect(app).toBeTruthy(); 21 | }); 22 | 23 | it(`should have as title 'frontend'`, () => { 24 | const fixture = TestBed.createComponent(AppComponent); 25 | const app = fixture.debugElement.componentInstance; 26 | expect(app.title).toEqual('frontend'); 27 | }); 28 | 29 | it('should render title in a h1 tag', () => { 30 | const fixture = TestBed.createComponent(AppComponent); 31 | fixture.detectChanges(); 32 | const compiled = fixture.debugElement.nativeElement; 33 | expect(compiled.querySelector('h1').textContent).toContain('Welcome to frontend!'); 34 | }); 35 | }); 36 | -------------------------------------------------------------------------------- /frontend/src/app/app.component.ts: -------------------------------------------------------------------------------- 1 | import {Component} from '@angular/core'; 2 | 3 | @Component({ 4 | selector: 'app-root', 5 | templateUrl: './app.component.html', 6 | styleUrls: ['./app.component.scss'] 7 | }) 8 | export class AppComponent { 9 | title = 'frontend'; 10 | } 11 | -------------------------------------------------------------------------------- /frontend/src/app/app.module.ts: -------------------------------------------------------------------------------- 1 | import {BrowserModule} from '@angular/platform-browser'; 2 | import {NgModule} from '@angular/core'; 3 | import {FormsModule} from '@angular/forms'; 4 | import {NgbModule} from '@ng-bootstrap/ng-bootstrap'; 5 | 6 | import {AppRoutingModule} from './app-routing.module'; 7 | import {AppComponent} from './app.component'; 8 | import {PageHeaderComponent} from './page-header/page-header.component'; 9 | import {PageFooterComponent} from './page-footer/page-footer.component'; 10 | import {TodoListComponent} from './todo-list/todo-list.component'; 11 | import {HttpClientModule} from '@angular/common/http'; 12 | 13 | import { FontAwesomeModule } from '@fortawesome/angular-fontawesome'; 14 | import { library } from '@fortawesome/fontawesome-svg-core'; 15 | import { faArrowRight, faRecycle } from '@fortawesome/free-solid-svg-icons'; 16 | 17 | library.add(faArrowRight, faRecycle); 18 | 19 | @NgModule({ 20 | declarations: [ 21 | AppComponent, 22 | PageHeaderComponent, 23 | PageFooterComponent, 24 | TodoListComponent, 25 | ], 26 | imports: [ 27 | BrowserModule, 28 | AppRoutingModule, 29 | FormsModule, 30 | NgbModule, 31 | HttpClientModule, 32 | FontAwesomeModule, 33 | ], 34 | providers: [], 35 | bootstrap: [AppComponent] 36 | }) 37 | export class AppModule { 38 | } 39 | -------------------------------------------------------------------------------- /frontend/src/app/page-footer/page-footer.component.html: -------------------------------------------------------------------------------- 1 | 2 |
3 |
4 |
5 |

Copyright © Taimos GmbH 2019

6 |
7 |
8 | 9 |
10 | -------------------------------------------------------------------------------- /frontend/src/app/page-footer/page-footer.component.scss: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/taimos/serverless-todo-demo/3ec0de9df428af699b8e5eab3014ceb89bc1c8cb/frontend/src/app/page-footer/page-footer.component.scss -------------------------------------------------------------------------------- /frontend/src/app/page-footer/page-footer.component.spec.ts: -------------------------------------------------------------------------------- 1 | import {async, ComponentFixture, TestBed} from '@angular/core/testing'; 2 | 3 | import {PageFooterComponent} from './page-footer.component'; 4 | 5 | describe('PageFooterComponent', () => { 6 | let component : PageFooterComponent; 7 | let fixture : ComponentFixture; 8 | 9 | beforeEach(async(() => { 10 | TestBed.configureTestingModule({ 11 | declarations: [PageFooterComponent] 12 | }) 13 | .compileComponents(); 14 | })); 15 | 16 | beforeEach(() => { 17 | fixture = TestBed.createComponent(PageFooterComponent); 18 | component = fixture.componentInstance; 19 | fixture.detectChanges(); 20 | }); 21 | 22 | it('should create', () => { 23 | expect(component).toBeTruthy(); 24 | }); 25 | }); 26 | -------------------------------------------------------------------------------- /frontend/src/app/page-footer/page-footer.component.ts: -------------------------------------------------------------------------------- 1 | import {Component, OnInit} from '@angular/core'; 2 | 3 | @Component({ 4 | selector: 'app-page-footer', 5 | templateUrl: './page-footer.component.html', 6 | styleUrls: ['./page-footer.component.scss'] 7 | }) 8 | export class PageFooterComponent implements OnInit { 9 | 10 | constructor() { 11 | } 12 | 13 | ngOnInit() { 14 | } 15 | 16 | } 17 | -------------------------------------------------------------------------------- /frontend/src/app/page-header/page-header.component.html: -------------------------------------------------------------------------------- 1 | 2 |
3 |
4 |

ToDo List

5 |
6 |
7 | 8 | -------------------------------------------------------------------------------- /frontend/src/app/page-header/page-header.component.scss: -------------------------------------------------------------------------------- 1 | h1 { 2 | margin-top: 50px; 3 | } 4 | -------------------------------------------------------------------------------- /frontend/src/app/page-header/page-header.component.spec.ts: -------------------------------------------------------------------------------- 1 | import {async, ComponentFixture, TestBed} from '@angular/core/testing'; 2 | 3 | import {PageHeaderComponent} from './page-header.component'; 4 | 5 | describe('PageHeaderComponent', () => { 6 | let component : PageHeaderComponent; 7 | let fixture : ComponentFixture; 8 | 9 | beforeEach(async(() => { 10 | TestBed.configureTestingModule({ 11 | declarations: [PageHeaderComponent] 12 | }) 13 | .compileComponents(); 14 | })); 15 | 16 | beforeEach(() => { 17 | fixture = TestBed.createComponent(PageHeaderComponent); 18 | component = fixture.componentInstance; 19 | fixture.detectChanges(); 20 | }); 21 | 22 | it('should create', () => { 23 | expect(component).toBeTruthy(); 24 | }); 25 | }); 26 | -------------------------------------------------------------------------------- /frontend/src/app/page-header/page-header.component.ts: -------------------------------------------------------------------------------- 1 | import {Component, OnInit} from '@angular/core'; 2 | 3 | @Component({ 4 | selector: 'app-page-header', 5 | templateUrl: './page-header.component.html', 6 | styleUrls: ['./page-header.component.scss'] 7 | }) 8 | export class PageHeaderComponent implements OnInit { 9 | 10 | constructor() { 11 | } 12 | 13 | ngOnInit() { 14 | } 15 | 16 | } 17 | -------------------------------------------------------------------------------- /frontend/src/app/todo-list/todo-list.component.html: -------------------------------------------------------------------------------- 1 |
2 |
3 |
4 | 5 | Save 6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 34 | 35 | 36 |
IDTextState
{{todo.id}}{{todo.text}}{{todo.state}}  27 | 28 | 29 | 30 | 31 | 32 | 33 |
37 |
38 |
39 | -------------------------------------------------------------------------------- /frontend/src/app/todo-list/todo-list.component.scss: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/taimos/serverless-todo-demo/3ec0de9df428af699b8e5eab3014ceb89bc1c8cb/frontend/src/app/todo-list/todo-list.component.scss -------------------------------------------------------------------------------- /frontend/src/app/todo-list/todo-list.component.spec.ts: -------------------------------------------------------------------------------- 1 | import {async, ComponentFixture, TestBed} from '@angular/core/testing'; 2 | 3 | import {TodoListComponent} from './todo-list.component'; 4 | 5 | describe('TodoListComponent', () => { 6 | let component : TodoListComponent; 7 | let fixture : ComponentFixture; 8 | 9 | beforeEach(async(() => { 10 | TestBed.configureTestingModule({ 11 | declarations: [TodoListComponent] 12 | }) 13 | .compileComponents(); 14 | })); 15 | 16 | beforeEach(() => { 17 | fixture = TestBed.createComponent(TodoListComponent); 18 | component = fixture.componentInstance; 19 | fixture.detectChanges(); 20 | }); 21 | 22 | it('should create', () => { 23 | expect(component).toBeTruthy(); 24 | }); 25 | }); 26 | -------------------------------------------------------------------------------- /frontend/src/app/todo-list/todo-list.component.ts: -------------------------------------------------------------------------------- 1 | import {Component, OnInit} from '@angular/core'; 2 | import {ToDo, TodoService} from '../todo.service'; 3 | 4 | @Component({ 5 | selector: 'app-todo-list', 6 | templateUrl: './todo-list.component.html', 7 | styleUrls: ['./todo-list.component.scss'] 8 | }) 9 | export class TodoListComponent implements OnInit { 10 | 11 | todos : ToDo[]; 12 | text : string; 13 | 14 | private static nextState(state) { 15 | switch (state) { 16 | case 'OPEN': 17 | return 'IN_PROGRESS'; 18 | case 'IN_PROGRESS': 19 | return 'DONE'; 20 | default: 21 | return 'DONE'; 22 | } 23 | } 24 | 25 | constructor(private todoService : TodoService) { 26 | } 27 | 28 | ngOnInit() { 29 | this.todoService.getList().subscribe((list) => { 30 | console.log(list); 31 | this.todos = list; 32 | }); 33 | } 34 | 35 | proceed(todo) { 36 | if (!todo) { 37 | return; 38 | } 39 | this.updateTodo(todo, TodoListComponent.nextState(todo.state)); 40 | } 41 | 42 | reopen(todo) { 43 | if (!todo) { 44 | return; 45 | } 46 | this.updateTodo(todo, 'OPEN'); 47 | } 48 | 49 | updateTodo(todo, newState) { 50 | const toSave = JSON.parse(JSON.stringify(todo)); 51 | toSave.state = newState; 52 | this.todoService.update(toSave).subscribe(() => { 53 | this.ngOnInit(); 54 | }); 55 | } 56 | 57 | create() { 58 | const todo = { 59 | text: this.text, 60 | state: 'OPEN' 61 | }; 62 | this.todoService.create(todo).subscribe(() => { 63 | this.ngOnInit(); 64 | }); 65 | } 66 | 67 | } 68 | -------------------------------------------------------------------------------- /frontend/src/app/todo.service.spec.ts: -------------------------------------------------------------------------------- 1 | import { TestBed } from '@angular/core/testing'; 2 | 3 | import { TodoService } from './todo.service'; 4 | 5 | describe('TodoService', () => { 6 | beforeEach(() => TestBed.configureTestingModule({})); 7 | 8 | it('should be created', () => { 9 | const service: TodoService = TestBed.get(TodoService); 10 | expect(service).toBeTruthy(); 11 | }); 12 | }); 13 | -------------------------------------------------------------------------------- /frontend/src/app/todo.service.ts: -------------------------------------------------------------------------------- 1 | import {Injectable} from '@angular/core'; 2 | import {HttpClient} from '@angular/common/http'; 3 | import {Observable} from 'rxjs'; 4 | 5 | export interface ToDo { 6 | id : string; 7 | text : string; 8 | state : string; 9 | } 10 | 11 | @Injectable({ 12 | providedIn: 'root' 13 | }) 14 | export class TodoService { 15 | 16 | constructor(private http : HttpClient) { 17 | } 18 | 19 | getList() : Observable { 20 | return >this.http.get('/todos'); 21 | } 22 | 23 | create(todo) : Observable { 24 | return >this.http.post('/todos', todo); 25 | } 26 | 27 | update(todo) : Observable { 28 | return >this.http.put('/todos/' + todo.id, todo); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /frontend/src/assets/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/taimos/serverless-todo-demo/3ec0de9df428af699b8e5eab3014ceb89bc1c8cb/frontend/src/assets/.gitkeep -------------------------------------------------------------------------------- /frontend/src/browserslist: -------------------------------------------------------------------------------- 1 | # This file is currently used by autoprefixer to adjust CSS to support the below specified browsers 2 | # For additional information regarding the format and rule options, please see: 3 | # https://github.com/browserslist/browserslist#queries 4 | # 5 | # For IE 9-11 support, please remove 'not' from the last line of the file and adjust as needed 6 | 7 | > 0.5% 8 | last 2 versions 9 | Firefox ESR 10 | not dead 11 | not IE 9-11 -------------------------------------------------------------------------------- /frontend/src/environments/environment.prod.ts: -------------------------------------------------------------------------------- 1 | export const environment = { 2 | production: true 3 | }; 4 | -------------------------------------------------------------------------------- /frontend/src/environments/environment.ts: -------------------------------------------------------------------------------- 1 | // This file can be replaced during build by using the `fileReplacements` array. 2 | // `ng build --prod` replaces `environment.ts` with `environment.prod.ts`. 3 | // The list of file replacements can be found in `angular.json`. 4 | 5 | export const environment = { 6 | production: false 7 | }; 8 | 9 | /* 10 | * For easier debugging in development mode, you can import the following file 11 | * to ignore zone related error stack frames such as `zone.run`, `zoneDelegate.invokeTask`. 12 | * 13 | * This import should be commented out in production mode because it will have a negative impact 14 | * on performance if an error is thrown. 15 | */ 16 | // import 'zone.js/dist/zone-error'; // Included with Angular CLI. 17 | -------------------------------------------------------------------------------- /frontend/src/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/taimos/serverless-todo-demo/3ec0de9df428af699b8e5eab3014ceb89bc1c8cb/frontend/src/favicon.ico -------------------------------------------------------------------------------- /frontend/src/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Serverless Demo - Todo List 6 | 7 | 8 | 9 | 10 | 11 | 12 |
13 | 14 |
15 | 16 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /frontend/src/karma.conf.js: -------------------------------------------------------------------------------- 1 | // Karma configuration file, see link for more information 2 | // https://karma-runner.github.io/1.0/config/configuration-file.html 3 | 4 | module.exports = function (config) { 5 | config.set({ 6 | basePath: '', 7 | frameworks: ['jasmine', '@angular-devkit/build-angular'], 8 | plugins: [ 9 | require('karma-jasmine'), 10 | require('karma-chrome-launcher'), 11 | require('karma-jasmine-html-reporter'), 12 | require('karma-coverage-istanbul-reporter'), 13 | require('@angular-devkit/build-angular/plugins/karma') 14 | ], 15 | client: { 16 | clearContext: false // leave Jasmine Spec Runner output visible in browser 17 | }, 18 | coverageIstanbulReporter: { 19 | dir: require('path').join(__dirname, '../coverage'), 20 | reports: ['html', 'lcovonly', 'text-summary'], 21 | fixWebpackSourcePaths: true 22 | }, 23 | reporters: ['progress', 'kjhtml'], 24 | port: 9876, 25 | colors: true, 26 | logLevel: config.LOG_INFO, 27 | autoWatch: true, 28 | browsers: ['Chrome'], 29 | singleRun: false 30 | }); 31 | }; -------------------------------------------------------------------------------- /frontend/src/main.ts: -------------------------------------------------------------------------------- 1 | import { enableProdMode } from '@angular/core'; 2 | import { platformBrowserDynamic } from '@angular/platform-browser-dynamic'; 3 | 4 | import { AppModule } from './app/app.module'; 5 | import { environment } from './environments/environment'; 6 | 7 | if (environment.production) { 8 | enableProdMode(); 9 | } 10 | 11 | platformBrowserDynamic().bootstrapModule(AppModule) 12 | .catch(err => console.error(err)); 13 | -------------------------------------------------------------------------------- /frontend/src/polyfills.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * This file includes polyfills needed by Angular and is loaded before the app. 3 | * You can add your own extra polyfills to this file. 4 | * 5 | * This file is divided into 2 sections: 6 | * 1. Browser polyfills. These are applied before loading ZoneJS and are sorted by browsers. 7 | * 2. Application imports. Files imported after ZoneJS that should be loaded before your main 8 | * file. 9 | * 10 | * The current setup is for so-called "evergreen" browsers; the last versions of browsers that 11 | * automatically update themselves. This includes Safari >= 10, Chrome >= 55 (including Opera), 12 | * Edge >= 13 on the desktop, and iOS 10 and Chrome on mobile. 13 | * 14 | * Learn more in https://angular.io/guide/browser-support 15 | */ 16 | 17 | /*************************************************************************************************** 18 | * BROWSER POLYFILLS 19 | */ 20 | 21 | /** IE9, IE10, IE11, and Chrome <55 requires all of the following polyfills. 22 | * This also includes Android Emulators with older versions of Chrome and Google Search/Googlebot 23 | */ 24 | 25 | // import 'core-js/es6/symbol'; 26 | // import 'core-js/es6/object'; 27 | // import 'core-js/es6/function'; 28 | // import 'core-js/es6/parse-int'; 29 | // import 'core-js/es6/parse-float'; 30 | // import 'core-js/es6/number'; 31 | // import 'core-js/es6/math'; 32 | // import 'core-js/es6/string'; 33 | // import 'core-js/es6/date'; 34 | // import 'core-js/es6/array'; 35 | // import 'core-js/es6/regexp'; 36 | // import 'core-js/es6/map'; 37 | // import 'core-js/es6/weak-map'; 38 | // import 'core-js/es6/set'; 39 | 40 | /** IE10 and IE11 requires the following for NgClass support on SVG elements */ 41 | // import 'classlist.js'; // Run `npm install --save classlist.js`. 42 | 43 | /** IE10 and IE11 requires the following for the Reflect API. */ 44 | // import 'core-js/es6/reflect'; 45 | 46 | /** 47 | * Web Animations `@angular/platform-browser/animations` 48 | * Only required if AnimationBuilder is used within the application and using IE/Edge or Safari. 49 | * Standard animation support in Angular DOES NOT require any polyfills (as of Angular 6.0). 50 | */ 51 | // import 'web-animations-js'; // Run `npm install --save web-animations-js`. 52 | 53 | /** 54 | * By default, zone.js will patch all possible macroTask and DomEvents 55 | * user can disable parts of macroTask/DomEvents patch by setting following flags 56 | * because those flags need to be set before `zone.js` being loaded, and webpack 57 | * will put import in the top of bundle, so user need to create a separate file 58 | * in this directory (for example: zone-flags.ts), and put the following flags 59 | * into that file, and then add the following code before importing zone.js. 60 | * import './zone-flags.ts'; 61 | * 62 | * The flags allowed in zone-flags.ts are listed here. 63 | * 64 | * The following flags will work for all browsers. 65 | * 66 | * (window as any).__Zone_disable_requestAnimationFrame = true; // disable patch requestAnimationFrame 67 | * (window as any).__Zone_disable_on_property = true; // disable patch onProperty such as onclick 68 | * (window as any).__zone_symbol__BLACK_LISTED_EVENTS = ['scroll', 'mousemove']; // disable patch specified eventNames 69 | * 70 | * in IE/Edge developer tools, the addEventListener will also be wrapped by zone.js 71 | * with the following flag, it will bypass `zone.js` patch for IE/Edge 72 | * 73 | * (window as any).__Zone_enable_cross_context_check = true; 74 | * 75 | */ 76 | 77 | /*************************************************************************************************** 78 | * Zone JS is required by default for Angular itself. 79 | */ 80 | import 'zone.js/dist/zone'; // Included with Angular CLI. 81 | 82 | 83 | /*************************************************************************************************** 84 | * APPLICATION IMPORTS 85 | */ 86 | -------------------------------------------------------------------------------- /frontend/src/styles.scss: -------------------------------------------------------------------------------- 1 | /* You can add global styles to this file, and also import other style files */ 2 | @import url('https://fonts.googleapis.com/css?family=Montserrat:400,700,200|Open+Sans+Condensed:700'); 3 | @import "~bootstrap/scss/bootstrap.scss"; 4 | -------------------------------------------------------------------------------- /frontend/src/test.ts: -------------------------------------------------------------------------------- 1 | // This file is required by karma.conf.js and loads recursively all the .spec and framework files 2 | 3 | import 'zone.js/dist/zone-testing'; 4 | import { getTestBed } from '@angular/core/testing'; 5 | import { 6 | BrowserDynamicTestingModule, 7 | platformBrowserDynamicTesting 8 | } from '@angular/platform-browser-dynamic/testing'; 9 | 10 | declare const require: any; 11 | 12 | // First, initialize the Angular testing environment. 13 | getTestBed().initTestEnvironment( 14 | BrowserDynamicTestingModule, 15 | platformBrowserDynamicTesting() 16 | ); 17 | // Then we find all the tests. 18 | const context = require.context('./', true, /\.spec\.ts$/); 19 | // And load the modules. 20 | context.keys().map(context); 21 | -------------------------------------------------------------------------------- /frontend/src/tsconfig.app.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../tsconfig.json", 3 | "compilerOptions": { 4 | "outDir": "../out-tsc/app", 5 | "types": [] 6 | }, 7 | "exclude": [ 8 | "test.ts", 9 | "**/*.spec.ts" 10 | ] 11 | } 12 | -------------------------------------------------------------------------------- /frontend/src/tsconfig.spec.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../tsconfig.json", 3 | "compilerOptions": { 4 | "outDir": "../out-tsc/spec", 5 | "types": [ 6 | "jasmine", 7 | "node" 8 | ] 9 | }, 10 | "files": [ 11 | "test.ts", 12 | "polyfills.ts" 13 | ], 14 | "include": [ 15 | "**/*.spec.ts", 16 | "**/*.d.ts" 17 | ] 18 | } 19 | -------------------------------------------------------------------------------- /frontend/src/tslint.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../tslint.json", 3 | "rules": { 4 | "directive-selector": [ 5 | true, 6 | "attribute", 7 | "app", 8 | "camelCase" 9 | ], 10 | "component-selector": [ 11 | true, 12 | "element", 13 | "app", 14 | "kebab-case" 15 | ] 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /frontend/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compileOnSave": false, 3 | "compilerOptions": { 4 | "baseUrl": "./", 5 | "outDir": "./dist/out-tsc", 6 | "sourceMap": true, 7 | "declaration": false, 8 | "module": "es2015", 9 | "moduleResolution": "node", 10 | "emitDecoratorMetadata": true, 11 | "experimentalDecorators": true, 12 | "importHelpers": true, 13 | "target": "es5", 14 | "typeRoots": [ 15 | "node_modules/@types" 16 | ], 17 | "lib": [ 18 | "es2018", 19 | "dom" 20 | ] 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /frontend/tslint.json: -------------------------------------------------------------------------------- 1 | { 2 | "rulesDirectory": [ 3 | "codelyzer" 4 | ], 5 | "rules": { 6 | "arrow-return-shorthand": true, 7 | "callable-types": true, 8 | "class-name": true, 9 | "comment-format": [ 10 | true, 11 | "check-space" 12 | ], 13 | "curly": true, 14 | "deprecation": { 15 | "severity": "warn" 16 | }, 17 | "eofline": true, 18 | "forin": true, 19 | "import-blacklist": [ 20 | true, 21 | "rxjs/Rx" 22 | ], 23 | "import-spacing": true, 24 | "indent": [ 25 | true, 26 | "spaces" 27 | ], 28 | "interface-over-type-literal": true, 29 | "label-position": true, 30 | "max-line-length": [ 31 | true, 32 | 140 33 | ], 34 | "member-access": false, 35 | "member-ordering": [ 36 | true, 37 | { 38 | "order": [ 39 | "static-field", 40 | "instance-field", 41 | "static-method", 42 | "instance-method" 43 | ] 44 | } 45 | ], 46 | "no-arg": true, 47 | "no-bitwise": true, 48 | "no-console": [ 49 | true, 50 | "debug", 51 | "info", 52 | "time", 53 | "timeEnd", 54 | "trace" 55 | ], 56 | "no-construct": true, 57 | "no-debugger": true, 58 | "no-duplicate-super": true, 59 | "no-empty": false, 60 | "no-empty-interface": true, 61 | "no-eval": true, 62 | "no-inferrable-types": [ 63 | true, 64 | "ignore-params" 65 | ], 66 | "no-misused-new": true, 67 | "no-non-null-assertion": true, 68 | "no-redundant-jsdoc": true, 69 | "no-shadowed-variable": true, 70 | "no-string-literal": false, 71 | "no-string-throw": true, 72 | "no-switch-case-fall-through": true, 73 | "no-trailing-whitespace": true, 74 | "no-unnecessary-initializer": true, 75 | "no-unused-expression": true, 76 | "no-use-before-declare": true, 77 | "no-var-keyword": true, 78 | "object-literal-sort-keys": false, 79 | "one-line": [ 80 | true, 81 | "check-open-brace", 82 | "check-catch", 83 | "check-else", 84 | "check-whitespace" 85 | ], 86 | "prefer-const": true, 87 | "quotemark": [ 88 | true, 89 | "single" 90 | ], 91 | "radix": true, 92 | "semicolon": [ 93 | true, 94 | "always" 95 | ], 96 | "triple-equals": [ 97 | true, 98 | "allow-null-check" 99 | ], 100 | "unified-signatures": true, 101 | "variable-name": false, 102 | "whitespace": [ 103 | true, 104 | "check-branch", 105 | "check-decl", 106 | "check-operator", 107 | "check-separator", 108 | "check-type" 109 | ], 110 | "no-output-on-prefix": true, 111 | "use-input-property-decorator": true, 112 | "use-output-property-decorator": true, 113 | "use-host-property-decorator": true, 114 | "no-input-rename": true, 115 | "no-output-rename": true, 116 | "use-life-cycle-interface": true, 117 | "use-pipe-transform-interface": true, 118 | "component-class-suffix": true, 119 | "directive-class-suffix": true 120 | } 121 | } 122 | --------------------------------------------------------------------------------