Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit68c77cf

Browse files
committed
update server endpoints to conform to new names and types
1 parent6643d8b commit68c77cf

File tree

5 files changed

+16
-13
lines changed

5 files changed

+16
-13
lines changed

‎services/src/auth/api-access.ts‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,12 @@ export type SelectableApiKey = Selectable<Apiaccess>
88
constapiAccessIdSchema=z.number().brand('api-access')
99
exporttypeApiAccessId=z.infer<typeofapiAccessIdSchema>
1010

11-
constapiKeyKeySchema=z.string().uuid().brand('api-key')
12-
exporttypeApiKey=z.infer<typeofapiKeyKeySchema>
11+
exportconstapiKeySchema=z.string().uuid().brand('api-key')
12+
exporttypeApiKey=z.infer<typeofapiKeySchema>
1313

1414
exportconstapiAccessSchema=z.object({
1515
id:apiAccessIdSchema,
16-
apikey:apiKeyKeySchema,
16+
apikey:apiKeySchema,
1717
name:z.string(),
1818
project_id:z.number(),
1919
created_at:z.date(),

‎src/routes/(api)/api/[project]/[lang]/translations/+server.ts‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import{validateRequestBody}from'$lib/server/request-utils'
2+
importtype{ProjectId}from'services/project/project'
23
import{authorize}from'../../../api-utils'
3-
import{translationPOSTRequestSchema,typeProjectId}from'../../../api.model'
4+
import{translationPOSTRequestSchema}from'../../../api.model'
45
importtype{RequestHandler}from'./$types'
56

67
exportconstPOST:RequestHandler=async({ params, request})=>{

‎src/routes/(api)/api/[project]/config/+server.ts‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import{validateRequestBody}from'$lib/server/request-utils'
2+
importtype{ProjectId}from'services/project/project'
23
import{authorize}from'../../api-utils'
3-
import{projectConfigPOSTRequestSchema,typeProjectId}from'../../api.model'
4+
import{projectConfigPOSTRequestSchema}from'../../api.model'
45
importtype{RequestHandler}from'./$types'
56

67
exportconstPOST:RequestHandler=async({ params, request})=>{

‎src/routes/(api)/api/api-utils.ts‎

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,17 @@
11
import{checkApiKeyAccess}from'services/auth/api-access.service'
2-
importtype{ProjectId}from'./api.model'
32
import{error}from'@sveltejs/kit'
3+
import{apiKeySchema}from'services/auth/api-access'
4+
importtype{ProjectId}from'services/project/project'
45

5-
exportconstauthorize=async(req:Request,project:ProjectId)=>{
6-
constapiKey=req.headers.get('Authorization')
7-
if(!apiKey){
6+
exportconstauthorize=async(req:Request,projectId:ProjectId)=>{
7+
if(req.headers.get('Authorization')){
88
error(401,'No API key provided in the Authorization header')
99
}
10-
consthasAccess=awaitcheckApiKeyAccess(apiKey,project)
10+
constparsedApiKey=apiKeySchema.safeParse(req.headers.get('Authorization'))
11+
if(parsedApiKey.error){
12+
error(400,'The provided API key does not conform to the correct schema')
13+
}
14+
consthasAccess=awaitcheckApiKeyAccess(parsedApiKey.data,projectId)
1115
if(!hasAccess){
1216
error(
1317
403,

‎src/routes/(api)/api/api.model.ts‎

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,6 @@ export type TranslationKey = z.infer<typeof translationKeySchema>
66
consttranslationValueSchema=z.string().brand('translation-value')
77
exporttypeTranslationValue=z.infer<typeoftranslationValueSchema>
88

9-
constprojectIdSchema=z.number().brand('project-id')
10-
exporttypeProjectId=z.infer<typeofprojectIdSchema>
11-
129
constaddTranslationCommandSchema=z.object({
1310
key:translationKeySchema,
1411
value:translationValueSchema

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp