-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Set up project #4
base: master
Are you sure you want to change the base?
Conversation
|
||
To start and stop server for development use `(mount/start)` and `(mount/stop)` respectively. Mount will setup the state including config and db datastore | ||
|
||
Carry out a health check at `\api\ping` . A pong will be returned if everything is healthy |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Carry out a health check at `\api\ping` . A pong will be returned if everything is healthy | |
Carry out a health check at `/api/ping`. A pong will be returned if everything is healthy |
@@ -0,0 +1,21 @@ | |||
(defproject practitioner "0.1.0-SNAPSHOT" | |||
:description "FIXME: write description" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could add a small description
(defn -main | ||
[] | ||
(mount/start) | ||
(migrations/migrate) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you need your migration to run every time you start your application?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You're right, I don't need to. Will use practitioner.migrations/migrate-with-command
to make it optional when starting. Migrating each time I start the application might cost time.
(:require | ||
[aero.core :as aero] | ||
[clojure.java.io :as io] | ||
[mount.core :refer [defstate]])) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Have you used mount
before? Was there a need to use mount
in practitioner?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have not used mount before. Used mount in practitioner to allow the state to be reloaded in the REPL and I don't have to restart the REPL.
(when (try | ||
(jdbc/execute! ds/datasource ["select now()"]) | ||
(catch Exception e | ||
(res/response (.getMessage e)))) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Exceptions are usually very verbose, they may provide valuable information to someone debugging an error. However, they may leak information about the system. In this case, when there is an issue with the database, it will leak unnecessary information to the user. This is both a security risk and a bad interface for a user.
You could
- Log the error to be debugged later
- Respond with a more meaningful error message to the user
- Add HTTP status codes to your responses. Ref: https://developer.mozilla.org/en-US/docs/Web/HTTP/Status
There is more to error handling, but you can start from here
(ns practitioner.models.user) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you need this file, if there is nothing in it?
# Introduction to practitioner | ||
|
||
TODO: write [great documentation](http://jacobian.org/writing/what-to-write/) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe delete this file if this is not necessary?
(testing "Returns pong when healthy" | ||
(is (= (health-check (mock/request :get "/api/ping")) | ||
{:status 200 | ||
:headers {} | ||
:body "pong"})))) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(testing "Returns pong when healthy" | |
(is (= (health-check (mock/request :get "/api/ping")) | |
{:status 200 | |
:headers {} | |
:body "pong"})))) | |
(testing "Returns pong when healthy" | |
(is (= (health-check (mock/request :get "/api/ping")) | |
{:status 200 | |
:headers {} | |
:body "pong"}))) | |
(testing "Returns error when healthy" | |
(is (= (health-check (mock/request :get "/api/ping")) | |
{:status 500 | |
:headers {} | |
:body "Server down"})))) |
This solves #1