Skip to content

Commit a4a68ed

Browse files
authored
feat: add transaction service (#1)
* Add workflow setup * Add docs app for OpenAPI definitions * Add storage model for transaction * Add transaction service * Add prototype for GRPC microservices arch
1 parent c55e7fc commit a4a68ed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

85 files changed

+6101
-515
lines changed

.github/workflows/pr.yml

+31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
name: conventional-pr
2+
on:
3+
pull_request:
4+
branches:
5+
- main
6+
- master
7+
types:
8+
- opened
9+
- edited
10+
- synchronize
11+
jobs:
12+
label:
13+
runs-on: ubuntu-latest
14+
name: Lint PR
15+
steps:
16+
- name: label
17+
uses: action-runner/conventional-labeler@2.0.0
18+
with:
19+
access_token: ${{ secrets.GITHUB_TOKEN }}
20+
outdater:
21+
runs-on: ubuntu-latest
22+
name: Dependencies outdater
23+
steps:
24+
- uses: actions/checkout@v3
25+
- uses: pnpm/action-setup@v2
26+
with:
27+
version: 6.32.9
28+
- name: Dependencies Outdater
29+
uses: action-runner/dependencies-outdater@master
30+
with:
31+
access_token: ${{ secrets.GITHUB_TOKEN }}

.github/workflows/test.yml

+55
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
name: Test and release
2+
on:
3+
push:
4+
5+
jobs:
6+
test:
7+
env:
8+
TURBO_TOKEN: ${{ secrets.TURBO_TOKEN }}
9+
TURBO_TEAM: ${{ secrets.TURBO_TEAM }}
10+
if: ${{ github.event.pusher.name != 'github action' }}
11+
runs-on: ubuntu-latest
12+
steps:
13+
- uses: actions/checkout@v2
14+
- uses: pnpm/action-setup@v2
15+
with:
16+
version: 6.32.9
17+
- uses: actions/setup-node@v3
18+
with:
19+
node-version: "16"
20+
cache: "pnpm"
21+
- run: pnpm install
22+
- run: pnpm build
23+
- run: pnpm test
24+
- run: pnpm release-dry
25+
- name: Upload coverage to Codecov
26+
uses: codecov/codecov-action@v1
27+
with:
28+
token: ${{ secrets.CODECOV_TOKEN }}
29+
30+
release:
31+
env:
32+
TURBO_TOKEN: ${{ secrets.TURBO_TOKEN }}
33+
TURBO_TEAM: ${{ secrets.TURBO_TEAM }}
34+
if: ${{ (github.event.pusher.name != 'github action') && (github.ref == 'refs/heads/main') }}
35+
needs: [ test ]
36+
runs-on: ubuntu-latest
37+
steps:
38+
- uses: actions/checkout@v2
39+
- uses: pnpm/action-setup@v2
40+
with:
41+
version: 6.32.9
42+
- uses: actions/setup-node@v3
43+
with:
44+
node-version: "16"
45+
cache: "pnpm"
46+
- run: pnpm install
47+
- run: pnpm build
48+
- name: Setup git identity
49+
run: |
50+
git config --global user.email "github-action.github.com"
51+
git config --global user.name "github action"
52+
- name: Release
53+
run: pnpm release --ci
54+
env:
55+
GITHUB_TOKEN: ${{secrets.RELEASE_TOKEN}}

.gitignore

+2
Original file line numberDiff line numberDiff line change
@@ -35,3 +35,5 @@ lerna-debug.log*
3535

3636
services/**/*.proto
3737
node_modules
38+
.env
39+
.turbo

.release-it.json

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
{
2+
"npm": {
3+
"publish": false
4+
},
5+
"github": {
6+
"release": true
7+
},
8+
"plugins": {
9+
"@release-it/conventional-changelog": {
10+
"preset": "angular",
11+
"infile": "CHANGELOG.md",
12+
"header": "# Changelog"
13+
},
14+
"@release-it/bumper": {
15+
"out": [
16+
"packages/**/package.json",
17+
"apps/**/package.json",
18+
"services/**/package.json"
19+
]
20+
}
21+
}
22+
}

apps/docs/.eslintrc.json

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"extends": "next/core-web-vitals"
3+
}

apps/docs/.gitignore

+35
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
2+
3+
# dependencies
4+
/node_modules
5+
/.pnp
6+
.pnp.js
7+
8+
# testing
9+
/coverage
10+
11+
# next.js
12+
/.next/
13+
/out/
14+
15+
# production
16+
/build
17+
18+
# misc
19+
.DS_Store
20+
*.pem
21+
22+
# debug
23+
npm-debug.log*
24+
yarn-debug.log*
25+
yarn-error.log*
26+
.pnpm-debug.log*
27+
28+
# local env files
29+
.env*.local
30+
31+
# vercel
32+
.vercel
33+
34+
# typescript
35+
*.tsbuildinfo

apps/docs/README.md

+34
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
This is a [Next.js](https://nextjs.org/) project bootstrapped with [`create-next-app`](https://github.com/vercel/next.js/tree/canary/packages/create-next-app).
2+
3+
## Getting Started
4+
5+
First, run the development server:
6+
7+
```bash
8+
npm run dev
9+
# or
10+
yarn dev
11+
```
12+
13+
Open [http://localhost:3000](http://localhost:3000) with your browser to see the result.
14+
15+
You can start editing the page by modifying `pages/index.tsx`. The page auto-updates as you edit the file.
16+
17+
[API routes](https://nextjs.org/docs/api-routes/introduction) can be accessed on [http://localhost:3000/api/hello](http://localhost:3000/api/hello). This endpoint can be edited in `pages/api/hello.ts`.
18+
19+
The `pages/api` directory is mapped to `/api/*`. Files in this directory are treated as [API routes](https://nextjs.org/docs/api-routes/introduction) instead of React pages.
20+
21+
## Learn More
22+
23+
To learn more about Next.js, take a look at the following resources:
24+
25+
- [Next.js Documentation](https://nextjs.org/docs) - learn about Next.js features and API.
26+
- [Learn Next.js](https://nextjs.org/learn) - an interactive Next.js tutorial.
27+
28+
You can check out [the Next.js GitHub repository](https://github.com/vercel/next.js/) - your feedback and contributions are welcome!
29+
30+
## Deploy on Vercel
31+
32+
The easiest way to deploy your Next.js app is to use the [Vercel Platform](https://vercel.com/new?utm_medium=default-template&filter=next.js&utm_source=create-next-app&utm_campaign=create-next-app-readme) from the creators of Next.js.
33+
34+
Check out our [Next.js deployment documentation](https://nextjs.org/docs/deployment) for more details.

apps/docs/next-env.d.ts

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
/// <reference types="next" />
2+
/// <reference types="next/image-types/global" />
3+
4+
// NOTE: This file should not be edited
5+
// see https://nextjs.org/docs/basic-features/typescript for more information.

apps/docs/next.config.js

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
/** @type {import('next').NextConfig} */
2+
const nextConfig = {
3+
reactStrictMode: true,
4+
}
5+
6+
module.exports = nextConfig

apps/docs/package.json

+32
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
{
2+
"name": "docs",
3+
"version": "0.1.0",
4+
"private": true,
5+
"scripts": {
6+
"dev": "next dev",
7+
"build": "next build",
8+
"start": "next start",
9+
"lint": "next lint"
10+
},
11+
"dependencies": {
12+
"@emotion/react": "^11.9.0",
13+
"@emotion/styled": "^11.8.1",
14+
"@mui/icons-material": "^5.6.2",
15+
"@mui/material": "^5.7.0",
16+
"mobx": "^6.5.0",
17+
"next": "12.1.6",
18+
"openapi_specs": "*",
19+
"react": "18.1.0",
20+
"react-dom": "18.1.0",
21+
"redoc": "2.0.0-rc.67",
22+
"styled-components": "^5.3.5"
23+
},
24+
"devDependencies": {
25+
"@types/node": "17.0.31",
26+
"@types/react": "18.0.9",
27+
"@types/react-dom": "18.0.3",
28+
"eslint": "8.15.0",
29+
"eslint-config-next": "12.1.6",
30+
"typescript": "4.6.4"
31+
}
32+
}

apps/docs/pages/_app.tsx

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
import type { AppProps } from 'next/app';
2+
import { createTheme, ThemeProvider } from '@mui/material';
3+
4+
const theme = createTheme({
5+
palette: {
6+
primary: {
7+
main: '#f5f5f5',
8+
},
9+
},
10+
});
11+
12+
function MyApp({ Component, pageProps }: AppProps) {
13+
return (
14+
<ThemeProvider theme={theme}>
15+
<Component {...pageProps} />
16+
</ThemeProvider>
17+
);
18+
}
19+
20+
export default MyApp;

apps/docs/pages/index.tsx

+81
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
import type { NextPage } from 'next';
2+
import { RedocStandalone } from 'redoc';
3+
import * as spec from 'openapi_specs';
4+
import {
5+
AppBar,
6+
Button,
7+
CircularProgress,
8+
Fade,
9+
LinearProgress,
10+
MenuItem,
11+
Toolbar,
12+
Typography,
13+
} from '@mui/material';
14+
import { useRouter } from 'next/router';
15+
import { useEffect, useMemo, useState } from 'react';
16+
17+
const Home: NextPage = () => {
18+
const router = useRouter();
19+
const [isLoading, setIsLoading] = useState(false);
20+
useEffect(() => {
21+
setIsLoading(true);
22+
}, [router.query.doc]);
23+
const selectedDoc = useMemo(() => {
24+
if (!Boolean(router.query.doc)) {
25+
return spec.health_service_schema;
26+
}
27+
const foundValue = Object.entries(spec).find(
28+
([key, value], index) => key === router.query.doc,
29+
);
30+
31+
if (!foundValue) {
32+
return undefined;
33+
}
34+
35+
return foundValue[1];
36+
}, [router.query.doc]);
37+
38+
return (
39+
<div>
40+
<AppBar color="primary">
41+
<Toolbar>
42+
<Typography variant={'h5'}>Docs</Typography>
43+
{Object.keys(spec).map((k) => (
44+
<MenuItem
45+
key={k}
46+
selected={true}
47+
onClick={() => router.push(`?doc=${k}`)}
48+
style={{ color: k === router.query.doc ? 'purple' : 'black' }}
49+
>
50+
{k}
51+
</MenuItem>
52+
))}
53+
</Toolbar>
54+
</AppBar>
55+
<div style={{ marginTop: 70 }}>
56+
<Fade in={isLoading} mountOnEnter unmountOnExit>
57+
<LinearProgress color={'secondary'} />
58+
</Fade>
59+
{selectedDoc && (
60+
<RedocStandalone
61+
spec={selectedDoc}
62+
onLoaded={() => {
63+
setIsLoading(false);
64+
}}
65+
options={{
66+
theme: {
67+
sidebar: { width: '0px' },
68+
rightPanel: { width: '40%' },
69+
},
70+
scrollYOffset: 0,
71+
hideLoading: true,
72+
nativeScrollbars: false,
73+
}}
74+
/>
75+
)}
76+
</div>
77+
</div>
78+
);
79+
};
80+
81+
export default Home;

apps/docs/public/favicon.ico

25.3 KB
Binary file not shown.

apps/docs/public/vercel.svg

+4
Loading

apps/docs/tsconfig.json

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
{
2+
"compilerOptions": {
3+
"target": "es5",
4+
"lib": ["dom", "dom.iterable", "esnext"],
5+
"allowJs": true,
6+
"skipLibCheck": true,
7+
"strict": true,
8+
"forceConsistentCasingInFileNames": true,
9+
"noEmit": true,
10+
"esModuleInterop": true,
11+
"module": "esnext",
12+
"moduleResolution": "node",
13+
"resolveJsonModule": true,
14+
"isolatedModules": true,
15+
"jsx": "preserve",
16+
"incremental": true
17+
},
18+
"include": ["next-env.d.ts", "**/*.ts", "**/*.tsx"],
19+
"exclude": ["node_modules"]
20+
}

apps/readme.md

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# Apps folder
2+
3+
We construct our frontend apps here. It contains multiple apps:
4+
5+
- `docs`: A documentation app.

grpc/health.proto

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
package health;
2+
3+
service HealthController{
4+
rpc healthCheck(Void) returns (Reason){}
5+
}
6+
7+
message Void{
8+
9+
}
10+
11+
message Reason{
12+
optional string reason = 1;
13+
}

grpc/transaction.proto

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
package transaction;
22

3-
service TransactionService{
3+
service TransactionController{
44
rpc healthCheck(Void) returns (Reason){}
55
}
66

0 commit comments

Comments
 (0)