-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add installed panels count to extensions
- Loading branch information
Showing
6 changed files
with
124 additions
and
39 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import { globalAPIRouter } from "@/api" | ||
import { time } from "@rjweb/utils" | ||
import { asc, eq, sql } from "drizzle-orm" | ||
|
||
export = new globalAPIRouter.Path('/') | ||
.http('GET', '/', (http) => http | ||
.document({ | ||
description: 'Get all blueprint extensions', | ||
responses: { | ||
200: { | ||
description: 'Success', | ||
content: { | ||
'application/json': { | ||
schema: { | ||
type: 'array', | ||
items: { | ||
$ref: '#/components/schemas/Extension' | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
}) | ||
.onRequest(async(ctr) => { | ||
const extensions = await ctr["@"].cache.use('extensions::all', () => ctr["@"].database.select(ctr["@"].database.fields.extension) | ||
.from(ctr["@"].database.schema.extensions) | ||
.innerJoin(ctr["@"].database.schema.authors, eq(ctr["@"].database.schema.extensions.authorId, ctr["@"].database.schema.authors.id)) | ||
.where(eq(ctr["@"].database.schema.extensions.hidden, false)) | ||
.orderBy(asc(ctr["@"].database.schema.extensions.id)), | ||
time(5).m() | ||
) | ||
|
||
return ctr.print(extensions) | ||
}) | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
import { globalAPIRouter } from "@/api" | ||
import { time } from "@rjweb/utils" | ||
import { and, eq, or, sql } from "drizzle-orm" | ||
|
||
export = new globalAPIRouter.Path('/') | ||
.http('GET', '/', (http) => http | ||
.document({ | ||
description: 'Get a blueprint extension', | ||
responses: { | ||
200: { | ||
description: 'Success', | ||
content: { | ||
'application/json': { | ||
schema: { | ||
$ref: '#/components/schemas/Extension' | ||
} | ||
} | ||
} | ||
} | ||
}, parameters: [ | ||
{ | ||
name: 'id', | ||
in: 'path', | ||
description: 'The ID or identifier of the extension', | ||
required: true, | ||
schema: { | ||
anyOf: [ | ||
{ type: 'integer' }, | ||
{ type: 'string' } | ||
] | ||
} | ||
} | ||
] | ||
}) | ||
.onRequest(async(ctr) => { | ||
const id = ctr.params.get('id', '') | ||
if (!id) return ctr.status(ctr.$status.BAD_REQUEST).print({ errors: ['Invalid ID'] }) | ||
|
||
const idInt = parseInt(id) | ||
|
||
const [ extension ] = await ctr["@"].cache.use(`extension::${id}`, () => ctr["@"].database.select(ctr["@"].database.fields.extension) | ||
.from(ctr["@"].database.schema.extensions) | ||
.innerJoin(ctr["@"].database.schema.authors, eq(ctr["@"].database.schema.extensions.authorId, ctr["@"].database.schema.authors.id)) | ||
.where(and( | ||
eq(ctr["@"].database.schema.extensions.hidden, false), | ||
or( | ||
!isNaN(idInt) ? eq(ctr["@"].database.schema.extensions.id, idInt) : undefined, | ||
eq(ctr["@"].database.schema.extensions.identifier, id) | ||
) | ||
)), | ||
time(5).m() | ||
) | ||
|
||
if (!extension) return ctr.status(ctr.$status.NOT_FOUND).print({ errors: ['Extension not found'] }) | ||
|
||
return ctr.print(extension) | ||
}) | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters