Skip to content

Commit

Permalink
Patching pack (#2718)
Browse files Browse the repository at this point in the history
* remove api: /api/mock/achievement

* remove page: /demo/achievement

* add api: /api/authenticate
  • Loading branch information
aggre authored Aug 8, 2024
1 parent 9cad2f9 commit 17da3c9
Show file tree
Hide file tree
Showing 5 changed files with 44 additions and 200 deletions.
1 change: 1 addition & 0 deletions built-in-api-paths.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ export default [
'/api/cron',
'/api/config',
'/api/clubs',
'/api/authenticate',
'/api/assets',
'/api/addDaoToDraft',
]
43 changes: 43 additions & 0 deletions src/pages/api/authenticate.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
import { getDefaultClient } from '@fixtures/api/club/redis'
import { authenticate, decode } from '@devprotocol/clubs-core'
import { isNotError, whenDefined, whenNotError } from '@devprotocol/util-ts'
import { json } from '@fixtures/api/json'
import { headers } from '@fixtures/api/headers'
import { getDefaultProvider } from 'ethers'

export const POST = async ({ request }: { request: Request }) => {
const { message, signature, site } = (await request.json()) as {
site: string
message: string
signature: string
}

const client = await getDefaultClient()

const config = await client.get(site)
const authenticated =
(await whenDefined(config, (previousConfiguration) =>
authenticate({
message,
signature,
previousConfiguration,
provider: getDefaultProvider(decode(previousConfiguration).rpcUrl),
}),
)) ?? new Error('Specified Club is not defined.')

const res = whenNotError(authenticated, (_auth) =>
_auth ? _auth : new Error('Unauthorized'),
)

return isNotError(res)
? new Response(
json({
authenticated: res,
}),
{ status: 200, headers },
)
: new Response(json({ error: res.message }), {
status: 401,
headers,
})
}
109 changes: 0 additions & 109 deletions src/pages/api/mock/achievement/[account].ts

This file was deleted.

78 changes: 0 additions & 78 deletions src/pages/demo/App.vue

This file was deleted.

13 changes: 0 additions & 13 deletions src/pages/demo/achievements.astro

This file was deleted.

0 comments on commit 17da3c9

Please sign in to comment.