e468639d9f413fac8c862fc85beb3840b8468796 — William Vaughn 2 months ago 695bfe0 main
make created_at with time zone in db, mock in fake API with instant
M resources/migrations/20220211035117-grsroot-auth.up.sql => resources/migrations/20220211035117-grsroot-auth.up.sql +2 -2
@@ 2,7 2,7 @@ create table app_user (
  app_user_id uuid primary key default gen_random_uuid(),
  email       character varying(320) unique not null,
  password    text not null,
  created_at  timestamp not null default now()
  created_at  timestamp with time zone not null default now()
create table app (

@@ 27,7 27,7 @@ create table app_user_role (
create table refresh_token (
  refresh_token_id bigserial primary key,
  app_user_id      uuid not null references app_user(app_user_id),
  issued_at        timestamp not null,
  issued_at        timestamp with time zone not null,
  token            text not null,
  is_valid         boolean not null

M src/clj/grsroot_auth/routes/services.clj => src/clj/grsroot_auth/routes/services.clj +17 -11
@@ 1,5 1,7 @@
(ns grsroot-auth.routes.services
   [clojure.java.io :as io]
   [java-time :refer [instant]]
   [reitit.swagger :as swagger]
   [reitit.swagger-ui :as swagger-ui]
   [reitit.ring.coercion :as coercion]

@@ 12,8 14,7 @@
   [grsroot-auth.middleware :as middleware]
   [grsroot-auth.middleware.formats :as formats]
   [grsroot-auth.service :as svc]
   [ring.util.http-response :refer :all]
   [clojure.java.io :as io]))
   [ring.util.http-response :refer [ok created conflict not-found]]))

(defn service-routes []

@@ 100,24 101,31 @@
    ["" {:get {:id ::list-app-users
               :summary "List app users"
               :responses {200 {:body
                                {:app-users [{:app-user_id uuid?
                                              :email string?}]}}}
                                {:app-users [{:app-user-id uuid?
                                              :email string?
                                              :created-at inst?}]}}}
               :handler (fn [_]
                          (ok {:app-users []}))}
                          (ok {:app-users [{:app-user-id (java.util.UUID/randomUUID)
                                            :email "vaughnwilld@gmail.com"
                                            :created-at (instant)}]}))}
         :post {:id ::create-app-user
                :summary "Create/register a new app user"
                :responses {201 {:body {:app-user-id uuid?
                                        :email string?}}}
                                        :email string?
                                        :created-at inst?}}}
                :handler (fn [_]
                           (created "/api/app-users/1" {:app-user-id (java.util.UUID/randomUUID)
                                                        :email "vaughnwilld@gmail.com"}))}
                                                        :email "vaughnwilld@gmail.com"
                                                        :created-at (instant)}))}
         :put {:id ::put-app-user
               :summary "Update app user"
               :responses {200 {:body {:app-user-id uuid?
                                       :email string?}}}
                                       :email string?
                                       :created-at inst?}}}
               :handler (fn [_]
                          (ok {:app-user-id (java.util.UUID/randomUUID)
                               :email "vaughnwilld@gmail.com"}))}}]]
                               :email "vaughnwilld@gmail.com"
                               :created-at (instant)}))}}]]

    {:swagger {:tags ["apps"]}}

@@ 139,8 147,6 @@
                            403 {:body {:message string?}}
                            409 {:body {:message string?}}}
                :handler (fn [{{{:keys [app-slug]} :body} :parameters :as request}]
                           (prn (keys request))
                           (prn (:identity request))
                             (let [{:keys [app-id]} (svc/create-app! app-slug)]
                               (created (format "/api/apps/%s" app-id) {:app-id app-id  :app-slug app-slug}))