使用自托管服务器为您的网站提供服务并销售课程。
sserver是简单的无头服务器,用于以最小的开销托管来自私人 github 存储库的课程和相关博客/静态内容。
它提供开箱即用的 https,因此您无需处理安装/管理证书。它会自动从 github 同步内容,因此您无需将内容上传到服务器。它还通过简单的配置文件支持高级内容,而不会影响您的内容工作流程,例如,如果您使用像hugo这样的静态站点生成器,您可以通过在配置文件中指定来向公众隐藏高级内容。它具有条带集成功能,因此您可以出售优质内容。它内置了用于添加/验证用户的用户管理。它还具有管理 API,因此您可以监控站点的订单/用户。
以下是一些如何使用它的示例,请确保在尝试之前设置 SS_<> 环境变量,例如
export SS_GITHUB_TOKEN=<github_token>
export SS_STRIPE_TOKEN=<stripe_token>
export SS_SMTP_FROM=<email_id>
export SS_SMTP_USER=<smtp_username>
export SS_SMTP_PWD=<smtp_password>
export SS_SMTP_HOST=<smtp_host_address>
export SS_SMTP_PORT=<smtp_port>
export SS_ADMIN_EMAIL=<admin_email>
export SS_ADMIN_PWD=<admin_password_for_sserver>
./sserver -repo "https://github.com/newbeelearn/sserver.git"
存储库的根目录中应包含 index.html 和 ssconfig.toml。如果使用hugo/jekyll等静态站点生成器,存储库应包含生成的站点。(默认情况下,根目录中有index.html)
./sserver -repo "https://github.com/newbeelearn/sserver.git?folder=public"
存储库应该在您想要提供内容的文件夹中包含index.html,如果使用hugo/jekyll等静态站点生成器,通常它是公共的。根目录中应该有 ssconfig.toml
./sserver -repo "https://github.com/newbeelearn/sserver.git?ref=test-config"
分支的根目录中应该有index.html和ssconfig.toml。如果使用hugo/jekyll等静态站点生成器,则分支应包含生成的站点。(默认情况下,根目录中有index.html)
./sserver -repo "https://github.com/newbeelearn/sserver.git?domain=example.com"
存储库的根目录中应该有index.html和ssconfig.toml 访问服务站点的域sserver应该有权绑定到443端口,这可以通过以下命令来完成
sudo setcap 'cap_net_bind_service=+ep' sserver
./sserver -repo "file:///workspace/projects/newbeelearn.com/sserver"
存储库的根目录中应包含 index.html 和 ssconfig.toml。如果是本地文件,也可以指定所有选项,即文件夹/域等
示例 ssconfig.toml 可以在下面找到
# specify the site
[site]
# period to check for new content
syncinterval = "@every 12h"
# product/course details
[[site.prod]]
name = "course1"
# path from root, this will be accessible to users who have bought the course
path = "courses/course1"
# can be draft/active, buying functionality will be enabled when status is active
status = "active"
# unique identifier for the course
sku = "prod-course-1"
# price in cents
price = 10000
# currency
currency = "USD"
sserver从运行的位置创建“wwwss”目录
drwxrwxr-x 2 test test 4096 Nov 30 17:04 a
drwxrwxr-x 8 test test 4096 Nov 30 17:04 b
drwxrwxr-x 2 test test 4096 Nov 30 17:04 certs
drwxrwxr-x 2 test test 4096 Nov 30 17:04 logs
-rw-rw-r-- 1 test test 527483 Nov 30 17:04 tmp.zip
-rw-rw-r-- 1 test test 49152 Nov 30 17:05 ssapp.db
配置文件用于指定您想要销售的产品/课程以及一些服务器参数,例如站点同步的频率等。
示例 ssconfig.toml 文件如下所示
#specify the site
[site]
#period to check for new content default is 12 hours
syncinterval = "@every 12h"
[[site.prod]]
name = "course1"
path = "courses/course1"
status = "active"
sku = "prod-course-1"
price = 10000
currency = "USD"
所有 api 端点都与用于提供内容的域相关,即如果域是 example.com 并且 api 是/api/v1/product/list
请求将是 https://example.com/api/v1/product/list
角色层次结构如下 admin > user > guest 任何可以访问 guest 的 api 也可以访问 user,任何可以访问 user 的 api 也可以访问 admin 对于访问 user/admin,登录后获取的 api 的会话 cookie 必须随每个请求一起提供实践中这将由浏览器处理
描述 | 要求 | 角色 |
---|---|---|
注册用户 | POST /api/v1/user/register | 客人 |
登录用户 | POST /api/v1/user/login | 客人 |
注销用户 | 获取/api/v1/user/logout | 客人 |
验证用户 | 获取/api/v1/user/verify/:id | 客人 |
重置用户密码 | POST /api/v1/user/reset | 客人 |
获取产品清单 | 获取/api/v1/product/list | 客人 |
创建订单 | POST /api/v1/order/id | 客人 |
修改订单 | PUT /api/v1/order/id | 用户 |
结帐订单 | POST /api/v1/order/checkout | 用户 |
根据订单id获取订单 | 获取/api/v1/order/id/:id | 用户 |
获取用户所有订单 | 获取/api/v1/order/id/list | 用户 |
更改用户密码 | POST /api/v1/user/changepwd | 用户 |
获取所有订单 | 获取/api/v1/order/list | 行政 |
获取所有用户 | 获取/api/v1/user/list | 行政 |
使用电子邮件和密码注册新用户。如果设置了 SMTP 服务器配置,则将邮件发送到用于注册的电子邮件并包含验证码。
请求示例
curl 'http://localhost:54545/api/v1/user/register'
-H 'Content-Type: application/x-www-form-urlencoded'
-X POST
--data-raw 'email=stripe%40newbeelearn.com&password=test&confirm-password=test&remember=on'
响应示例
{"status":"success"}
使用电子邮件和密码登录用户。如果配置文件中未设置“postlogin”字段,则返回 json,否则重定向到“postlogin”中指定的页面
请求示例
curl 'http://localhost:54545/api/v1/user/login'
-H 'Content-Type: application/x-www-form-urlencoded'
-X POST
--data-raw 'email=admin%40example.com&password=admin'
响应示例
{
"data": {
"user_id": "1",
"username": ""
},
"msg": "user found",
"status": "success"
}
注销已登录的用户并重定向到主页
请求示例
curl 'http://localhost:54545/api/v1/user/logout'
-H 'Cookie: session_id=9e8b22a3-15ac-442f-bf65-15c37dbfc889; max-age=300; path=/; secure; SameSite=Lax'
响应示例
<!doctype html>
<html lang="en">
<head>
</head>
<body>
</body>
</html>
如果设置了域名,则通过发送 url 来验证注册用户的电子邮件;如果未设置域名,则通过在验证 api 后附加代码来验证注册用户的电子邮件
请求示例
curl 'http://localhost:54545/api/v1/user/verify/cafj5grn0gpog1j3a0m0'
响应示例
{"status":"success"}
重置用户密码并发送新的临时登录代码。用户下次登录时需要使用此代码并更改密码
请求示例
curl 'http://localhost:54545/api/v1/user/reset'
-H 'Content-Type: application/x-www-form-urlencoded'
-X POST
--data-raw 'email=stripe%40newbeelearn.com'
响应示例
{
"data": null,
"msg": "password reset successful",
"status": "success"
}
获取网站上列出的所有待售产品。以“limit”和“offset”作为查询。如果未设置查询,则默认限制值设置为 10,偏移量设置为 0
请求示例
curl 'http://localhost:54545/api/v1/product/list?limit=1&offset=0'
响应示例
{
"data": [
{
"prd_id": 1,
"prd_name": "course1",
"sku": "prod-course-1",
"permalink": "users/list/",
"price": 10000,
"currency": "USD",
"period": 365,
"status": "active"
}
],
"msg": "Order found",
"status": "success"
}
使用"line_item"
字段中列出的产品创建新订单。请求应该是有效的 json。实际的order_id/user_id
等字段由服务器填充,任何虚拟值都可以传递。
请求示例
curl 'http://localhost:54545/api/v1/order/id'
-H 'Content-Type: application/json; charset=utf-8'
-H 'Cookie: session_id=cad8439e-dcc4-475e-94fc-12b75f85bb20; max-age=300; path=/; secure; SameSite=Lax'
-X POST
--data-raw ' {
"order_id": 1,
"user_id": 3,
"currency": "USD",
"line_items": [
{
"sku": "prod-course-1"
},
{
"sku": "prod-course-3"
}
]
}'
响应示例
{
"data": {
"order_id": 1,
"user_id": 3,
"created_at": "2022-06-07 11:45:57.601996759 +0000 UTC",
"modified_at": "2022-06-07 11:45:57.601996759 +0000 UTC",
"status": "active",
"currency": "USD",
"order_number": "cafjktbn0gpp5hq3dt4g",
"grand_total": 11000,
"line_items": [
{
"line_id": 1,
"order_id": 1,
"prd_id": 1,
"created_at": "2022-06-07 11:45:57.601996759 +0000 UTC",
"modified_at": "2022-06-07 11:45:57.601996759 +0000 UTC",
"grand": 10000,
"enabled": true,
"sku": "prod-course-1"
},
{
"line_id": 2,
"order_id": 1,
"prd_id": 2,
"created_at": "2022-06-07 11:45:57.601996759 +0000 UTC",
"modified_at": "2022-06-07 11:45:57.601996759 +0000 UTC",
"grand": 1000,
"enabled": true,
"sku": "prod-course-3"
}
]
},
"msg": "Order found",
"status": "success"
}
通过在line_item
字段中添加/删除产品来修改现有订单。用户必须登录才能修改订单,并且订单应处于活动状态。使用之前创建订单或获取订单的响应来添加/删除产品
请求示例
curl 'http://localhost:54545/api/v1/order/id'
-H 'Content-Type: application/json; charset=utf-8'
-H 'Cookie: session_id=cad8439e-dcc4-475e-94fc-12b75f85bb20; max-age=300; path=/; secure; SameSite=Lax'
-X PUT
--data-raw ' {
"order_id": 1,
"user_id": 3,
"created_at": "2022-06-07 11:45:57.601996759 +0000 UTC",
"modified_at": "2022-06-07 11:45:57.601996759 +0000 UTC",
"status": "active",
"currency": "USD",
"order_number": "cafjktbn0gpp5hq3dt4g",
"grand_total": 11000,
"line_items": [
{
"line_id": 2,
"order_id": 1,
"prd_id": 2,
"created_at": "2022-06-07 11:45:57.601996759 +0000 UTC",
"modified_at": "2022-06-07 11:45:57.601996759 +0000 UTC",
"grand": 1000,
"enabled": true,
"sku": "prod-course-3"
}
]
}'
响应示例
{
"data": {
"order_id": 1,
"user_id": 3,
"created_at": "2022-06-07 11:45:57.601996759 +0000 UTC",
"modified_at": "2022-06-07 11:48:05.425488765 +0000 UTC",
"status": "active",
"currency": "USD",
"order_number": "cafjktbn0gpp5hq3dt4g",
"grand_total": 1000,
"line_items": [
{
"line_id": 2,
"order_id": 1,
"prd_id": 2,
"created_at": "2022-06-07 11:45:57.601996759 +0000 UTC",
"modified_at": "2022-06-07 11:48:05.425488765 +0000 UTC",
"grand": 1000,
"enabled": true,
"sku": "prod-course-3"
}
]
},
"msg": "Order found",
"status": "success"
}
获取由create order api创建的订单支付的stripe url。使用创建订单/修改订单/获取订单 api 的响应发送请求。不要修改此请求中的响应,否则会导致失败。
请求示例
curl 'http://localhost:54545/api/v1/order/checkout'
-H 'Content-Type: application/json; charset=utf-8'
-H 'Cookie: session_id=2f1be070-7256-4e84-a4ef-c14754cabcdb; max-age=300; path=/; secure; SameSite=Lax'
-X POST
--data-raw ' {
"order_id": 1,
"user_id": 3,
"created_at": "2022-06-07 11:45:57.601996759 +0000 UTC",
"modified_at": "2022-06-07 11:45:57.601996759 +0000 UTC",
"status": "active",
"currency": "USD",
"order_number": "cafjktbn0gpp5hq3dt4g",
"grand_total": 11000,
"line_items": [
{
"line_id": 2,
"order_id": 1,
"prd_id": 2,
"created_at": "2022-06-07 11:45:57.601996759 +0000 UTC",
"modified_at": "2022-06-07 11:45:57.601996759 +0000 UTC",
"grand": 1000,
"enabled": true,
"sku": "prod-course-3"
}
]
}'
响应示例
{
"data": {
"url": "https://checkout.stripe.com/pay/cs_test_a17D2l74NsKMv29YJ1c5rSBPx7BGSsNAsObGAsOanEJqyFNXKEYDLji4BZ#fidkdWxOYHwnPyd1blpxYHZxWjA0TlVKPHNMaW9vYEd1YmhdUWQ3UUJqSEpMYTMza11ObGAyXDFPcXA8bz1yY1VicVZVdDN8c1NkaUZEazxIQWdjM04wdz1DTmF3PXxHaVE9bTVuZz1pUWw3NTUybHZLZldgaicpJ2N3amhWYHdzYHcnP3F3cGApJ2lkfGpwcVF8dWAnPyd2bGtiaWBabHFgaCcpJ2BrZGdpYFVpZGZgbWppYWB3dic%2FcXdwYHgl"
},
"msg": "Order found",
"status": "success"
}
通过订单号获取订单详情
请求示例
curl 'http://localhost:54545/api/v1/order/id/cafjktbn0gpp5hq3dt4g'
-H 'Content-Type: application/json; charset=utf-8'
-H 'Cookie: session_id=fe9b9fff-c5c0-4745-becf-ecb0e5abca81; max-age=300; path=/; secure; SameSite=Lax'
响应示例
{
"data": {
"order_id": 1,
"user_id": 3,
"created_at": "2022-06-07 11:45:57.601996759 +0000 UTC",
"modified_at": "2022-06-07 11:48:05.425488765 +0000 UTC",
"status": "active",
"currency": "USD",
"order_number": "cafjktbn0gpp5hq3dt4g",
"grand_total": 1000,
"line_items": [
{
"line_id": 2,
"order_id": 1,
"prd_id": 2,
"created_at": "2022-06-07 11:45:57.601996759 +0000 UTC",
"modified_at": "2022-06-07 11:48:05.425488765 +0000 UTC",
"grand": 1000,
"enabled": true
}
]
},
"msg": "Order found",
"status": "success"
}
按用户获取所有订单。以limit和offset作为查询参数默认值分别为10和0
请求示例
curl 'http://localhost:54545/api/v1/order/id/list?limit=1&offset=0'
-H 'Content-Type: application/json; charset=utf-8'
-H 'Cookie: session_id=fe9b9fff-c5c0-4745-becf-ecb0e5abca81; max-age=300; path=/; secure; SameSite=Lax'
响应示例
{
"data": [
{
"order_id": 1,
"user_id": 3,
"created_at": "2022-06-07 11:45:57.601996759 +0000 UTC",
"modified_at": "2022-06-07 11:48:05.425488765 +0000 UTC",
"status": "active",
"currency": "USD",
"order_number": "cafjktbn0gpp5hq3dt4g",
"grand_total": 1000
}
],
"msg": "Order found",
"status": "success"
}
更改用户密码。用户必须登录才能提出此请求
请求示例
curl 'http://localhost:54545/api/v1/user/changepwd'
-H 'Content-Type: application/x-www-form-urlencoded'
-H 'Cookie: session_id=fe9b9fff-c5c0-4745-becf-ecb0e5abca81; max-age=300; path=/; secure; SameSite=Lax'
-X POST
--data-raw 'oldpassword=cafjjjbn0gpp5hq3dt40&password=test123'
响应示例
{
"data": null,
"msg": "password change successful",
"status": "success"
}
获取商店中创建的所有订单。以 limit 和 offset 作为查询参数,默认值分别为 10 和 0 仅适用于管理员用户。获取所有订单
请求示例
curl 'http://localhost:54545/api/v1/order/list?limit=1&offset=0'
-H 'Content-Type: application/json; charset=utf-8'
-H 'Cookie: session_id=e4ecd3a4-b8be-493e-a33d-518ab11c65e8; max-age=300; path=/; secure; SameSite=Lax'
响应示例
{
"data": [
{
"order_id": 1,
"user_id": 3,
"created_at": "2022-06-07 11:45:57.601996759 +0000 UTC",
"modified_at": "2022-06-07 11:48:05.425488765 +0000 UTC",
"status": "active",
"currency": "USD",
"order_number": "cafjktbn0gpp5hq3dt4g",
"price_total": 1000,
"discount_total": 0,
"sub_total": 1000,
"taxes_total": 0,
"grand_total": 1000,
"refunds_total": 0,
"created_channel": "",
"payment_provider": ""
}
],
"msg": "Order found",
"status": "success"
}
让所有用户在网站上注册。以 limit 和 offset 作为查询参数,默认值分别为 10 和 0 仅适用于管理员用户。
请求示例
curl 'http://localhost:54545/api/v1/user/list?limit=1&offset=0'
-H 'Content-Type: application/json; charset=utf-8'
-H 'Cookie: session_id=e4ecd3a4-b8be-493e-a33d-518ab11c65e8; max-age=300; path=/; secure; SameSite=Lax'
响应示例
{
"data": [
{
"user_id": 1,
"email": "[email protected]",
"created_at": "2022-06-07 10:53:00.480128762 +0000 UTC",
"username": "",
"last_password_set": "2022-06-07 10:53:00.480128762 +0000 UTC",
"last_login": "2022-06-07 10:53:00.480128762 +0000 UTC",
"verified": 0,
"reset": 0,
"user_role": "admin"
},
{
"user_id": 2,
"email": "[email protected]",
"created_at": "2022-06-07 10:53:00.532691788 +0000 UTC",
"username": "",
"last_password_set": "2022-06-07 10:53:00.532691788 +0000 UTC",
"last_login": "2022-06-07 10:53:00.532691788 +0000 UTC",
"verified": 0,
"reset": 0,
"user_role": "guest"
},
{
"user_id": 3,
"email": "[email protected]",
"created_at": "2022-06-07 11:13:06.947313364 +0000 UTC",
"username": "",
"last_password_set": "2022-06-07 11:13:06.947313364 +0000 UTC",
"last_login": "2022-06-07 11:13:06.947313364 +0000 UTC",
"verified": 2,
"reset": 1,
"user_role": "user"
}
],
"msg": "Order found",
"status": "success"
}
不,仅发布二进制文件,并且网站用于围绕产品进行讨论。
它处于 alpha 阶段,功能已完成,但可能包含错误
这是因为需要举办课程而创建的
现在不行,因为不支持订阅,它仅适用于一次性数字产品。它也没有可以插入您自己的 SaaS 的路由转发功能。但是,如果有足够的兴趣,可以添加这些更改,如果您想拥有这些功能,请开始讨论,但目前它还没有出现在路线图上。
它可用于托管课程和相关博客。带有时事通讯的博客。具有优质内容的博客。启动和相关博客的登陆页面。销售主题等
开箱即用地支持 linux 和 macos。 Windows 用户可以使用 WSL,但尚未经过测试。
创建问题并用功能标记它
目前尚未决定是否可以免费使用。付费产品(如果有)将使用单独的渠道。因此,如果您从 github 版本下载,它是永久免费的。帮助我们做出决定,在讨论区告诉我们您愿意为此支付多少钱。