Skip to content

Commit 3143d0a

Browse files
authored
chore: fix case endpoints, service renaming, add api types (#54)
* fix: case on endpoints * feat: move api types to separate project * feat: migrate all services to use external types * chore: rename packages for clarity, fix docker compose, fix workflow * chore: add rest of types
1 parent 53229e2 commit 3143d0a

File tree

116 files changed

+545
-408
lines changed

Some content is hidden

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

116 files changed

+545
-408
lines changed

.github/workflows/api-main.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,11 @@ jobs:
2828
- name: Set up Docker
2929
uses: docker/setup-docker-action@v4
3030

31+
- name: Build API Types
32+
run: |
33+
cd ./packages/lib-api-types
34+
pnpm build
35+
3136
- name: Run Docker Compose Up
3237
run: |
3338
cd ./packages/api-main

docker-compose.yml

Lines changed: 31 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -68,9 +68,9 @@ services:
6868
# ================================
6969
# Event Consuming Services
7070
# ================================
71-
post-service:
72-
container_name: "post-service"
73-
build: ./packages/post-service
71+
service-post:
72+
container_name: "service-post"
73+
build: ./packages/service-post
7474
depends_on:
7575
api-main:
7676
condition: service_healthy
@@ -88,9 +88,9 @@ services:
8888
restart: always
8989
command: ["pnpm", "start"]
9090

91-
reply-service:
92-
container_name: "reply-service"
93-
build: ./packages/reply-service
91+
service-reply:
92+
container_name: "service-reply"
93+
build: ./packages/service-reply
9494
depends_on:
9595
api-main:
9696
condition: service_healthy
@@ -108,9 +108,9 @@ services:
108108
restart: always
109109
command: ["pnpm", "start"]
110110

111-
like-service:
112-
container_name: "like-service"
113-
build: ./packages/like-service
111+
service-like:
112+
container_name: "service-like"
113+
build: ./packages/service-like
114114
depends_on:
115115
api-main:
116116
condition: service_healthy
@@ -128,9 +128,9 @@ services:
128128
restart: always
129129
command: ["pnpm", "start"]
130130

131-
dislike-service:
132-
container_name: "dislike-service"
133-
build: ./packages/dislike-service
131+
service-dislike:
132+
container_name: "service-dislike"
133+
build: ./packages/service-dislike
134134
depends_on:
135135
api-main:
136136
condition: service_healthy
@@ -148,9 +148,9 @@ services:
148148
restart: always
149149
command: ["pnpm", "start"]
150150

151-
follow-service:
152-
container_name: "follow-service"
153-
build: ./packages/follow-service
151+
service-follow:
152+
container_name: "service-follow"
153+
build: ./packages/service-follow
154154
depends_on:
155155
api-main:
156156
condition: service_healthy
@@ -167,9 +167,10 @@ services:
167167
API_ROOT: "http://api-main:3001/v1"
168168
restart: always
169169
command: ["pnpm", "start"]
170-
unfollow-service:
171-
container_name: "unfollow-service"
172-
build: ./packages/unfollow-service
170+
171+
service-unfollow:
172+
container_name: "service-unfollow"
173+
build: ./packages/service-unfollow
173174
depends_on:
174175
api-main:
175176
condition: service_healthy
@@ -186,9 +187,10 @@ services:
186187
API_ROOT: "http://api-main:3001/v1"
187188
restart: always
188189
command: ["pnpm", "start"]
189-
flag-service:
190-
container_name: "flag-service"
191-
build: ./packages/flag-service
190+
191+
service-flag:
192+
container_name: "service-flag"
193+
build: ./packages/service-flag
192194
depends_on:
193195
api-main:
194196
condition: service_healthy
@@ -205,9 +207,10 @@ services:
205207
API_ROOT: "http://api-main:3001/v1"
206208
restart: always
207209
command: ["pnpm", "start"]
208-
post-remove-service:
209-
container_name: "post-remove-service"
210-
build: ./packages/post-remove-service
210+
211+
service-post-remove:
212+
container_name: "service-post-remove"
213+
build: ./packages/service-post-remove
211214
depends_on:
212215
api-main:
213216
condition: service_healthy
@@ -224,9 +227,10 @@ services:
224227
API_ROOT: "http://api-main:3001/v1"
225228
restart: always
226229
command: ["pnpm", "start"]
227-
dead-letter-service:
228-
container_name: "dead-letter-service"
229-
build: ./packages/dead-letter-service
230+
231+
service-dead-letter:
232+
container_name: "service-dead-letter"
233+
build: ./packages/service-dead-letter
230234
depends_on:
231235
rabbitmq:
232236
condition: service_healthy

eslint.config.mjs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,7 @@ export default [
117117
'**/*.conf',
118118
'**/nginx/**',
119119
'**/data/postgres_data',
120+
'**/dist/**',
120121
],
121122
},
122123
];

packages/api-main/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
},
1818
"dependencies": {
1919
"@atomone/chronostate": "^2.2.1",
20+
"@atomone/dither-api-types": "link:..\\lib-api-types",
2021
"@cosmjs/crypto": "^0.33.1",
2122
"@cosmjs/encoding": "^0.33.1",
2223
"@elysiajs/cors": "~1.2.0",

packages/api-main/src/gets/dislikes.ts

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,10 @@
1+
import { type Gets } from '@atomone/dither-api-types';
12
import { eq, sql } from 'drizzle-orm';
2-
import { t } from 'elysia';
33

44
import { getDatabase } from '../../drizzle/db';
55
import { DislikesTable } from '../../drizzle/schema';
66
import { getJsonbArrayCount } from '../utility';
77

8-
export const DislikesQuery = t.Object({
9-
hash: t.String(),
10-
limit: t.Optional(t.Number()),
11-
offset: t.Optional(t.Number()),
12-
count: t.Optional(t.Boolean()),
13-
});
14-
158
const statement = getDatabase()
169
.select()
1710
.from(DislikesTable)
@@ -20,7 +13,7 @@ const statement = getDatabase()
2013
.offset(sql.placeholder('offset'))
2114
.prepare('stmnt_get_dislikes');
2215

23-
export async function Dislikes(query: typeof DislikesQuery.static) {
16+
export async function Dislikes(query: typeof Gets.DislikesQuery.static) {
2417
if (!query.hash) {
2518
return {
2619
status: 400,

packages/api-main/src/gets/feed.ts

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,9 @@
1+
import { type Gets } from '@atomone/dither-api-types';
12
import { and, count, isNull, sql } from 'drizzle-orm';
2-
import { t } from 'elysia';
33

44
import { getDatabase } from '../../drizzle/db';
55
import { FeedTable } from '../../drizzle/schema';
66

7-
export const FeedQuery = t.Object({
8-
limit: t.Optional(t.Number()),
9-
offset: t.Optional(t.Number()),
10-
count: t.Optional(t.Boolean()),
11-
});
12-
137
const statement = getDatabase()
148
.select()
159
.from(FeedTable)
@@ -18,7 +12,7 @@ const statement = getDatabase()
1812
.where(and(isNull(FeedTable.removed_at), isNull(FeedTable.post_hash)))
1913
.prepare('stmnt_get_feed');
2014

21-
export async function Feed(query: typeof FeedQuery.static) {
15+
export async function Feed(query: typeof Gets.FeedQuery.static) {
2216
if (query.count) {
2317
try {
2418
return await getDatabase().select({ count: count() }).from(FeedTable);

packages/api-main/src/gets/flags.ts

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,10 @@
1+
import { type Gets } from '@atomone/dither-api-types';
12
import { eq, sql } from 'drizzle-orm';
2-
import { t } from 'elysia';
33

44
import { getDatabase } from '../../drizzle/db';
55
import { FlagsTable } from '../../drizzle/schema';
66
import { getJsonbArrayCount } from '../utility';
77

8-
export const FlagsQuery = t.Object({
9-
hash: t.String(),
10-
limit: t.Optional(t.Number()),
11-
offset: t.Optional(t.Number()),
12-
count: t.Optional(t.Boolean()),
13-
});
14-
158
const statement = getDatabase()
169
.select()
1710
.from(FlagsTable)
@@ -20,7 +13,7 @@ const statement = getDatabase()
2013
.offset(sql.placeholder('offset'))
2114
.prepare('stmnt_get_flags');
2215

23-
export async function Flags(query: typeof FlagsQuery.static) {
16+
export async function Flags(query: typeof Gets.FlagsQuery.static) {
2417
if (!query.hash) {
2518
return {
2619
status: 400,

packages/api-main/src/gets/followers.ts

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,9 @@
1+
import { type Gets } from '@atomone/dither-api-types';
12
import { and, eq, isNull, sql } from 'drizzle-orm';
2-
import { t } from 'elysia';
33

44
import { getDatabase } from '../../drizzle/db';
55
import { FollowsTable } from '../../drizzle/schema';
66

7-
export const FollowersQuery = t.Object({
8-
limit: t.Optional(t.Number()),
9-
offset: t.Optional(t.Number()),
10-
address: t.String(),
11-
});
12-
137
const statementGetFollowers = getDatabase()
148
.select({ address: FollowsTable.follower, hash: FollowsTable.hash })
159
.from(FollowsTable)
@@ -18,7 +12,7 @@ const statementGetFollowers = getDatabase()
1812
.offset(sql.placeholder('offset'))
1913
.prepare('stmnt_get_followers');
2014

21-
export async function Followers(query: typeof FollowersQuery.static) {
15+
export async function Followers(query: typeof Gets.FollowersQuery.static) {
2216
let limit = typeof query.limit !== 'undefined' ? Number(query.limit) : 100;
2317
const offset = typeof query.offset !== 'undefined' ? Number(query.offset) : 0;
2418

packages/api-main/src/gets/following.ts

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,9 @@
1+
import { type Gets } from '@atomone/dither-api-types';
12
import { and, eq, isNull, sql } from 'drizzle-orm';
2-
import { t } from 'elysia';
33

44
import { getDatabase } from '../../drizzle/db';
55
import { FollowsTable } from '../../drizzle/schema';
66

7-
export const FollowingQuery = t.Object({
8-
limit: t.Optional(t.Number()),
9-
offset: t.Optional(t.Number()),
10-
address: t.String(),
11-
});
12-
137
const statementGetFollowing = getDatabase()
148
.select({ address: FollowsTable.following, hash: FollowsTable.hash })
159
.from(FollowsTable)
@@ -18,7 +12,7 @@ const statementGetFollowing = getDatabase()
1812
.offset(sql.placeholder('offset'))
1913
.prepare('stmnt_get_following');
2014

21-
export async function Following(query: typeof FollowingQuery.static) {
15+
export async function Following(query: typeof Gets.FollowingQuery.static) {
2216
let limit = typeof query.limit !== 'undefined' ? Number(query.limit) : 100;
2317
const offset = typeof query.offset !== 'undefined' ? Number(query.offset) : 0;
2418

packages/api-main/src/gets/likes.ts

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,10 @@
1+
import { type Gets } from '@atomone/dither-api-types';
12
import { eq, sql } from 'drizzle-orm';
2-
import { t } from 'elysia';
33

44
import { getDatabase } from '../../drizzle/db';
55
import { LikesTable } from '../../drizzle/schema';
66
import { getJsonbArrayCount } from '../utility';
77

8-
export const LikesQuery = t.Object({
9-
hash: t.String(),
10-
limit: t.Optional(t.Number()),
11-
offset: t.Optional(t.Number()),
12-
count: t.Optional(t.Boolean()),
13-
});
14-
158
const statement = getDatabase()
169
.select()
1710
.from(LikesTable)
@@ -20,7 +13,7 @@ const statement = getDatabase()
2013
.offset(sql.placeholder('offset'))
2114
.prepare('stmnt_get_likes');
2215

23-
export async function Likes(query: typeof LikesQuery.static) {
16+
export async function Likes(query: typeof Gets.LikesQuery.static) {
2417
if (!query.hash) {
2518
return {
2619
status: 400,

0 commit comments

Comments
 (0)