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

Add api sdk #1390

Merged
merged 1 commit into from
Aug 20, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
5 changes: 3 additions & 2 deletions .github/workflows/ci-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,17 @@ on:
paths:
- ".github/workflows/ci-build.yml"
- "backend/**"
- "frontend/**"
- "frontend/apps/**"
- ".dockerignore"
- "docker-init.sh"
- "Dockerfile"
- "!**.md"
- "!frontend/packages/**"
pull_request:
paths:
- ".github/workflows/ci-build.yml"
- "backend/**"
- "frontend/**"
- "frontend/apps/**"
- ".dockerignore"
- "docker-init.sh"
- "Dockerfile"
Expand Down
153 changes: 153 additions & 0 deletions .github/workflows/ci-frontend-api.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,153 @@
name: "@remark42/api"

on:
push:
branches:
- master
paths:
- ".github/workflows/ci-frontend-api.yml"
- "frontend/packages/**"
- "!**.md"
pull_request:
paths:
- ".github/workflows/ci-frontend-api.yml"
- "frontend/packages/**"
- "!**.md"

jobs:
type-check:
name: Type check
runs-on: ubuntu-latest
strategy:
matrix:
node: [16.15.1]

steps:
- name: Checkout
uses: actions/checkout@v3

- name: Install node
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node }}

- name: Install pnpm
uses: pnpm/[email protected]
id: pnpm-install
with:
version: 7
run_install: false

- name: Get pnpm store directory
id: pnpm-cache
run: |
echo "::set-output name=pnpm_cache_dir::$(pnpm store path)"

- name: Setup pnpm cache
uses: actions/cache@v3
with:
path: ${{ steps.pnpm-cache.outputs.pnpm_cache_dir }}
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-pnpm-store-

- name: Install dependencies
run: pnpm i
working-directory: ./frontend

- name: Run type check
run: pnpm type-check:api
working-directory: ./frontend

lint:
name: Lint
runs-on: ubuntu-latest
strategy:
matrix:
node: [16.15.1]

steps:
- name: Checkout
uses: actions/checkout@v3

- name: Install node
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node }}

- name: Install pnpm
uses: pnpm/[email protected]
id: pnpm-install
with:
version: 7
run_install: false

- name: Get pnpm store directory
id: pnpm-cache
run: |
echo "::set-output name=pnpm_cache_dir::$(pnpm store path)"

- name: Setup pnpm cache
uses: actions/cache@v3
with:
path: ${{ steps.pnpm-cache.outputs.pnpm_cache_dir }}
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-pnpm-store-

- name: Install dependencies
run: pnpm i
working-directory: ./frontend

- name: Run linters
run: pnpm lint:api
working-directory: ./frontend/

test:
name: Tests & Coverage
runs-on: ubuntu-latest
strategy:
matrix:
node: [16.15.1]

steps:
- name: Checkout
uses: actions/checkout@v3

- name: Install node
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node }}

- name: Install pnpm
uses: pnpm/[email protected]
id: pnpm-install
with:
version: 7
run_install: false

- name: Get pnpm store directory
id: pnpm-cache
run: |
echo "::set-output name=pnpm_cache_dir::$(pnpm store path)"

- name: Setup pnpm cache
uses: actions/cache@v3
with:
path: ${{ steps.pnpm-cache.outputs.pnpm_cache_dir }}
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-pnpm-store-

- name: Install dependencies
run: pnpm i
working-directory: ./frontend

- name: Test & Coverage
run: pnpm coverage:api
working-directory: ./frontend

- name: Submit coverage
run: ${{ github.workspace }}/frontend/apps/remark42/node_modules/.bin/codecov
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
9 changes: 7 additions & 2 deletions frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,15 @@
],
"scripts": {
"prepare": "if [ -z \"$CI\" ]; then cd .. && husky install frontend/.husky; else echo \"Skip Husky Hooks\"; fi",
"lint-staged": "lint-staged"
"lint-staged": "lint-staged",
"test:api": "turbo run test --filter=@remark42/api",
"coverage:api": "turbo run coverage --filter=@remark42/api",
"type-check:api": "turbo run type-check --filter=@remark42/api",
"lint:api": "turbo run lint --filter=@remark42/api"
},
"devDependencies": {
"husky": "^8.0.1",
"lint-staged": "^13.0.3"
"lint-staged": "^13.0.3",
"turbo": "^1.4.3"
}
}
2 changes: 2 additions & 0 deletions frontend/packages/api/.eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
dist
coverage
22 changes: 22 additions & 0 deletions frontend/packages/api/.eslintrc.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
module.exports = {
env: {
browser: true,
es2021: true,
node: true,
},
extends: [
'eslint:recommended',
'plugin:@typescript-eslint/recommended',
'plugin:@typescript-eslint/recommended-requiring-type-checking',
'plugin:@typescript-eslint/strict',
'plugin:prettier/recommended',
],
overrides: [],
parser: '@typescript-eslint/parser',
parserOptions: {
ecmaVersion: 'latest',
sourceType: 'module',
project: './tsconfig.eslint.json',
},
plugins: ['@typescript-eslint'],
}
5 changes: 5 additions & 0 deletions frontend/packages/api/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
node_modules
coverage
dist
**/*.js
**/*.d.ts
3 changes: 3 additions & 0 deletions frontend/packages/api/.lintstagedrc.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module.exports = {
'./**/*.ts': ['pnpm lint-staged:lint'],
}
17 changes: 17 additions & 0 deletions frontend/packages/api/.npmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
coverage/**
dist/**
node_modules/**
src/**
test/**
.editorconfig
.eslintrc.cjs
.prettierrc
files.txt
jest.config.ts
pnpm-lock.yaml
postpublish.sh
prepublish.sh
tsconfig.common.json
tsconfig.dev.json
tsconfig.json

1 change: 1 addition & 0 deletions frontend/packages/api/.nvmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
16.17.0
6 changes: 6 additions & 0 deletions frontend/packages/api/.prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"semi": false,
"printWidth": 100,
"quoteProps": "consistent",
"singleQuote": true
}
11 changes: 11 additions & 0 deletions frontend/packages/api/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# @remark42/api

Implementation of API methods for Remark42

## Development

- If you don't have `pnpm` installed run `npm i -g pnpm`
- Install dependencies `pnpm i`
- Run development mode with `pnpm run dev`
- Build lib with `pnpm run build`
- Run tests with `pnpm run test`
Loading