Skip to content

Commit

Permalink
Removed built-in logging middleware
Browse files Browse the repository at this point in the history
  • Loading branch information
madvas committed Mar 5, 2018
1 parent a84fdd2 commit 2d47003
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 45 deletions.
15 changes: 5 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
Clojurescript-node.js [mount](https://github.com/tolitius/mount) module for a district server, that takes care of HTTP server and its endpoints. This module currently utilises [expressjs](https://expressjs.com/) as an underlying HTTP server.

## Installation
Add `[district0x/district-server-endpoints "1.0.2"]` into your project.clj
Add `[district0x/district-server-endpoints "1.0.3"]` into your project.clj
Include `[district.server.endpoints]` in your CLJS file, where you use `mount/start`

## API Overview
Expand All @@ -24,7 +24,6 @@ Include `[district.server.endpoints]` in your CLJS file, where you use `mount/st
- [reg-delete!](#reg-delete!)
- [reg-endpoint!](#reg-endpoint!)
- [district.server.endpoints.middleware.defaults](#districtserverendpointsmiddlewaredefaults)
- [district.server.endpoints.middleware.logging](#districtserverendpointsmiddlewarelogging)

## Real-world example
To see how district server modules play together in real-world app, you can take a look at [NameBazaar server folder](https://github.com/district0x/name-bazaar/tree/master/src/name_bazaar/server),
Expand All @@ -33,15 +32,15 @@ where this is deployed in production.
## Usage
You can pass following args to endpoints module:
* `:port` Port at which HTTP server will start
* `:middlewares` Collection of expressjs [middlewares](http://expressjs.com/en/guide/using-middleware.html) you want to install
* `:middlewares` Collection of expressjs [middlewares](http://expressjs.com/en/guide/using-middleware.html) you want to install.
See list of [district-server-middlewares](https://github.com/search?q=topic%3Adistrict-server-middleware+org%3Adistrict0x&type=Repositories).
* `:default-middlewares` This module comes with few default middlewares. Each has an unique keyword key. If you want to use only some of default ones, you can pass collection of their keys here.


```clojure
(ns my-district
(:require [mount.core :as mount]
[district.server.endpoints :refer [reg-get! send query-params]]
[district.server.endpoints.middleware.logging :refer [logging-middlewares]]))
[district.server.endpoints :refer [reg-get! send query-params]]))

(reg-get! "/my-endpoint"
(fn [req res]
Expand All @@ -50,8 +49,7 @@ You can pass following args to endpoints module:
(send res 400 "Bad Request"))))

(-> (mount/with-args
{:endpoints {:port 6200
:middlewares [logging-middlewares]}})
{:endpoints {:port 6200}})
(mount/start))
```
You need to define your endpoints with `reg-get!`, `reg-post!`, etc. before you start mount. Endpoint definitions can be of course in different file and you just require it in main file.
Expand Down Expand Up @@ -107,9 +105,6 @@ Default middlewares that comes with endpoints module are defined here. If you wa
* `:middleware/transit-body-parser` parses transit body
* `:middleware/query-params-parser` parses query params

## district.server.endpoints.middleware.logging
Middleware that logs server requests and errors comes with this package, but it's not included in default middleware because it uses [timbre](https://github.com/ptaoussanis/timbre) for logging, which might not be good for everyone. If you do so, best way to set it up is via [district-server-logging](https://github.com/district0x/district-server-logging) mount module.

## Development
```bash
# To start REPL and run tests
Expand Down
3 changes: 1 addition & 2 deletions project.clj
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
(defproject district0x/district-server-endpoints "1.0.2"
(defproject district0x/district-server-endpoints "1.0.3"
:description "district0x server component for setting up API endpoints"
:url "https://github.com/district0x/district-server-endpoints"
:license {:name "Eclipse Public License"
:url "http://www.eclipse.org/legal/epl-v10.html"}
:dependencies [[com.cognitect/transit-cljs "0.8.243"]
[com.taoensso/timbre "4.10.0"]
[district0x/district-server-config "1.0.1"]
[mount "0.1.11"]
[org.clojure/clojurescript "1.9.946"]]
Expand Down
33 changes: 0 additions & 33 deletions src/district/server/endpoints/middleware/logging.cljs

This file was deleted.

0 comments on commit 2d47003

Please sign in to comment.