Skip to content

Commit

Permalink
Merge pull request #2 from StartUpNationLabs/client-libraries
Browse files Browse the repository at this point in the history
feat: add clients for backend
  • Loading branch information
Apoorva64 authored Sep 23, 2024
2 parents 0d7531c + c299669 commit 3243009
Show file tree
Hide file tree
Showing 113 changed files with 7,755 additions and 73 deletions.
4 changes: 3 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,11 @@ jobs:
main:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/checkout@v3
with:
fetch-depth: 0
fetch-tags: true

- name: Setup Git
run: |
git config user.name "GitHub Bot"
Expand Down
26 changes: 26 additions & 0 deletions .openapi-generator-ignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# OpenAPI Generator Ignore
# Generated by openapi-generator https://github.com/openapitools/openapi-generator

# Use this file to prevent files from being overwritten by the generator.
# The patterns follow closely to .gitignore or .dockerignore.

# As an example, the C# client generator defines ApiClient.cs.
# You can make changes and tell OpenAPI Generator to ignore just this file by uncommenting the following line:
#ApiClient.cs

# You can match any string of characters against a directory, file or extension with a single asterisk (*):
#foo/*/qux
# The above matches foo/bar/qux and foo/baz/qux, but not foo/bar/baz/qux

# You can recursively match patterns against a directory, file or extension with a double asterisk (**):
#foo/**/qux
# This matches foo/bar/qux, foo/baz/qux, and foo/bar/baz/qux

# You can also negate patterns with an exclamation (!).
# For example, you can ignore all files in a docs folder with the file extension .md:
#docs/*.md
# Then explicitly reverse the ignore rule for a single file:
#!docs/README.md

**/**/.gitignore
**/**/git_push.sh
22 changes: 0 additions & 22 deletions apps/sample-nestjs/src/app/app.controller.spec.ts

This file was deleted.

8 changes: 3 additions & 5 deletions apps/sample-nestjs/src/app/app.service.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,10 @@ describe('AppService', () => {
providers: [AppService],
}).compile();

service = app.get<AppService>(AppService);
service = app.get<AppService>(AppService) as AppService;
});

describe('getData', () => {
it('should return "Hello API"', () => {
expect(service.getData()).toEqual({ message: 'Hello API' });
});
it('should be defined', () => {
expect(service).toBeDefined();
});
});
7 changes: 5 additions & 2 deletions apps/sample-nestjs/src/app/app.service.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
import { Injectable } from '@nestjs/common';
import {TablesApi, TableWithOrderDto} from "@spos/clients/dining";
import axios from "axios";

@Injectable()
export class AppService {
getData(): { message: string } {
return { message: 'Hello API' };
tableApi = new TablesApi();
async getData() {
return (await this.tableApi.tablesControllerListAllTables()).data;
}
}
9 changes: 3 additions & 6 deletions apps/sample-react/src/app/app.spec.tsx
Original file line number Diff line number Diff line change
@@ -1,15 +1,12 @@
import { render } from '@testing-library/react';

import App from './app';
import {QueryClient, QueryClientProvider} from "@tanstack/react-query";

describe('App', () => {
it('should render successfully', () => {
const { baseElement } = render(<App />);
const queryClient = new QueryClient()
const { baseElement } = render(<QueryClientProvider client={queryClient}><App /></QueryClientProvider>);
expect(baseElement).toBeTruthy();
});

it('should have a greeting as the title', () => {
const { getByText } = render(<App />);
expect(getByText(/Welcome sample-react/gi)).toBeTruthy();
});
});
23 changes: 21 additions & 2 deletions apps/sample-react/src/app/app.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,28 @@
import NxWelcome from './nx-welcome';
import {useQuery} from "@tanstack/react-query";
import {MenusApi} from "@spos/clients/menu";

const menusApi = new MenusApi(
)

export function App() {
const query = useQuery({
queryKey: ['menus'], queryFn: () => {
return menusApi.menusControllerGetFullMenu()
}
})
if (query.isLoading) {
return <div>Loading...</div>
}
if (query.isError) {
return <div>Error: {query.error}</div>
}
if (!query.data) {
return <div>No data</div>
}

return (
<div>
<NxWelcome title="sample-react" />
<pre>{JSON.stringify(query.data, null, 2)}</pre>
</div>
);
}
Expand Down
5 changes: 5 additions & 0 deletions apps/sample-react/src/main.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,17 @@ import { StrictMode } from 'react';
import * as ReactDOM from 'react-dom/client';

import App from './app/app';
import {QueryClient, QueryClientProvider} from "@tanstack/react-query";

const queryClient = new QueryClient()

const root = ReactDOM.createRoot(
document.getElementById('root') as HTMLElement
);
root.render(
<StrictMode>
<QueryClientProvider client={queryClient}>
<App />
</QueryClientProvider>
</StrictMode>
);
25 changes: 25 additions & 0 deletions libs/clients/dining/.eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
{
"extends": ["../../../.eslintrc.json"],
"ignorePatterns": ["!**/*"],
"overrides": [
{
"files": ["*.ts", "*.tsx", "*.js", "*.jsx"],
"rules": {}
},
{
"files": ["*.ts", "*.tsx"],
"rules": {}
},
{
"files": ["*.js", "*.jsx"],
"rules": {}
},
{
"files": ["*.json"],
"parser": "jsonc-eslint-parser",
"rules": {
"@nx/dependency-checks": "error"
}
}
]
}
7 changes: 7 additions & 0 deletions libs/clients/dining/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# clients-dining

This library was generated with [Nx](https://nx.dev).

## Building

Run `nx build clients-dining` to build the library.
Loading

0 comments on commit 3243009

Please sign in to comment.