Skip to content

Commit

Permalink
Merge pull request #37 from hollow-leaf/feat/apiMigrate
Browse files Browse the repository at this point in the history
feat: some api migrate
  • Loading branch information
kidneyweakx authored Feb 26, 2024
2 parents ad709b0 + d18d025 commit f819302
Show file tree
Hide file tree
Showing 14 changed files with 104 additions and 8,717 deletions.
1 change: 0 additions & 1 deletion .asdfrc

This file was deleted.

2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -36,3 +36,5 @@ yarn-error.log*
# Misc
.DS_Store
*.pem

wrangler.toml
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@
same "printed page" as the copyright notice for easier
identification within third-party archives.

Copyright [2023] kidneyweakx
Copyright [2023] kidneyweakx YeeeTai

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand Down
18 changes: 18 additions & 0 deletions apps/docs/backlog/Feb_Milestone.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
### February Milestone Plan for Doro

1. Frontend (focus here):
* PWA Integration:
- Migrate React Native components to Next.js PWA, prioritizing compatibility and responsiveness.
- Create a dedicated web page to complement the PWA user experience.

2. Contract CI/CD - Test and Deploy:
* Roulette Contract Testing:
- Conduct comprehensive testing on the Roulette contract to ensure reliability and security.
* Deploy on Berkeley Testnet:
- Complete the deployment of the tested Roulette contract on the Berkeley Testnet for real-world validation.

3. Backend - Optimize Serverless Part:
* Serverless API Migration:
- Transfer stateless APIs to the serverless architecture for improved scalability and flexibility.
* Mina-Sign Verification:
- Implement and verify Mina-Sign functionality in the backend or serverless environment to enhance security.
37 changes: 37 additions & 0 deletions apps/docs/design/api.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
### API Design

> /test (deprecated)
Only for test

### Game Lobby API

> /latest_game
> /get_answer/:id
> /get_game/:id
> /get_game_user/:id
### Game

> /draw/:id
(will deprecated)

(Same API, but return different)
> /reveal/:id
> /decrypt/:id
> /setGame
### Lobby (better UX)
> /gameLobby
> /lobbyTestData
### Wallet
> /generate_key
> /user/:address
(user can use ethereum wallet to recovery their mina key)
56 changes: 0 additions & 56 deletions apps/serverless/patch.js

This file was deleted.

6 changes: 5 additions & 1 deletion apps/serverless/src/app.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
import { OpenAPIHono } from '@hono/zod-openapi'
import { lobbyController, swaggerController, minaController } from './controllers'
import { cors } from 'hono/cors'

const app = new OpenAPIHono()
type Bindings = { "doro-": KVNamespace }

const app = new OpenAPIHono<{ Bindings: Bindings }>()

lobbyController(app)
swaggerController(app)
minaController(app)

export default app
35 changes: 35 additions & 0 deletions apps/serverless/src/controllers/gameController.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
// lobby function
import { OpenAPIHono, createRoute } from "@hono/zod-openapi"
import { UserSchema, ParamsSchema } from "../models/userModel"
import { createController, ResponseType } from "../utils"

const responses: ResponseType[] = [
{
statusCode: 200,
content: {
'application/json': {
schema: UserSchema,
},
},
description: 'Retrieve the user',
},
{
statusCode: 404,
description: 'User not found',
},
];

const UserController = createController('get', '/users/{id}', ParamsSchema, responses)

export default (app: OpenAPIHono) => {
// path: /users/{id}
app.openapi(UserController, (c: any) => {
const { id } = c.req.valid('param') as any
return c.json({
id,
age: 20,
name: 'Ultra-man',
d: 'a'
})
})
}
3 changes: 2 additions & 1 deletion apps/serverless/src/controllers/swaggerController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,6 @@ export default (app: OpenAPIHono) => {
title: 'Doro API',
},
})
app.get('/ui', swaggerUI({ url: '/doc' }))
app.get('/swagger-ui', swaggerUI({ url: '/doc' }))
console.log('Swagger UI is available at http://localhost:8787/swagger-ui')
}
Empty file.
5 changes: 4 additions & 1 deletion apps/serverless/src/models/userModel.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
import { z } from 'zod'
import { createParamSchema, createSchema } from '../utils';

type Binding = {
"mina-doro": KVNamespace
}
export const ParamsSchema = z.object({
id: createParamSchema('id', 'string', 3),
id: createParamSchema('id', 'string', 2),
});

export const UserSchema = createSchema('User', {
Expand Down
Empty file.
18 changes: 0 additions & 18 deletions apps/serverless/wrangler.toml

This file was deleted.

Loading

0 comments on commit f819302

Please sign in to comment.