Skip to content

Commit a0c0ec8

Browse files
committed
edit
1 parent 4d0eb64 commit a0c0ec8

6 files changed

Lines changed: 75 additions & 4 deletions

File tree

.github/workflows/publish.yml

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
name: Publish to npm
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
8+
jobs:
9+
publish:
10+
runs-on: ubuntu-latest
11+
12+
steps:
13+
- uses: actions/checkout@v3
14+
15+
- name: Use Node.js
16+
uses: actions/setup-node@v3
17+
with:
18+
node-version: 18
19+
registry-url: "https://registry.npmjs.org/"
20+
21+
- name: Install dependencies
22+
run: npm install
23+
24+
- name: Auto bump version
25+
run: npm version patch --no-git-tag-version
26+
27+
- name: Publish to npm
28+
run: npm publish
29+
env:
30+
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}

src/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
## this app for test

src/index.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,11 @@
1+
import { hamo } from "./modules/hamo/hamo.controller";
12
import { kkkkkkk } from "./modules/kkkkkkk/kkkkkkk.controller";
23
import { ui } from "./modules/ui/ui.controller";
34
import { kdm } from "./modules/kdm/kdm.controller";
45
import Elysia from "elysia";
56

67
console.log("kfmkfm");
7-
const app = new Elysia().use(kdm)
8-
.use(ui)
9-
.use(kkkkkkk)
10-
.listen(95995);
8+
const app = new Elysia().use(kdm).use(ui).use(kkkkkkk).use(hamo).listen(95995);
119

1210
console.log(
1311
`🦊 Elysia is running at ${app.server?.hostname}:${app.server?.port}`
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
import { Elysia } from "elysia";
2+
import { HamoService } from "./hamo.service";
3+
import { HamoModel } from "./hamo.model";
4+
5+
export const hamo = new Elysia({ prefix: "/hamos" })
6+
.get("/", async () => {
7+
return HamoService.findAll();
8+
})
9+
.get("/:id", async ({ params }) => {
10+
return HamoService.findOne(params.id);
11+
},{
12+
params: HamoModel.HamoParams
13+
})
14+
.post("/", async ({ body }) => {}, {
15+
body: HamoModel.HamoBody,
16+
})
17+

src/modules/hamo/hamo.model.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import { t } from 'elysia'
2+
3+
export namespace HamoModel {
4+
export const HamoBody = t.Object({
5+
name: t.String(),
6+
});
7+
8+
// Define it as TypeScript type
9+
export type HamoBodyType = typeof HamoBody.static;
10+
11+
export const HamoParams = t.Object({
12+
id: t.String(),
13+
});
14+
}

src/modules/hamo/hamo.service.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
export abstract class HamoService {
2+
static async findAll() {
3+
// TODO: Add logic here
4+
return [];
5+
}
6+
7+
static async findOne(id: string) {
8+
// TODO: Add logic here
9+
return { id };
10+
}
11+
}

0 commit comments

Comments
 (0)