Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
sleepy-monax committed Nov 29, 2024
1 parent 01ecdb6 commit 78fa6be
Show file tree
Hide file tree
Showing 10 changed files with 144 additions and 0 deletions.
21 changes: 21 additions & 0 deletions src/apps/hideo-chat/ws/main.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#include <karm-net/router.h>
#include <karm-sys/entry.h>

namespace Hideo::Chat {

Strong<Net::App> app() {
return Net::router({
Net::get(
"/user/:id",
[](Net::Scope const &, Net::Route::Params, Strong<Net::Recv>, Strong<Net::Send>) -> Async::Task<> {
co_return Ok();
}
),
});
}

} // namespace Hideo::Chat

Async::Task<> entryPointAsync(Sys::Context &) {
return Net::servAsync(Hideo::Chat::app());
}
11 changes: 11 additions & 0 deletions src/apps/hideo-chat/ws/manifest.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"$schema": "https://schemas.cute.engineering/stable/cutekit.manifest.component.v1",
"id": "hideo-chat.ws",
"props": {
"cpp-excluded": true
},
"type": "exe",
"requires": [
"karm-net"
]
}
9 changes: 9 additions & 0 deletions src/libs/karm-crypto/_embed.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#pragma once

#include <karm-base/res.h>

namespace Karm::Crypto::_Embed {

Res<> sRand(MutBytes buf);

} // namespace Karm::Crypto::_Embed
5 changes: 5 additions & 0 deletions src/libs/karm-crypto/crypt.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#pragma once

namespace Karm::Crypto {

} // namespace Karm::Crypto
5 changes: 5 additions & 0 deletions src/libs/karm-crypto/rand.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#pragma once

namespace Karm::Crypto {

} // namespace Karm::Crypto
3 changes: 3 additions & 0 deletions src/libs/karm-crypto/readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Karm Crypto

"People say not to roll your own crypto... Oh well..."
39 changes: 39 additions & 0 deletions src/libs/karm-net/router.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
#pragma once

#include "server.h"

namespace Karm::Net {

struct Route {
using Params = Map<String, String>;

using Handler = Func<Async::Task<>(Scope const &scope, Params params, Strong<Recv> recv, Strong<Send> send)>;

virtual ~Route() = default;

virtual bool accept(Scope const &scope) const = 0;

virtual Async::Task<> handleAsync(Scope const &scope, Strong<Recv> recv, Strong<Send> send) = 0;
};

struct HttpRoute : public Route {};

Strong<Route> get(Str path, Route::Handler handler);

Strong<Route> post(Str path, Route::Handler handler);

Strong<Route> put(Str path, Route::Handler handler);

Strong<Route> del(Str path, Route::Handler handler);

struct WsRoute : public Route {};

Strong<Route> ws(Str path, Route::Handler handler);

struct Router : public App {
Vec<Strong<Route>> routes;
};

Strong<App> router(Vec<Strong<Route>> routes);

} // namespace Karm::Net
38 changes: 38 additions & 0 deletions src/libs/karm-net/server.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
#pragma once

#include <karm-base/async.h>
#include <karm-base/func.h>
#include <karm-mime/url.h>

namespace Karm::Net {

struct Scope {
enum struct _Type {
WEBSOCKET,
HTTP,
};

using enum _Type;

_Type type;
Mime::Url url;
Map<String, String> headers;
};

struct Recv {
};

struct Send {
};

struct App {
virtual ~App() = default;
virtual Async::Task<> handleAsync(Scope, Strong<Recv>, Strong<Send>) = 0;
};

struct ServProps {
};

Async::Task<> servAsync(Strong<App> app, ServProps props = {});

} // namespace Karm::Net
8 changes: 8 additions & 0 deletions src/libs/karm-store/query.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#pragma once

namespace Karm::Store {

struct Query {
};

} // namespace Karm::Store
5 changes: 5 additions & 0 deletions src/libs/karm-store/store.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#pragma once

namespace Karm::Store {

} // namespace Karm::Store

0 comments on commit 78fa6be

Please sign in to comment.