Skip to content

Commit

Permalink
fix: Add package.json for proto
Browse files Browse the repository at this point in the history
  • Loading branch information
kiosion committed Aug 15, 2023
1 parent b874c58 commit c6190e2
Show file tree
Hide file tree
Showing 8 changed files with 24 additions and 39 deletions.
28 changes: 1 addition & 27 deletions web/info/src/lib/api.ts
Original file line number Diff line number Diff line change
@@ -1,34 +1,8 @@
import { PublicService } from '$api/public_service_connectweb';
import { API_URL } from '$lib/constants';

import { createPromiseClient } from '@bufbuild/connect';
import { createConnectTransport } from '@bufbuild/connect-web';
import { MethodKind, proto3 } from '@bufbuild/protobuf';

const ListFeedsRequest = proto3.makeMessageType('bff.v1.ListFeedsRequest', []);

const ListFeedsResponse = proto3.makeMessageType('bff.v1.ListFeedsResponse', () => [
{ no: 1, name: 'feeds', kind: 'message', T: Feed, repeated: true }
]);

const Feed = proto3.makeMessageType('bff.v1.Feed', () => [
{ no: 1, name: 'id', kind: 'scalar', T: 9 /* ScalarType.STRING */ },
{ no: 2, name: 'link', kind: 'scalar', T: 9 /* ScalarType.STRING */ },
{ no: 3, name: 'display_name', kind: 'scalar', T: 9 /* ScalarType.STRING */ },
{ no: 4, name: 'description', kind: 'scalar', T: 9 /* ScalarType.STRING */ },
{ no: 5, name: 'priority', kind: 'scalar', T: 5 /* ScalarType.INT32 */ }
]);

const PublicService = {
typeName: 'bff.v1.PublicService',
methods: {
listFeeds: {
name: 'ListFeeds',
I: ListFeedsRequest,
O: ListFeedsResponse,
kind: MethodKind.Unary
}
}
};

type RouteFetch = typeof fetch;

Expand Down
3 changes: 2 additions & 1 deletion web/info/src/routes/+layout.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ export const load = (async ({ url, fetch }) => {
const apiClient = getClient(fetch);

(feeds ||=
(await (apiClient.listFeeds as () => Promise<{ feeds: FeedInfo[] }>)()
(await apiClient
.listFeeds({})
.then((res) => {
return res.feeds
.filter((f) => f.priority >= 0)
Expand Down
1 change: 1 addition & 0 deletions web/info/svelte.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ const config = {

kit: {
alias: {
$api: '../proto/bff/v1',
$components: 'src/components',
$stores: 'src/stores',
$routes: 'src/routes'
Expand Down
1 change: 1 addition & 0 deletions web/info/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
"sourceMap": true,
"strict": true,
"paths": {
"$api/*": ["../proto/bff/v1/*"],
"$lib": ["src/lib"],
"$lib/*": ["src/lib/*"],
"$components/*": ["src/components/*"],
Expand Down
11 changes: 1 addition & 10 deletions web/info/types/app/index.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1 @@
type FeedInfo = {
id: string;
displayName: string;
description: string;
priority: number;
link: string;
tags?: string[];
};

export type { FeedInfo };
export type { Feed as FeedInfo } from '$api/public_service_pb';
8 changes: 7 additions & 1 deletion web/pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions web/pnpm-workspace.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
packages:
- 'admin'
- 'info'
- 'proto'
10 changes: 10 additions & 0 deletions web/proto/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"name": "proto",
"version": "1.0.0",
"description": "",
"keywords": [],
"author": "",
"dependencies": {
"@bufbuild/protobuf": "~1.2.0"
}
}

0 comments on commit c6190e2

Please sign in to comment.