A project build on clojure ecosystem. The aim is to compose different libraries to build a single page app backend template.
- Json request/response (with pedestal json-response)
- Authentication (with buddy-auth)
- Authorization
- Password hashing
- DB access
- Data migration
- Dev/prod profile
- Schema everything
- Logging
- Redux setup
- Assets compressing
- Start webpack
cd js
npm install
webpack --progress --colors --watch
- Start the application:
lein run-dev
- Go to localhost:8080 to see:
Hello World!
- Go to localhost:8080/index.html#/login to see login screen
- Endpoint without authentication
curl -X GET -H 'Content-Type: application/json" }' http://localhost:8080/about
returns:
{"message":"pedestal-rest: a single page app backend."}
-
Endpoint to login /login
curl -X POST -H 'Content-Type: application/json" }' -d '{"username": "[email protected]", "password": "1234"}' http://localhost:8080/login
returns
```json
{"status":200,"body":{"token": <encryped jwe token>}}
-
Endpoint protected by authentication
curl -X GET -H 'Content-Type: application/json" }' -H 'Authorization: Token ' http://localhost:8080/user/1/info
returns
```json
{
"id": 1,
"id": 1,
"first_name": "david",
"last_name": "hudson",
"email": "[email protected]",
"pass": "1234"
}
curl -X GET -H 'Content-Type: application/json" }' -H 'Authorization: Token <token from step.4>' http://localhost:8080/user/2/info
returns
{
"status": 401,
"body": {
"message": "Unauthorized resource access"
}
}
- I installed node with nvm, you will need to add "./node_modules/.bin" to path