mirror of
https://github.com/muety/wakapi.git
synced 2023-08-10 21:12:56 +03:00
fix: neutered file system
docs: add filter params to api docs
This commit is contained in:
parent
cbcdd938eb
commit
6f9015d3d8
19
main.go
19
main.go
@ -247,18 +247,19 @@ func main() {
|
|||||||
// https://github.com/golang/go/issues/43431
|
// https://github.com/golang/go/issues/43431
|
||||||
embeddedStatic, _ := fs.Sub(staticFiles, "static")
|
embeddedStatic, _ := fs.Sub(staticFiles, "static")
|
||||||
static := conf.ChooseFS("static", embeddedStatic)
|
static := conf.ChooseFS("static", embeddedStatic)
|
||||||
fileServer := gzipped.FileServer(fsutils.NewExistsHttpFS(
|
|
||||||
fsutils.NewExistsFS(
|
assetsFileServer := gzipped.FileServer(fsutils.NewExistsHttpFS(
|
||||||
fsutils.NeuteredFileSystem{
|
fsutils.NewExistsFS(static).WithCache(!config.IsDev()),
|
||||||
FS: static,
|
))
|
||||||
}).WithCache(!config.IsDev()),
|
staticFileServer := http.FileServer(http.FS(
|
||||||
|
fsutils.NeuteredFileSystem{FS: static},
|
||||||
))
|
))
|
||||||
|
|
||||||
router.PathPrefix("/contribute.json").Handler(fileServer)
|
router.PathPrefix("/contribute.json").Handler(staticFileServer)
|
||||||
router.PathPrefix("/assets").Handler(fileServer)
|
router.PathPrefix("/assets").Handler(assetsFileServer)
|
||||||
router.PathPrefix("/swagger-ui").Handler(fileServer)
|
router.PathPrefix("/swagger-ui").Handler(staticFileServer)
|
||||||
router.PathPrefix("/docs").Handler(
|
router.PathPrefix("/docs").Handler(
|
||||||
middlewares.NewFileTypeFilterMiddleware([]string{".go"})(fileServer),
|
middlewares.NewFileTypeFilterMiddleware([]string{".go"})(staticFileServer),
|
||||||
)
|
)
|
||||||
|
|
||||||
// Miscellaneous
|
// Miscellaneous
|
||||||
|
@ -41,6 +41,12 @@ func (h *SummaryApiHandler) RegisterRoutes(router *mux.Router) {
|
|||||||
// @Param from query string false "Start date (e.g. '2021-02-07')"
|
// @Param from query string false "Start date (e.g. '2021-02-07')"
|
||||||
// @Param to query string false "End date (e.g. '2021-02-08')"
|
// @Param to query string false "End date (e.g. '2021-02-08')"
|
||||||
// @Param recompute query bool false "Whether to recompute the summary from raw heartbeat or use cache"
|
// @Param recompute query bool false "Whether to recompute the summary from raw heartbeat or use cache"
|
||||||
|
// @Param project query string false "Project to filter by"
|
||||||
|
// @Param language query string false "Language to filter by"
|
||||||
|
// @Param editor query string false "Editor to filter by"
|
||||||
|
// @Param operating_system query string false "OS to filter by"
|
||||||
|
// @Param machine query string false "Machine to filter by"
|
||||||
|
// @Param label query string false "Project label to filter by"
|
||||||
// @Security ApiKeyAuth
|
// @Security ApiKeyAuth
|
||||||
// @Success 200 {object} models.Summary
|
// @Success 200 {object} models.Summary
|
||||||
// @Router /summary [get]
|
// @Router /summary [get]
|
||||||
|
@ -50,6 +50,12 @@ func (h *StatsHandler) RegisterRoutes(router *mux.Router) {
|
|||||||
// @Produce json
|
// @Produce json
|
||||||
// @Param user path string true "User ID to fetch data for (or 'current')"
|
// @Param user path string true "User ID to fetch data for (or 'current')"
|
||||||
// @Param range path string false "Range interval identifier" Enums(today, yesterday, week, month, year, 7_days, last_7_days, 30_days, last_30_days, 12_months, last_12_months, any)
|
// @Param range path string false "Range interval identifier" Enums(today, yesterday, week, month, year, 7_days, last_7_days, 30_days, last_30_days, 12_months, last_12_months, any)
|
||||||
|
// @Param project query string false "Project to filter by"
|
||||||
|
// @Param language query string false "Language to filter by"
|
||||||
|
// @Param editor query string false "Editor to filter by"
|
||||||
|
// @Param operating_system query string false "OS to filter by"
|
||||||
|
// @Param machine query string false "Machine to filter by"
|
||||||
|
// @Param label query string false "Project label to filter by"
|
||||||
// @Security ApiKeyAuth
|
// @Security ApiKeyAuth
|
||||||
// @Success 200 {object} v1.StatsViewModel
|
// @Success 200 {object} v1.StatsViewModel
|
||||||
// @Router /compat/wakatime/v1/users/{user}/stats/{range} [get]
|
// @Router /compat/wakatime/v1/users/{user}/stats/{range} [get]
|
||||||
|
@ -52,6 +52,12 @@ func (h *SummariesHandler) RegisterRoutes(router *mux.Router) {
|
|||||||
// @Param range query string false "Range interval identifier" Enums(today, yesterday, week, month, year, 7_days, last_7_days, 30_days, last_30_days, 12_months, last_12_months, any)
|
// @Param range query string false "Range interval identifier" Enums(today, yesterday, week, month, year, 7_days, last_7_days, 30_days, last_30_days, 12_months, last_12_months, any)
|
||||||
// @Param start query string false "Start date (e.g. '2021-02-07')"
|
// @Param start query string false "Start date (e.g. '2021-02-07')"
|
||||||
// @Param end query string false "End date (e.g. '2021-02-08')"
|
// @Param end query string false "End date (e.g. '2021-02-08')"
|
||||||
|
// @Param project query string false "Project to filter by"
|
||||||
|
// @Param language query string false "Language to filter by"
|
||||||
|
// @Param editor query string false "Editor to filter by"
|
||||||
|
// @Param operating_system query string false "OS to filter by"
|
||||||
|
// @Param machine query string false "Machine to filter by"
|
||||||
|
// @Param label query string false "Project label to filter by"
|
||||||
// @Security ApiKeyAuth
|
// @Security ApiKeyAuth
|
||||||
// @Success 200 {object} v1.SummariesViewModel
|
// @Success 200 {object} v1.SummariesViewModel
|
||||||
// @Router /compat/wakatime/v1/users/{user}/summaries [get]
|
// @Router /compat/wakatime/v1/users/{user}/summaries [get]
|
||||||
|
@ -313,6 +313,42 @@ var doc = `{
|
|||||||
"description": "Range interval identifier",
|
"description": "Range interval identifier",
|
||||||
"name": "range",
|
"name": "range",
|
||||||
"in": "path"
|
"in": "path"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "string",
|
||||||
|
"description": "Project to filter by",
|
||||||
|
"name": "project",
|
||||||
|
"in": "query"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "string",
|
||||||
|
"description": "Language to filter by",
|
||||||
|
"name": "language",
|
||||||
|
"in": "query"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "string",
|
||||||
|
"description": "Editor to filter by",
|
||||||
|
"name": "editor",
|
||||||
|
"in": "query"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "string",
|
||||||
|
"description": "OS to filter by",
|
||||||
|
"name": "operating_system",
|
||||||
|
"in": "query"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "string",
|
||||||
|
"description": "Machine to filter by",
|
||||||
|
"name": "machine",
|
||||||
|
"in": "query"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "string",
|
||||||
|
"description": "Project label to filter by",
|
||||||
|
"name": "label",
|
||||||
|
"in": "query"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"responses": {
|
"responses": {
|
||||||
@ -380,6 +416,42 @@ var doc = `{
|
|||||||
"description": "End date (e.g. '2021-02-08')",
|
"description": "End date (e.g. '2021-02-08')",
|
||||||
"name": "end",
|
"name": "end",
|
||||||
"in": "query"
|
"in": "query"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "string",
|
||||||
|
"description": "Project to filter by",
|
||||||
|
"name": "project",
|
||||||
|
"in": "query"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "string",
|
||||||
|
"description": "Language to filter by",
|
||||||
|
"name": "language",
|
||||||
|
"in": "query"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "string",
|
||||||
|
"description": "Editor to filter by",
|
||||||
|
"name": "editor",
|
||||||
|
"in": "query"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "string",
|
||||||
|
"description": "OS to filter by",
|
||||||
|
"name": "operating_system",
|
||||||
|
"in": "query"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "string",
|
||||||
|
"description": "Machine to filter by",
|
||||||
|
"name": "machine",
|
||||||
|
"in": "query"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "string",
|
||||||
|
"description": "Project label to filter by",
|
||||||
|
"name": "label",
|
||||||
|
"in": "query"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"responses": {
|
"responses": {
|
||||||
@ -719,6 +791,42 @@ var doc = `{
|
|||||||
"description": "Whether to recompute the summary from raw heartbeat or use cache",
|
"description": "Whether to recompute the summary from raw heartbeat or use cache",
|
||||||
"name": "recompute",
|
"name": "recompute",
|
||||||
"in": "query"
|
"in": "query"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "string",
|
||||||
|
"description": "Project to filter by",
|
||||||
|
"name": "project",
|
||||||
|
"in": "query"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "string",
|
||||||
|
"description": "Language to filter by",
|
||||||
|
"name": "language",
|
||||||
|
"in": "query"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "string",
|
||||||
|
"description": "Editor to filter by",
|
||||||
|
"name": "editor",
|
||||||
|
"in": "query"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "string",
|
||||||
|
"description": "OS to filter by",
|
||||||
|
"name": "operating_system",
|
||||||
|
"in": "query"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "string",
|
||||||
|
"description": "Machine to filter by",
|
||||||
|
"name": "machine",
|
||||||
|
"in": "query"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "string",
|
||||||
|
"description": "Project label to filter by",
|
||||||
|
"name": "label",
|
||||||
|
"in": "query"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"responses": {
|
"responses": {
|
||||||
|
@ -298,6 +298,42 @@
|
|||||||
"description": "Range interval identifier",
|
"description": "Range interval identifier",
|
||||||
"name": "range",
|
"name": "range",
|
||||||
"in": "path"
|
"in": "path"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "string",
|
||||||
|
"description": "Project to filter by",
|
||||||
|
"name": "project",
|
||||||
|
"in": "query"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "string",
|
||||||
|
"description": "Language to filter by",
|
||||||
|
"name": "language",
|
||||||
|
"in": "query"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "string",
|
||||||
|
"description": "Editor to filter by",
|
||||||
|
"name": "editor",
|
||||||
|
"in": "query"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "string",
|
||||||
|
"description": "OS to filter by",
|
||||||
|
"name": "operating_system",
|
||||||
|
"in": "query"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "string",
|
||||||
|
"description": "Machine to filter by",
|
||||||
|
"name": "machine",
|
||||||
|
"in": "query"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "string",
|
||||||
|
"description": "Project label to filter by",
|
||||||
|
"name": "label",
|
||||||
|
"in": "query"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"responses": {
|
"responses": {
|
||||||
@ -365,6 +401,42 @@
|
|||||||
"description": "End date (e.g. '2021-02-08')",
|
"description": "End date (e.g. '2021-02-08')",
|
||||||
"name": "end",
|
"name": "end",
|
||||||
"in": "query"
|
"in": "query"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "string",
|
||||||
|
"description": "Project to filter by",
|
||||||
|
"name": "project",
|
||||||
|
"in": "query"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "string",
|
||||||
|
"description": "Language to filter by",
|
||||||
|
"name": "language",
|
||||||
|
"in": "query"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "string",
|
||||||
|
"description": "Editor to filter by",
|
||||||
|
"name": "editor",
|
||||||
|
"in": "query"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "string",
|
||||||
|
"description": "OS to filter by",
|
||||||
|
"name": "operating_system",
|
||||||
|
"in": "query"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "string",
|
||||||
|
"description": "Machine to filter by",
|
||||||
|
"name": "machine",
|
||||||
|
"in": "query"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "string",
|
||||||
|
"description": "Project label to filter by",
|
||||||
|
"name": "label",
|
||||||
|
"in": "query"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"responses": {
|
"responses": {
|
||||||
@ -704,6 +776,42 @@
|
|||||||
"description": "Whether to recompute the summary from raw heartbeat or use cache",
|
"description": "Whether to recompute the summary from raw heartbeat or use cache",
|
||||||
"name": "recompute",
|
"name": "recompute",
|
||||||
"in": "query"
|
"in": "query"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "string",
|
||||||
|
"description": "Project to filter by",
|
||||||
|
"name": "project",
|
||||||
|
"in": "query"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "string",
|
||||||
|
"description": "Language to filter by",
|
||||||
|
"name": "language",
|
||||||
|
"in": "query"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "string",
|
||||||
|
"description": "Editor to filter by",
|
||||||
|
"name": "editor",
|
||||||
|
"in": "query"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "string",
|
||||||
|
"description": "OS to filter by",
|
||||||
|
"name": "operating_system",
|
||||||
|
"in": "query"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "string",
|
||||||
|
"description": "Machine to filter by",
|
||||||
|
"name": "machine",
|
||||||
|
"in": "query"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "string",
|
||||||
|
"description": "Project label to filter by",
|
||||||
|
"name": "label",
|
||||||
|
"in": "query"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"responses": {
|
"responses": {
|
||||||
|
@ -536,6 +536,30 @@ paths:
|
|||||||
in: path
|
in: path
|
||||||
name: range
|
name: range
|
||||||
type: string
|
type: string
|
||||||
|
- description: Project to filter by
|
||||||
|
in: query
|
||||||
|
name: project
|
||||||
|
type: string
|
||||||
|
- description: Language to filter by
|
||||||
|
in: query
|
||||||
|
name: language
|
||||||
|
type: string
|
||||||
|
- description: Editor to filter by
|
||||||
|
in: query
|
||||||
|
name: editor
|
||||||
|
type: string
|
||||||
|
- description: OS to filter by
|
||||||
|
in: query
|
||||||
|
name: operating_system
|
||||||
|
type: string
|
||||||
|
- description: Machine to filter by
|
||||||
|
in: query
|
||||||
|
name: machine
|
||||||
|
type: string
|
||||||
|
- description: Project label to filter by
|
||||||
|
in: query
|
||||||
|
name: label
|
||||||
|
type: string
|
||||||
produces:
|
produces:
|
||||||
- application/json
|
- application/json
|
||||||
responses:
|
responses:
|
||||||
@ -583,6 +607,30 @@ paths:
|
|||||||
in: query
|
in: query
|
||||||
name: end
|
name: end
|
||||||
type: string
|
type: string
|
||||||
|
- description: Project to filter by
|
||||||
|
in: query
|
||||||
|
name: project
|
||||||
|
type: string
|
||||||
|
- description: Language to filter by
|
||||||
|
in: query
|
||||||
|
name: language
|
||||||
|
type: string
|
||||||
|
- description: Editor to filter by
|
||||||
|
in: query
|
||||||
|
name: editor
|
||||||
|
type: string
|
||||||
|
- description: OS to filter by
|
||||||
|
in: query
|
||||||
|
name: operating_system
|
||||||
|
type: string
|
||||||
|
- description: Machine to filter by
|
||||||
|
in: query
|
||||||
|
name: machine
|
||||||
|
type: string
|
||||||
|
- description: Project label to filter by
|
||||||
|
in: query
|
||||||
|
name: label
|
||||||
|
type: string
|
||||||
produces:
|
produces:
|
||||||
- application/json
|
- application/json
|
||||||
responses:
|
responses:
|
||||||
@ -804,6 +852,30 @@ paths:
|
|||||||
in: query
|
in: query
|
||||||
name: recompute
|
name: recompute
|
||||||
type: boolean
|
type: boolean
|
||||||
|
- description: Project to filter by
|
||||||
|
in: query
|
||||||
|
name: project
|
||||||
|
type: string
|
||||||
|
- description: Language to filter by
|
||||||
|
in: query
|
||||||
|
name: language
|
||||||
|
type: string
|
||||||
|
- description: Editor to filter by
|
||||||
|
in: query
|
||||||
|
name: editor
|
||||||
|
type: string
|
||||||
|
- description: OS to filter by
|
||||||
|
in: query
|
||||||
|
name: operating_system
|
||||||
|
type: string
|
||||||
|
- description: Machine to filter by
|
||||||
|
in: query
|
||||||
|
name: machine
|
||||||
|
type: string
|
||||||
|
- description: Project label to filter by
|
||||||
|
in: query
|
||||||
|
name: label
|
||||||
|
type: string
|
||||||
produces:
|
produces:
|
||||||
- application/json
|
- application/json
|
||||||
responses:
|
responses:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user