-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
34 changed files
with
443 additions
and
19 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,6 +10,9 @@ | |
# Data | ||
/data/ | ||
|
||
# OpenAPI | ||
/openapi/schema.html | ||
|
||
# Tracked, but not needed | ||
/.devcontainer/ | ||
/.github/ | ||
|
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 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 |
---|---|---|
|
@@ -13,3 +13,6 @@ | |
# Data | ||
/data/* | ||
!/data/.gitkeep | ||
|
||
# OpenAPI | ||
/openapi/schema.html |
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 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 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
info: | ||
title: fusion app | ||
description: Audio streaming with Liquidsoap 🧼 | ||
openapi: 3.1.0 | ||
servers: | ||
- url: / | ||
paths: | ||
/ping: | ||
get: | ||
summary: Ping | ||
description: Do nothing. | ||
responses: | ||
"204": | ||
description: Request fulfilled, nothing follows | ||
headers: | ||
Cache-Control: | ||
schema: | ||
type: string | ||
example: no-cache | ||
/playlist: | ||
get: | ||
summary: Get playlist data | ||
description: Get the current playlist data. | ||
responses: | ||
"200": | ||
description: Request fulfilled, document follows | ||
content: | ||
application/json: | ||
schema: | ||
$ref: "#/components/schemas/GetPlaylistResponse" | ||
"404": | ||
description: Request failed, resource not found | ||
content: | ||
text/plain: | ||
schema: | ||
type: string | ||
example: Playlist data not found. | ||
put: | ||
summary: Update playlist data | ||
description: Update the current playlist data. | ||
requestBody: | ||
required: true | ||
content: | ||
application/json: | ||
schema: | ||
$ref: "#/components/schemas/PutPlaylistRequest" | ||
responses: | ||
"200": | ||
description: Request fulfilled, document follows | ||
content: | ||
application/json: | ||
schema: | ||
$ref: "#/components/schemas/PutPlaylistResponse" | ||
"400": | ||
description: Bad request syntax | ||
content: | ||
text/plain: | ||
schema: | ||
type: string | ||
example: Request body is not a valid JSON object. | ||
components: | ||
schemas: | ||
GetPlaylistResponse: | ||
type: object | ||
properties: | ||
id: | ||
type: string | ||
format: uuid | ||
example: 123e4567-e89b-12d3-a456-426614174000 | ||
required: | ||
- id | ||
PutPlaylistRequest: | ||
type: object | ||
properties: | ||
id: | ||
type: string | ||
format: uuid | ||
example: 123e4567-e89b-12d3-a456-426614174000 | ||
required: | ||
- id | ||
PutPlaylistResponse: | ||
type: object | ||
properties: | ||
id: | ||
type: string | ||
format: uuid | ||
example: 123e4567-e89b-12d3-a456-426614174000 | ||
required: | ||
- id |
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,19 @@ | ||
let api.app = {} | ||
|
||
def api.app.register(~method, ~path, handler) = | ||
def handle(request) = | ||
try | ||
handler(request) | ||
catch _ do | ||
api.responses.text( | ||
status=api.codes.internalservererror, | ||
body= | ||
"Internal Server Error" | ||
) | ||
end | ||
end | ||
|
||
harbor.http.register.simple( | ||
port=config.server.http.port, method=method, path, handle | ||
) | ||
end |
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,8 @@ | ||
let api.codes = {} | ||
|
||
let api.codes.ok = 200 | ||
let api.codes.created = 201 | ||
let api.codes.nocontent = 204 | ||
let api.codes.badrequest = 400 | ||
let api.codes.notfound = 404 | ||
let api.codes.internalservererror = 500 |
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,8 @@ | ||
let api = {} | ||
|
||
%include "codes.liq" | ||
%include "responses.liq" | ||
%include "app.liq" | ||
%include "ping/index.liq" | ||
%include "playlist/index.liq" | ||
%include "schema/index.liq" |
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,8 @@ | ||
let api.ping.controller = {} | ||
|
||
def api.ping.controller.ping(_) = | ||
api.ping.service.ping() | ||
api.responses.empty(headers=[("Cache-Control", "no-cache")]) | ||
end | ||
|
||
api.app.register(method="GET", path="/ping", api.ping.controller.ping) |
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,4 @@ | ||
let api.ping = {} | ||
|
||
%include "service.liq" | ||
%include "controller.liq" |
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,5 @@ | ||
let api.ping.service = {} | ||
|
||
def api.ping.service.ping() = | ||
() | ||
end |
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,28 @@ | ||
let api.playlist.controller = {} | ||
|
||
def api.playlist.controller.get(_) = | ||
try | ||
response = api.playlist.service.get() | ||
api.responses.json( | ||
status=api.codes.ok, | ||
body=api.playlist.models.getresponse.serialize(response) | ||
) | ||
catch error : [api.playlist.errors.notfound] do | ||
api.responses.text(status=api.codes.notfound, body=error.message) | ||
end | ||
end | ||
|
||
def api.playlist.controller.put(request) = | ||
try | ||
req = api.playlist.models.putrequest.deserialize(request.body()) | ||
res = api.playlist.service.put(req) | ||
api.responses.json( | ||
status=api.codes.ok, body=api.playlist.models.putresponse.serialize(res) | ||
) | ||
catch error : [error.json] do | ||
api.responses.text(status=api.codes.badrequest, body=error.message) | ||
end | ||
end | ||
|
||
api.app.register(method="GET", path="/playlist", api.playlist.controller.get) | ||
api.app.register(method="PUT", path="/playlist", api.playlist.controller.put) |
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,4 @@ | ||
let api.playlist.errors = {} | ||
|
||
let api.playlist.errors.notfound = | ||
error.register("api.playlist.errors.notfound") |
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,6 @@ | ||
let api.playlist = {} | ||
|
||
%include "errors.liq" | ||
%include "models.liq" | ||
%include "service.liq" | ||
%include "controller.liq" |
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,52 @@ | ||
let api.playlist.models = {} | ||
|
||
def api.playlist.models.getresponse = | ||
def create(~id) = | ||
{id=id} | ||
end | ||
|
||
def serialize(model) = | ||
json.stringify(model) | ||
end | ||
|
||
def deserialize(data) = | ||
let json.parse (model : {id: string}) = data | ||
model | ||
end | ||
|
||
{create=create, serialize=serialize, deserialize=deserialize} | ||
end | ||
|
||
def api.playlist.models.putrequest = | ||
def create(~id) = | ||
{id=id} | ||
end | ||
|
||
def serialize(model) = | ||
json.stringify(model) | ||
end | ||
|
||
def deserialize(data) = | ||
let json.parse (model : {id: string}) = data | ||
model | ||
end | ||
|
||
{create=create, serialize=serialize, deserialize=deserialize} | ||
end | ||
|
||
def api.playlist.models.putresponse = | ||
def create(~id) = | ||
{id=id} | ||
end | ||
|
||
def serialize(model) = | ||
json.stringify(model) | ||
end | ||
|
||
def deserialize(data) = | ||
let json.parse (model : {id: string}) = data | ||
model | ||
end | ||
|
||
{create=create, serialize=serialize, deserialize=deserialize} | ||
end |
Oops, something went wrong.