Skip to content

Commit aee675f

Browse files
committed
feat(apps/track): initial @stack/track setup
1 parent a6b3ab2 commit aee675f

File tree

9 files changed

+68
-0
lines changed

9 files changed

+68
-0
lines changed

apps/track/package.json

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
{
2+
"name": "@stack/track",
3+
"private": true,
4+
"version": "0.0.0",
5+
"scripts": {
6+
"dev": "bun --watch run ./src/index.ts"
7+
},
8+
"dependencies": {
9+
"@clickhouse/client": "1.4.1",
10+
"@hattip/adapter-bun": "0.0.47",
11+
"@hattip/response": "0.0.47",
12+
"@hattip/router": "0.0.47"
13+
},
14+
"devDependencies": {
15+
"@stack/typescript-config": "workspace:*",
16+
"@types/bun": "1.1.6"
17+
}
18+
}

apps/track/src/index.ts

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
// entry-node.js
2+
import adapter from '@hattip/adapter-bun';
3+
4+
import { router } from './routes';
5+
6+
// export default router;
7+
export default adapter(
8+
router,
9+
// @ts-expect-error
10+
{ port: 3001 }
11+
);

apps/track/src/routes/events/index.ts

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
import type { TrackRouter } from '../router';
2+
3+
import { pageViewRote } from './page-view';
4+
5+
export const addEventsRoutes = (router: TrackRouter) => {
6+
// TODO: Add other routers
7+
pageViewRote(router);
8+
};
+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import type { TrackRouter } from '../router';
2+
3+
import { eventRoute } from './shared';
4+
5+
export const pageViewRote = (router: TrackRouter) => {
6+
router.get(
7+
eventRoute('page-view'),
8+
async () =>
9+
new Response(undefined, {
10+
status: 200
11+
})
12+
);
13+
};
+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export const eventRoute = (route: string) => `/events/${route}`;

apps/track/src/routes/index.ts

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export { default as router } from './router';

apps/track/src/routes/router.ts

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import type { BunPlatformInfo } from '@hattip/adapter-bun';
2+
import type { Router } from '@hattip/router';
3+
4+
import { createRouter } from '@hattip/router';
5+
6+
import { addEventsRoutes } from './events';
7+
8+
const router = createRouter<BunPlatformInfo>();
9+
10+
addEventsRoutes(router);
11+
12+
export type TrackRouter = Router<BunPlatformInfo>;
13+
export default router.buildHandler();

apps/track/tsconfig.json

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"extends": "@stack/typescript-config/server.json"
3+
}

bun.lockb

4.61 KB
Binary file not shown.

0 commit comments

Comments
 (0)