summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGrant Shoshin Shangreaux <shoshin@cicadas.surf>2023-01-07 09:39:46 -0600
committerGrant Shoshin Shangreaux <shoshin@cicadas.surf>2023-01-07 09:39:46 -0600
commit9a040d4e78ab07eb9c482a40042f2ba92d2a8e3b (patch)
tree5286e5283238995a1500a2a5bc71cbd24255bc46
parentee7919667832660ef05939823af5516eb9344e16 (diff)
Revert "Add: serialization for Heroes and dnd.api package"
This reverts commit 72bcf7e66269af588d9daa9064de23d257cbd053.
-rw-r--r--api.lisp16
-rw-r--r--init.lisp12
-rw-r--r--model.lisp6
-rw-r--r--package.lisp14
-rw-r--r--routes.lisp12
-rw-r--r--serialization.lisp25
-rw-r--r--utilities.lisp2
7 files changed, 37 insertions, 50 deletions
diff --git a/api.lisp b/api.lisp
index ca60f21..cecacb4 100644
--- a/api.lisp
+++ b/api.lisp
@@ -1,8 +1,8 @@
;;;; api.lisp -- http routes for dnd
-(in-package :dnd.api)
+(in-package :dnd)
-(lzb:provision-app ()
+(lzb:provision-app (api)
:title "Dungeons & Deadlines"
:version "0.1.0"
:prefix "/api"
@@ -13,11 +13,13 @@
(declare (ignore ignore))
t)
-(defendpoint api :get "/heroes" ()
+
+
+(defendpoint* :get "/hall-of-legends" ((filter-by identity))
(:auth t)
"Get a list of heros sorted by renown"
(json:to-json
- (list :|heroes|
- (sort (copy-seq (db:store-objects-with-class 'hero))
- #'>
- :key #'renown))))
+ (list :heroes
+ (sort (copy-seq (db:store-objects-with-class 'hero))
+ #'>
+ :key #'renown))))
diff --git a/init.lisp b/init.lisp
index c3382aa..535da6c 100644
--- a/init.lisp
+++ b/init.lisp
@@ -1,6 +1,6 @@
;;;; init.lisp
-(in-package #:dnd.api)
+(in-package #:dnd)
(defun init-db (&optional config)
(if config
@@ -9,13 +9,3 @@
'db:mp-store
:directory (merge-pathnames "dnd-store/" (user-homedir-pathname))
:subsystems (list (make-instance 'db:store-object-subsystem)))))
-
-(defvar *dnd-arena* nil
- "The instance of the HTTP server.")
-
-(defun conjure-arena ()
- (setf *dnd-arena* (lzb:create-server))
- (lzb:install-app *dnd-arena* 'api)
- (lzb:start-server *dnd-arena*))
-
-
diff --git a/model.lisp b/model.lisp
index 050bbfe..8605ace 100644
--- a/model.lisp
+++ b/model.lisp
@@ -1,6 +1,8 @@
;;;; model.lisp -- bknr.datastore class definitions for dnd
-(in-package :dnd.api)
+
+
+(in-package :dnd)
(deftype title ()
`(member :noob))
@@ -18,7 +20,7 @@
(experience hero))
(defclass has-uid ()
- ((uid :reader uid :initform (nuid)))
+ ((nuid :reader uid :initform (nuid)))
(:metaclass db:persistent-class))
(defclass can-equip ()
diff --git a/package.lisp b/package.lisp
index ff06a36..2c7bff8 100644
--- a/package.lisp
+++ b/package.lisp
@@ -8,20 +8,8 @@
(#:re #:cl-ppcre)
(#:json #:jonathan))
(:import-from #:lazybones
- #:defendpoint
#:defendpoint*)
(:import-from #:derrida
#:with-plist))
-(defpackage #:dnd.api
- (:use #:cl)
- (:local-nicknames (#:db #:bknr.datastore)
- (#:idx #:bknr.indices)
- (#:lzb #:lazybones)
- (#:re #:cl-ppcre)
- (#:json #:jonathan))
- (:import-from #:lazybones
- #:defendpoint
- #:defendpoint*)
- (:import-from #:derrida
- #:with-plist))
+
diff --git a/routes.lisp b/routes.lisp
new file mode 100644
index 0000000..56b6191
--- /dev/null
+++ b/routes.lisp
@@ -0,0 +1,12 @@
+;;;; routes.lisp -- http routes for dnd
+
+(in-package :dnd)
+
+(lzb:provision-app (api)
+ :title "Dungeons & Deadlines"
+ :version "0.1.0"
+ :prefix "/api"
+ :content-type "application/json")
+
+
+
diff --git a/serialization.lisp b/serialization.lisp
index d1689c1..6579b92 100644
--- a/serialization.lisp
+++ b/serialization.lisp
@@ -1,20 +1,13 @@
;;;; serialization.lisp
-(in-package :dnd.api)
-(defmacro with-json-object (&body pairs)
- (list*
- 'json:with-object
- (loop for (key val . more) on pairs by #'cddr
- collect `(json:write-key-value ,key ,val))))
-(defmethod json:%to-json ((hero hero))
- (with-slots (name experience chronicle uid equipment-table) hero
- (with-json-object
- :|name| name
- :|experience| experience
- :|chronicle| chronicle
- :|uid| uid
- :|renown| (renown hero)
- :|title| (hero-title hero)
- :|class| (hero-class hero))))
+(in-package :dnd)
+
+(defun hall-of-fame-hero-view (hero)
+ (json:to-json
+ (list :name (hero-name hero)
+ :uid (uid hero)
+ :renown (renown hero)
+ :title (hero-title hero)
+ :class (hero-class hero))))
diff --git a/utilities.lisp b/utilities.lisp
index 987ddce..b6cf16a 100644
--- a/utilities.lisp
+++ b/utilities.lisp
@@ -1,6 +1,6 @@
;;;; utilities -- nuff said
-(in-package :dnd.api)
+(in-package :dnd)
(let ((host (uiop:hostname))