Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Chinook Media Store #176

Draft
wants to merge 80 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
80 commits
Select commit Hold shift + click to select a range
7b5c164
creating cds model of chinook db
dimaanj Sep 29, 2020
788c288
add cli tool
dimaanj Sep 30, 2020
4038ac5
remove redundantt folder
dimaanj Oct 1, 2020
88aa865
remove redundantt folder
dimaanj Oct 1, 2020
8d712d2
add reorder for column names
dimaanj Oct 1, 2020
59a9d63
add tests. add to many associations
dimaanj Oct 3, 2020
22f3665
adjast regex for omiting id from column name
dimaanj Oct 3, 2020
19d56ee
remove redundant args
dimaanj Oct 3, 2020
88d2091
return timeout for mocha runner
dimaanj Oct 3, 2020
b5af207
add tracks main page. add get my tracks action
dimaanj Oct 8, 2020
a0233b9
adjust README.md with frontend repo link provided
dimaanj Oct 8, 2020
7708718
add getMyTracks option
dimaanj Oct 13, 2020
ffb2c92
remove compiled bundles from app
dimaanj Oct 13, 2020
6d7b789
add app bundles to medi-store
dimaanj Oct 13, 2020
f88de14
add mocked auth
dimaanj Oct 14, 2020
371aabc
add invoice action
dimaanj Oct 17, 2020
fdd992b
add getUser method
dimaanj Oct 19, 2020
843281d
reaname services
dimaanj Oct 23, 2020
c50b0a9
rename person type
dimaanj Oct 23, 2020
70ffd13
add status to invoices
dimaanj Oct 27, 2020
8e9aa26
add cancel invoice action
dimaanj Oct 29, 2020
0cf1def
add customer restriction when browsing invoices
dimaanj Oct 30, 2020
058fafc
refactor import usage. refactor invoices implementation
dimaanj Nov 3, 2020
0a8be80
add custom authentication checks
dimaanj Nov 4, 2020
c549507
refactoring requests
dimaanj Nov 4, 2020
507583f
replacing restriction conditions
dimaanj Nov 4, 2020
ba68f96
refactoring code
dimaanj Nov 5, 2020
f4326ae
add compositions for cascade delete
dimaanj Nov 6, 2020
0fb9ec7
return bool flag
dimaanj Nov 9, 2020
49c04aa
providing initial data. replacing bycript with bycriptjs
dimaanj Nov 11, 2020
5e107ad
add dev only things
dimaanj Nov 11, 2020
72864ff
refactor csv data
dimaanj Nov 11, 2020
1e961a7
add frontend code. add deploy config
dimaanj Nov 14, 2020
86e79ab
add env vars. change db kind
dimaanj Nov 14, 2020
94c58ea
change invoiceDate impl
dimaanj Nov 16, 2020
95a741c
add hana kind
dimaanj Nov 16, 2020
bd70d5c
refactoring user settings in the frontend
dimaanj Nov 16, 2020
bd27f72
add flow when invalid credentials
dimaanj Nov 16, 2020
d0d7ec1
add response interceptors for refreshTokens method
dimaanj Nov 23, 2020
38d6ed7
refactoring error page
dimaanj Nov 24, 2020
04766c1
now create tracks method works properly
dimaanj Nov 24, 2020
3519ba0
clean up things
dimaanj Nov 24, 2020
531fef4
edit person page. remove invoicedItems on logout
dimaanj Nov 25, 2020
3dc028f
change readme.md. clean up console.logs. add check for exsisting invo…
dimaanj Nov 25, 2020
df83187
changing logger
dimaanj Nov 25, 2020
812228b
changing invoice request
dimaanj Nov 25, 2020
18f3b72
changing tests. removing importData func
dimaanj Nov 25, 2020
baa63f3
add .mta files to gitignore
dimaanj Nov 25, 2020
b1ad249
change token live time
dimaanj Nov 25, 2020
daa5caf
moving front app to subfolder. add webpack config with watch and dev-…
dimaanj Nov 29, 2020
30adfee
add app to gitignore
dimaanj Nov 29, 2020
d90c4e3
change gitignore. change server.js
dimaanj Nov 29, 2020
62e18e2
move xs-securiry.json
dimaanj Nov 29, 2020
a723d9f
change readme.md
dimaanj Nov 30, 2020
252514b
changing cds services
dimaanj Nov 30, 2020
9f5d02e
change readme.md. add folders description
dimaanj Nov 30, 2020
753202c
change words to lowwer case in readme.md
dimaanj Nov 30, 2020
4a10376
changing endings
dimaanj Nov 30, 2020
14d2bf8
changing readme.md style
dimaanj Nov 30, 2020
fa813a7
changing webpack-dev-server-config
dimaanj Nov 30, 2020
05a3148
remove unnecessary assosiation. add /index.html route to main page
dimaanj Dec 3, 2020
b216a10
add retry interceptor impl
dimaanj Dec 6, 2020
2338ab9
resolve quotation mark error when searching
dimaanj Dec 6, 2020
ae47021
changing retry number. add readme.md point
dimaanj Dec 7, 2020
bf8544e
change invoice action impl. changing .http sample file
dimaanj Dec 8, 2020
23e4ec2
change retry count
dimaanj Dec 9, 2020
4f10e83
update tests
dimaanj Dec 14, 2020
d7e41c0
change tests
dimaanj Dec 15, 2020
343eb05
Cleanup folder layout
danjoa Dec 16, 2020
b5bc869
re-including app folder
danjoa Dec 16, 2020
ca6bcbf
Moved to chinook + added .env
danjoa Dec 16, 2020
8c6eab9
change folders structure
dimaanj Dec 22, 2020
0d3ffa0
change tests
dimaanj Dec 23, 2020
675d642
changing chinook sql kind property to sql
dimaanj Dec 23, 2020
00c6063
returning subfolders names
dimaanj Dec 23, 2020
d19857d
returning package.json dependencies
dimaanj Dec 23, 2020
eda2fcc
change jest timeout. add @capire/chinook as dependency
dimaanj Dec 23, 2020
f993999
changing package.json scripts. adjusting mock datetime format
dimaanj Dec 24, 2020
372e5ea
add right datetime format
dimaanj Dec 24, 2020
b3ad71c
fix: getting marked tracks as single entity
dimaanj Mar 24, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions chinook/.env
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# REVISIT: This is not a good practice -> don't do it that way, we just did it to save some time :)
ACCESS_TOKEN_SECRET=secret
REFRESH_TOKEN_SECRET=refresh-secret
24 changes: 24 additions & 0 deletions chinook/.eslintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{
"extends": "eslint:recommended",
"env": {
"node": true,
"es6": true,
"jest": true
},
"parserOptions": {
"ecmaVersion": 2017
},
"globals": {
"SELECT": true,
"INSERT": true,
"UPDATE": true,
"DELETE": true,
"CREATE": true,
"DROP": true,
"cds": true
},
"rules": {
"no-console": "off",
"require-atomic-updates": "off"
}
}
35 changes: 35 additions & 0 deletions chinook/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# CAP media-store
_out
*.db
connection.properties
default-*.json
gen/
node_modules/
target/
package-lock.json
app/build

# html5Deployer
app/deployers/html5Deployer/resources/

# Web IDE, App Studio
.che/
.gen/

# MTA
*_mta_build_tmp
*.mtar
*.mta
mta_archives/

# Other
.DS_Store
*.orig
*.log

*.iml
*.flattened-pom.xml

# IDEs
# .vscode
# .idea
20 changes: 20 additions & 0 deletions chinook/.vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
// See https://go.microsoft.com/fwlink/?LinkId=827846 to learn about workspace recommendations.
// Extension identifier format: ${publisher}.${name}. Example: vscode.csharp

// List of extensions which should be recommended for users of this workspace.
"recommendations": [
// >>>>>>>> Add CDS Editor here as soon it is available of vscode marketplace!,
"dbaeumer.vscode-eslint",
"esbenp.prettier-vscode",
"mechatroner.rainbow-csv",
"humao.rest-client",
"alexcvzz.vscode-sqlite",
"hbenl.vscode-mocha-test-adapter",
"sdras.night-owl"
],
// List of extensions recommended by VS Code that should not be recommended for users of this workspace.
"unwantedRecommendations": [

]
}
17 changes: 17 additions & 0 deletions chinook/.vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [


{
"command": "cds run --with-mocks --in-memory?",
"name": "cds run",
"request": "launch",
"type": "node-terminal",
"skipFiles": ["<node_internals>/**"]
}
]
}
8 changes: 8 additions & 0 deletions chinook/.vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"files.exclude": {
"**/.gitignore": true,
"**/.git": true,
"**/.vscode": true
},
"files.watcherExclude": {}
}
25 changes: 25 additions & 0 deletions chinook/.vscode/tasks.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
{
// See https://go.microsoft.com/fwlink/?LinkId=733558
// for the documentation about the tasks.json format
"version": "2.0.0",
"tasks": [
{
"type": "shell",
"label": "cds watch",
"command": "cds",
"args": ["watch"],
"group": {
"kind": "build",
"isDefault": true
},
"problemMatcher": []
},
{
"type": "shell",
"label": "cds run",
"command": "cds",
"args": ["run", "--with-mocks", "--in-memory?"],
"problemMatcher": []
}
]
}
102 changes: 102 additions & 0 deletions chinook/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
# Getting Started

Welcome to your new project.

It contains these folders and files, following our recommended project layout:

| File or Folder | Purpose |
| ---------------- | ------------------------------------ |
| `app/` | will contain compiled front bundles |
| `app/front/` | contains frontend app on react |
| `app/deployers/` | contains deployment staff |
| `db/` | your domain models and data go here |
| `srv/` | your service models and code go here |
| `test/` | your services tests |
| `package.json` | project metadata and configuration |
| `mta.yaml` | deployment config |
| `readme.md` | this getting started guide |
| `server.js` | initial server set up |

## Development

- At first open a new terminal and run below command. It should create new sqlite source and fill initial data from `db/data`. You can browse database in any sqlite client

```json
npm run deploy
```

- Next, start cds service on 4004 port in watch mode:

```json
cds watch
```

- Open `app/front` folder and run next commands. This will install dependencies and run frontend src files watcher. When you will change src files your bundles in app directory will re-compiled. Now you can enjoy development:

```json
npm install
npm run watch
```

> For better frontend development experience use below command instead of watcher. This will start frontend dev server on 3000 port. Now your bundles will be hot reloaded, this means you do not need reload the page to see changes:
>
> ```json
> npm run start
> ```

## Test

- Change package.json db section

```json
"db": {
"kind": "sql"
}
```

- Run tests

```json
npm run test
```

## Deployment

- Make sure you already have hanatrial instance in your cockpit dashboard (SAP Cloud Platform).
Or if you are using hana instance - change it in mta.yaml config file from hanatrial to hana
- Change package.json db section

```json
"db": {
"kind": "hana"
}
```

- Authenticate to the Cloud Foundry:

```json
cf login
```

- Open `app/front` folder and run the following commands. This will create frontend production bundles in app subfolder:

```json
npm install
npm run build:prod
```

- Clean up app/deployers/html5Deployer/resources folder from the previous frontend build

- From root directory run:

```json
mbt build -t ./
cf deploy media-store_1.0.0.mtar
```

- Now your services should be deployed with hanatrial instance and filled with initial data

## Learn More

- [Learn more about CAP](https://cap.cloud.sap/docs/get-started/)
- [Deploying to Cloud Foundry](https://cap.cloud.sap/docs/advanced/deploy-to-cloud)
11 changes: 11 additions & 0 deletions chinook/app/deployers/approuter/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"name": "media-store-approuter",
"description": "Approuter",
"version": "1.0.0",
"dependencies": {
"@sap/approuter": "^6.8.2"
},
"scripts": {
"start": "node node_modules/@sap/approuter/approuter.js"
}
}
17 changes: 17 additions & 0 deletions chinook/app/deployers/approuter/xs-app.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"welcomeFile": "/index.html",
"authenticationMethod": "none",
"routes": [
{
"source": "/api/(.*)",
"target": "$1",
"destination": "srv-binding",
"authenticationType": "none"
},
{
"source": "^(.*)",
"target": "mediastore/$1",
"service": "html5-apps-repo-rt"
}
]
}
12 changes: 12 additions & 0 deletions chinook/app/deployers/html5Deployer/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"name": "media-store-html5deployer",
"engines": {
"node": ">=6.0.0"
},
"dependencies": {
"@sap/html5-app-deployer": "^2.0.0"
},
"scripts": {
"start": "node node_modules/@sap/html5-app-deployer/index.js"
}
}
7 changes: 7 additions & 0 deletions chinook/app/deployers/xs-security.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"xsappname": "media-store-xsuaa",
"tenant-mode": "dedicated",
"scopes": [],
"attributes": [],
"role-templates": []
}
5 changes: 5 additions & 0 deletions chinook/app/front/.babelrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"presets": ["@babel/preset-react", "@babel/preset-env"],
"plugins": ["@babel/plugin-transform-runtime", "babel-plugin-syntax-dynamic-import"]
}

43 changes: 43 additions & 0 deletions chinook/app/front/.eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
{
"env": {
"browser": true,
"es2020": true
},
"extends": ["plugin:react/recommended", "airbnb", "prettier"],
"parserOptions": {
"ecmaFeatures": {
"jsx": true
},
"ecmaVersion": 11,
"sourceType": "module"
},
"plugins": ["react", "prettier"],
"rules": {
"prettier/prettier": ["error", { "parser": "flow", "endOfLine": "auto" }],
"linebreak-style": [0, "error", "windows"],
"import/prefer-default-export": "off",
"no-shadow": "off",
"react/forbid-prop-types": "off",
"no-alert": "off",
"jsx-a11y/label-has-associated-control": [
"error",
{
"required": {
"some": ["nesting", "id"]
}
}
],
"jsx-a11y/label-has-for": [
"error",
{
"required": {
"some": ["nesting", "id"]
}
}
],
"react/jsx-props-no-spreading": "off", // props spreading,
"no-console": "off",
"consistent-return": "off",
"prefer-destructuring": "off"
}
}
23 changes: 23 additions & 0 deletions chinook/app/front/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.

# dependencies
/node_modules
/.pnp
.pnp.js

# testing
/coverage

# production
/build

# misc
.DS_Store
.env.local
.env.development.local
.env.test.local
.env.production.local

npm-debug.log*
yarn-debug.log*
yarn-error.log*
4 changes: 4 additions & 0 deletions chinook/app/front/.prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"printWidth": 100,
"singleQuote": true
}
13 changes: 13 additions & 0 deletions chinook/app/front/.vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@

{
"version": "0.2.0",
"configurations": [
{
"name": "Chrome",
"type": "chrome",
"request": "launch",
"url": "http://localhost:3000",
"webRoot": "${workspaceRoot}/src"
}
]
}
1 change: 1 addition & 0 deletions chinook/app/front/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
"# Media store UI"
Loading