All annotations assumes class methods as decorated sources.
@Query([cypher statement], asTable=False)
| import React, { createContext } from 'react'; | |
| const UserContext = createContext(); | |
| export default class UserProvider extends React.Component { | |
| constructor(props) { | |
| super(props); | |
| this.state = { | |
| user: {}, |
| function log(target: any, property: string, descriptor: PropertyDescriptor) { | |
| let method = descriptor.value; | |
| descriptor.value = function() { | |
| console.warn(`[RUNNING]: ${property}`); | |
| method.apply(this, arguments); | |
| } | |
| } | |
| class Handlers { | |
| @log |
| (defn request-auth | |
| "Finds the user by the header token parameter and pass it to the next chain filter/controller as the :user request parameter" | |
| [req & chain] | |
| (let [token (get-in req [:headers "x-auth-token"])] | |
| (if (nil? token) | |
| {:status 401} | |
| (let [user (user/find-by-token (:tx req) token)] | |
| (if (nil? user) | |
| {:status 403} | |
| (let [new-req (assoc req :user (assoc (:user user) :id (:id user)))] |