create-fff-app 0.1.10 → 0.1.12
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/index.ts +9 -12
- package/template/dev-server.ts +98 -341
- package/template/migrations/0001_init.sql +7 -23
- package/template/package.json +12 -13
- package/template/schema.sql +9 -25
- package/template/src/client/Client.fsproj +1 -1
- package/template/src/server/Server.fsproj +0 -12
- package/template/src/server/Worker.fs +2 -32
- package/template/wrangler.toml +13 -15
- package/template/migrations/0002_employees.sql +0 -16
- package/template/src/server/Domain/Employees/Employee.fs +0 -34
- package/template/src/server/Endpoints/Employees/Routes.fs +0 -35
- package/template/src/server/Endpoints/Pages/About.fjsx +0 -66
- package/template/src/server/Endpoints/Pages/EmployeeEdit.fjsx +0 -66
- package/template/src/server/Endpoints/Pages/EmployeeList.fjsx +0 -54
- package/template/src/server/Endpoints/Pages/EmployeeNew.fjsx +0 -55
- package/template/src/server/Endpoints/Pages/Layout.fjsx +0 -40
- package/template/src/server/Endpoints/Pages/Routes.fs +0 -118
- package/template/src/server/Endpoints/Pages/Templates.fs +0 -44
- package/template/src/server/Workflows/Employees/EmployeeWorkflows.fs +0 -86
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
module App.Server.Endpoints.Pages.Templates
|
|
2
|
-
|
|
3
|
-
open Fable.Core
|
|
4
|
-
open Fable.Core.JsInterop
|
|
5
|
-
|
|
6
|
-
// ── Compiled FJSX page template modules ──────────────────────────────────────
|
|
7
|
-
// Paths are relative to THIS source file so Fable generates correct dist-relative
|
|
8
|
-
// imports. FJSX output goes to dist/server/Pages/ (4 dirs up from here, then dist/).
|
|
9
|
-
// Run: fjsx --dir src/server/Endpoints/Pages --out dist/server/Pages
|
|
10
|
-
|
|
11
|
-
[<ImportAll("../../../../dist/server/Pages/Layout.js")>]
|
|
12
|
-
let private layoutMod : obj = jsNative
|
|
13
|
-
|
|
14
|
-
[<ImportAll("../../../../dist/server/Pages/EmployeeList.js")>]
|
|
15
|
-
let private employeeListMod : obj = jsNative
|
|
16
|
-
|
|
17
|
-
[<ImportAll("../../../../dist/server/Pages/EmployeeNew.js")>]
|
|
18
|
-
let private employeeNewMod : obj = jsNative
|
|
19
|
-
|
|
20
|
-
[<ImportAll("../../../../dist/server/Pages/About.js")>]
|
|
21
|
-
let private aboutMod : obj = jsNative
|
|
22
|
-
|
|
23
|
-
[<ImportAll("../../../../dist/server/Pages/EmployeeEdit.js")>]
|
|
24
|
-
let private employeeEditMod : obj = jsNative
|
|
25
|
-
// ── Render helpers ────────────────────────────────────────────────────────────
|
|
26
|
-
|
|
27
|
-
let renderLayout (data: obj) : string = layoutMod?renderToHtml $ data
|
|
28
|
-
let renderEmployeeList (data: obj) : string = employeeListMod?renderToHtml $ data
|
|
29
|
-
let renderEmployeeNew (data: obj) : string = employeeNewMod?renderToHtml $ data
|
|
30
|
-
let renderAbout () : string = aboutMod?renderToHtml $ (createObj [])
|
|
31
|
-
|
|
32
|
-
let renderEmployeeEdit (data: obj) : string = employeeEditMod?renderToHtml $ data
|
|
33
|
-
|
|
34
|
-
/// Full-page HTML shell.
|
|
35
|
-
/// title — page title shown in <title> tag
|
|
36
|
-
/// activePath — used to highlight the active nav link
|
|
37
|
-
/// body — raw HTML injected into <main>
|
|
38
|
-
let shell (title: string) (activePath: string) (body: string) : string =
|
|
39
|
-
renderLayout (createObj [
|
|
40
|
-
"title" ==> title
|
|
41
|
-
"homeActive" ==> (activePath = "/")
|
|
42
|
-
"aboutActive" ==> (activePath = "/about")
|
|
43
|
-
"body" ==> body
|
|
44
|
-
])
|
|
@@ -1,86 +0,0 @@
|
|
|
1
|
-
module App.Server.Workflows.Employees
|
|
2
|
-
|
|
3
|
-
open FffStack.Server
|
|
4
|
-
open Fable.Core
|
|
5
|
-
open Fable.Core.JsInterop
|
|
6
|
-
open App.Server.Domain.Employees
|
|
7
|
-
|
|
8
|
-
[<Emit("crypto.randomUUID()")>]
|
|
9
|
-
let private newId () : string = jsNative
|
|
10
|
-
|
|
11
|
-
let getAll (db: ID1Database) : JS.Promise<Employee list> =
|
|
12
|
-
queryAll<Employee> db
|
|
13
|
-
"SELECT id, name, email, department, role, status, joined_at as joinedAt \
|
|
14
|
-
FROM employees ORDER BY name ASC"
|
|
15
|
-
[||]
|
|
16
|
-
|
|
17
|
-
let getById (db: ID1Database) (id: string) : JS.Promise<Employee option> =
|
|
18
|
-
queryOne<Employee> db
|
|
19
|
-
"SELECT id, name, email, department, role, status, joined_at as joinedAt \
|
|
20
|
-
FROM employees WHERE id = ?"
|
|
21
|
-
[| id |]
|
|
22
|
-
|
|
23
|
-
let create
|
|
24
|
-
(db: ID1Database)
|
|
25
|
-
(rawName: string)
|
|
26
|
-
(rawEmail: string)
|
|
27
|
-
(department: string)
|
|
28
|
-
(role: string)
|
|
29
|
-
(status: string)
|
|
30
|
-
: JS.Promise<Result<Employee, string>> =
|
|
31
|
-
promise {
|
|
32
|
-
match EmployeeName.create rawName, WorkEmail.create rawEmail with
|
|
33
|
-
| Error e, _ -> return Error e
|
|
34
|
-
| _, Error e -> return Error e
|
|
35
|
-
| Ok name, Ok email ->
|
|
36
|
-
let id = newId ()
|
|
37
|
-
let n = EmployeeName.value name
|
|
38
|
-
let em = WorkEmail.value email
|
|
39
|
-
let dep = department.Trim()
|
|
40
|
-
let rol = role.Trim()
|
|
41
|
-
let st = if status = "inactive" then "inactive" else "active"
|
|
42
|
-
do! execute db
|
|
43
|
-
"INSERT INTO employees (id, name, email, department, role, status, joined_at) \
|
|
44
|
-
VALUES (?, ?, ?, ?, ?, ?, date('now'))"
|
|
45
|
-
[| id; n; em; dep; rol; st |]
|
|
46
|
-
|> Promise.map ignore
|
|
47
|
-
return Ok { id = id; name = n; email = em; department = dep
|
|
48
|
-
role = rol; status = st; joinedAt = "" }
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
let update
|
|
52
|
-
(db: ID1Database)
|
|
53
|
-
(id: string)
|
|
54
|
-
(rawName: string)
|
|
55
|
-
(rawEmail: string)
|
|
56
|
-
(department: string)
|
|
57
|
-
(role: string)
|
|
58
|
-
(status: string)
|
|
59
|
-
: JS.Promise<Result<Employee, string>> =
|
|
60
|
-
promise {
|
|
61
|
-
match EmployeeName.create rawName, WorkEmail.create rawEmail with
|
|
62
|
-
| Error e, _ -> return Error e
|
|
63
|
-
| _, Error e -> return Error e
|
|
64
|
-
| Ok name, Ok email ->
|
|
65
|
-
let n = EmployeeName.value name
|
|
66
|
-
let em = WorkEmail.value email
|
|
67
|
-
let dep = department.Trim()
|
|
68
|
-
let rol = role.Trim()
|
|
69
|
-
let st = if status = "inactive" then "inactive" else "active"
|
|
70
|
-
do! execute db
|
|
71
|
-
"UPDATE employees SET name = ?, email = ?, department = ?, role = ?, status = ? WHERE id = ?"
|
|
72
|
-
[| n; em; dep; rol; st; id |]
|
|
73
|
-
|> Promise.map ignore
|
|
74
|
-
return Ok { id = id; name = n; email = em; department = dep
|
|
75
|
-
role = rol; status = st; joinedAt = "" }
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
let delete (db: ID1Database) (id: string) : JS.Promise<bool> =
|
|
79
|
-
promise {
|
|
80
|
-
match! getById db id with
|
|
81
|
-
| None -> return false
|
|
82
|
-
| Some _ ->
|
|
83
|
-
do! execute db "DELETE FROM employees WHERE id = ?" [| id |]
|
|
84
|
-
|> Promise.map ignore
|
|
85
|
-
return true
|
|
86
|
-
}
|