Skip to content

Commit

Permalink
fix(misc): several inconsistencies
Browse files Browse the repository at this point in the history
  • Loading branch information
bouassaba committed Nov 8, 2024
1 parent 3969e86 commit 66f13e0
Show file tree
Hide file tree
Showing 21 changed files with 189 additions and 246 deletions.
6 changes: 3 additions & 3 deletions api/client/mosaic_client/mosaic_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -185,12 +185,12 @@ type MosaicDownloadTileOptions struct {
S3Bucket string `json:"s3Bucket"`
ZoomLevel int `json:"zoomLevel"`
Row int `json:"row"`
Col int `json:"col"`
Ext string `json:"ext"`
Column int `json:"column"`
Extension string `json:"extension"`
}

func (cl *MosaicClient) DownloadTileBuffer(opts MosaicDownloadTileOptions) (*bytes.Buffer, error) {
resp, err := http.Get(fmt.Sprintf("%s/v3/mosaics/%s/%s/zoom_level/%d/row/%d/col/%d/ext/%s", cl.config.MosaicURL, opts.S3Bucket, opts.S3Key, opts.ZoomLevel, opts.Row, opts.Col, opts.Ext))
resp, err := http.Get(fmt.Sprintf("%s/v3/mosaics/%s/%s/zoom_level/%d/row/%d/column/%d/extension/%s", cl.config.MosaicURL, opts.S3Bucket, opts.S3Key, opts.ZoomLevel, opts.Row, opts.Column, opts.Extension))
if err != nil {
return nil, err
}
Expand Down
10 changes: 5 additions & 5 deletions api/docs/index.html

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions api/docs/swagger.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2925,7 +2925,7 @@ paths:
summary: Read Info
tags:
- Mosaic
/mosaics/{id}/zoom_level/{zoom_level}/row/{row}/col/{col}/ext/{ext}:
/mosaics/{id}/zoom_level/{zoom_level}/row/{row}/column/{column}/extension/{extension}:
get:
description: Download Tile
operationId: mosaic_download_tile
Expand All @@ -2945,9 +2945,9 @@ paths:
name: row
required: true
type: string
- description: Col
- description: Column
in: path
name: col
name: column
required: true
type: string
produces:
Expand Down
26 changes: 13 additions & 13 deletions api/router/file_router.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,9 +87,9 @@ func (r *FileRouter) AppendRoutes(g fiber.Router) {
}

func (r *FileRouter) AppendNonJWTRoutes(g fiber.Router) {
g.Get("/:id/original.:ext", r.DownloadOriginal)
g.Get("/:id/preview.:ext", r.DownloadPreview)
g.Get("/:id/thumbnail.:ext", r.DownloadThumbnail)
g.Get("/:id/original.:extension", r.DownloadOriginal)
g.Get("/:id/preview.:extension", r.DownloadPreview)
g.Get("/:id/thumbnail.:extension", r.DownloadThumbnail)
g.Post("/create_from_s3", r.CreateFromS3)
g.Patch("/:id/patch_from_s3", r.PatchFromS3)
}
Expand Down Expand Up @@ -929,8 +929,8 @@ func (r *FileRouter) DownloadOriginal(c *fiber.Ctx) error {
if id == "" {
return errorpkg.NewMissingQueryParamError("id")
}
ext := c.Params("ext")
if ext == "" {
extension := c.Params("extension")
if extension == "" {
return errorpkg.NewMissingQueryParamError("ext")
}
buf := r.bufferPool.Get().(*bytes.Buffer)
Expand All @@ -940,7 +940,7 @@ func (r *FileRouter) DownloadOriginal(c *fiber.Ctx) error {
if err != nil {
return err
}
if strings.TrimPrefix(filepath.Ext(snapshot.GetOriginal().Key), ".") != ext {
if strings.TrimPrefix(filepath.Ext(snapshot.GetOriginal().Key), ".") != extension {
return errorpkg.NewS3ObjectNotFoundError(nil)
}
c.Set("Content-Type", infra.DetectMIMEFromBytes(buf.Bytes()))
Expand Down Expand Up @@ -981,8 +981,8 @@ func (r *FileRouter) DownloadPreview(c *fiber.Ctx) error {
if id == "" {
return errorpkg.NewMissingQueryParamError("id")
}
ext := c.Params("ext")
if ext == "" {
extension := c.Params("extension")
if extension == "" {
return errorpkg.NewMissingQueryParamError("ext")
}
buf := r.bufferPool.Get().(*bytes.Buffer)
Expand All @@ -992,7 +992,7 @@ func (r *FileRouter) DownloadPreview(c *fiber.Ctx) error {
if err != nil {
return err
}
if strings.TrimPrefix(filepath.Ext(snapshot.GetPreview().Key), ".") != ext {
if strings.TrimPrefix(filepath.Ext(snapshot.GetPreview().Key), ".") != extension {
return errorpkg.NewS3ObjectNotFoundError(nil)
}
c.Set("Content-Type", infra.DetectMIMEFromBytes(buf.Bytes()))
Expand Down Expand Up @@ -1033,8 +1033,8 @@ func (r *FileRouter) DownloadThumbnail(c *fiber.Ctx) error {
if id == "" {
return errorpkg.NewMissingQueryParamError("id")
}
ext := c.Params("ext")
if ext == "" {
extension := c.Params("extension")
if extension == "" {
return errorpkg.NewMissingQueryParamError("ext")
}
buf := r.bufferPool.Get().(*bytes.Buffer)
Expand All @@ -1044,11 +1044,11 @@ func (r *FileRouter) DownloadThumbnail(c *fiber.Ctx) error {
if err != nil {
return err
}
if strings.TrimPrefix(filepath.Ext(snapshot.GetThumbnail().Key), ".") != ext {
if strings.TrimPrefix(filepath.Ext(snapshot.GetThumbnail().Key), ".") != extension {
return errorpkg.NewS3ObjectNotFoundError(nil)
}
c.Set("Content-Type", infra.DetectMIMEFromBytes(buf.Bytes()))
c.Set("Content-Disposition", fmt.Sprintf("filename=\"thumbnail%s\"", ext))
c.Set("Content-Disposition", fmt.Sprintf("filename=\"thumbnail%s\"", extension))
return c.Send(buf.Bytes())
}

Expand Down
20 changes: 10 additions & 10 deletions api/router/insights_router.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,8 @@ func (r *InsightsRouter) AppendRoutes(g fiber.Router) {
}

func (r *InsightsRouter) AppendNonJWTRoutes(g fiber.Router) {
g.Get("/:id/text:ext", r.DownloadText)
g.Get("/:id/ocr:ext", r.DownloadOCR)
g.Get("/:id/text:extension", r.DownloadText)
g.Get("/:id/ocr:extension", r.DownloadOCR)
}

// FindLanguages godoc
Expand Down Expand Up @@ -295,20 +295,20 @@ func (r *InsightsRouter) DownloadText(c *fiber.Ctx) error {
if id == "" {
return errorpkg.NewMissingQueryParamError("id")
}
ext := c.Params("ext")
if ext == "" {
extension := c.Params("extension")
if extension == "" {
return errorpkg.NewMissingQueryParamError("ext")
}
buf, file, snapshot, err := r.insightsSvc.DownloadTextBuffer(id, userID)
if err != nil {
return err
}
if filepath.Ext(snapshot.GetText().Key) != ext {
if filepath.Ext(snapshot.GetText().Key) != extension {
return errorpkg.NewS3ObjectNotFoundError(nil)
}
b := buf.Bytes()
c.Set("Content-Type", infra.DetectMIMEFromBytes(b))
c.Set("Content-Disposition", fmt.Sprintf("filename=\"%s\"", filepath.Base(file.GetName())+ext))
c.Set("Content-Disposition", fmt.Sprintf("filename=\"%s\"", filepath.Base(file.GetName())+extension))
return c.Send(b)
}

Expand Down Expand Up @@ -341,20 +341,20 @@ func (r *InsightsRouter) DownloadOCR(c *fiber.Ctx) error {
if id == "" {
return errorpkg.NewMissingQueryParamError("id")
}
ext := c.Params("ext")
if ext == "" {
extension := c.Params("extension")
if extension == "" {
return errorpkg.NewMissingQueryParamError("ext")
}
buf, file, snapshot, err := r.insightsSvc.DownloadOCRBuffer(id, userID)
if err != nil {
return err
}
if filepath.Ext(snapshot.GetOCR().Key) != ext {
if filepath.Ext(snapshot.GetOCR().Key) != extension {
return errorpkg.NewS3ObjectNotFoundError(nil)
}
b := buf.Bytes()
c.Set("Content-Type", infra.DetectMIMEFromBytes(b))
c.Set("Content-Disposition", fmt.Sprintf("filename=\"%s\"", filepath.Base(file.GetName())+ext))
c.Set("Content-Disposition", fmt.Sprintf("filename=\"%s\"", filepath.Base(file.GetName())+extension))
return c.Send(b)
}

Expand Down
22 changes: 11 additions & 11 deletions api/router/mosaic_router.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ func (r *MosaicRouter) AppendRoutes(g fiber.Router) {
}

func (r *MosaicRouter) AppendNonJWTRoutes(g fiber.Router) {
g.Get("/:id/zoom_level/:zoom_level/row/:row/col/:col/ext/:ext", r.DownloadTile)
g.Get("/:id/zoom_level/:zoom_level/row/:row/column/:column/extension/:extension", r.DownloadTile)
}

// Create godoc
Expand Down Expand Up @@ -122,10 +122,10 @@ func (r *MosaicRouter) ReadInfo(c *fiber.Ctx) error {
// @Param id path string true "ID"
// @Param zoom_level path string true "Zoom Level"
// @Param row path string true "Row"
// @Param col path string true "Col"
// @Param column path string true "Column"
// @Failure 404 {object} errorpkg.ErrorResponse
// @Failure 500 {object} errorpkg.ErrorResponse
// @Router /mosaics/{id}/zoom_level/{zoom_level}/row/{row}/col/{col}/ext/{ext} [get]
// @Router /mosaics/{id}/zoom_level/{zoom_level}/row/{row}/column/{column}/extension/{extension} [get]
func (r *MosaicRouter) DownloadTile(c *fiber.Ctx) error {
accessToken := c.Cookies(r.accessTokenCookieName)
if accessToken == "" {
Expand Down Expand Up @@ -160,20 +160,20 @@ func (r *MosaicRouter) DownloadTile(c *fiber.Ctx) error {
return err
}
}
var col int64
if c.Params("col") == "" {
return errorpkg.NewMissingQueryParamError("col")
var column int64
if c.Params("column") == "" {
return errorpkg.NewMissingQueryParamError("column")
} else {
col, err = strconv.ParseInt(c.Params("col"), 10, 64)
column, err = strconv.ParseInt(c.Params("column"), 10, 64)
if err != nil {
return err
}
}
buf, snapshot, err := r.mosaicSvc.DownloadTileBuffer(id, service.MosaicDownloadTileOptions{
ZoomLevel: int(zoomLevel),
Row: int(row),
Col: int(col),
Ext: c.Params("ext"),
Column: int(column),
Extension: c.Params("extension"),
}, userID)
if err != nil {
return err
Expand All @@ -184,12 +184,12 @@ func (r *MosaicRouter) DownloadTile(c *fiber.Ctx) error {
} else {
extension = filepath.Ext(snapshot.GetOriginal().Key)
}
if strings.TrimPrefix(extension, ".") != c.Params("ext") {
if strings.TrimPrefix(extension, ".") != c.Params("extension") {
return errorpkg.NewS3ObjectNotFoundError(nil)
}
b := buf.Bytes()
c.Set("Content-Type", infra.DetectMIMEFromBytes(b))
c.Set("Content-Disposition", fmt.Sprintf("filename=\"tile%s\"", c.Params("ext")))
c.Set("Content-Disposition", fmt.Sprintf("filename=\"tile%s\"", c.Params("extension")))
return c.Send(b)
}

Expand Down
8 changes: 4 additions & 4 deletions api/router/user_router.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ func (r *UserRouter) AppendRoutes(g fiber.Router) {
}

func (r *UserRouter) AppendNonJWTRoutes(g fiber.Router) {
g.Get("/:id/picture:ext", r.DownloadPicture)
g.Get("/:id/picture:extension", r.DownloadPicture)
}

// List godoc
Expand Down Expand Up @@ -187,8 +187,8 @@ func (r *UserRouter) DownloadPicture(c *fiber.Ctx) error {
if id == "" {
return errorpkg.NewMissingQueryParamError("id")
}
if c.Params("ext") == "" {
return errorpkg.NewMissingQueryParamError("ext")
if c.Params("extension") == "" {
return errorpkg.NewMissingQueryParamError("extension")
}
var orgID *string
if c.Query("organization_id") != "" {
Expand All @@ -210,7 +210,7 @@ func (r *UserRouter) DownloadPicture(c *fiber.Ctx) error {
if err != nil {
return err
}
if *ext != c.Params("ext") {
if *ext != c.Params("extension") {
return errorpkg.NewUserPictureNotFoundError(nil)
}
c.Set("Content-Type", *mime)
Expand Down
8 changes: 4 additions & 4 deletions api/service/mosaic_service.go
Original file line number Diff line number Diff line change
Expand Up @@ -237,8 +237,8 @@ func (svc *MosaicService) ReadInfo(id string, userID string) (*MosaicInfo, error
type MosaicDownloadTileOptions struct {
ZoomLevel int
Row int
Col int
Ext string
Column int
Extension string
}

func (svc *MosaicService) DownloadTileBuffer(id string, opts MosaicDownloadTileOptions, userID string) (*bytes.Buffer, model.Snapshot, error) {
Expand Down Expand Up @@ -272,8 +272,8 @@ func (svc *MosaicService) DownloadTileBuffer(id string, opts MosaicDownloadTileO
S3Bucket: snapshot.GetPreview().Bucket,
ZoomLevel: opts.ZoomLevel,
Row: opts.Row,
Col: opts.Col,
Ext: opts.Ext,
Column: opts.Column,
Extension: opts.Extension,
})
if err != nil {
return nil, nil, err
Expand Down
2 changes: 1 addition & 1 deletion idp/src/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ passport.use(
)

app.use('/v3/health', healthRouter)
app.use('/v3/user', userRouter)
app.use('/v3/users', userRouter)
app.use('/v3/accounts', accountRouter)
app.use('/v3/token', tokenRouter)
app.use('/version', versionRouter)
Expand Down
48 changes: 0 additions & 48 deletions idp/src/infra/admin-requests.ts

This file was deleted.

Loading

0 comments on commit 66f13e0

Please sign in to comment.