GithubHelp home page GithubHelp logo

pedestal-rest's Introduction

pedestal-rest

A project build on clojure ecosystem. The aim is to compose different libraries to build a single page app backend template.

To DO

  • 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

Getting Started

  1. Start webpack
cd js
npm install
webpack --progress --colors --watch
  1. Start the application: lein run-dev
  2. Go to localhost:8080 to see: Hello World!
  3. Go to localhost:8080/index.html#/login to see login screen
  4. Endpoint without authentication
curl -X GET -H 'Content-Type: application/json" }' http://localhost:8080/about

returns:

{"message":"pedestal-rest: a single page app backend."}
  1. 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>}}
  1. 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"
 }
}

NOTES:

  • I installed node with nvm, you will need to add "./node_modules/.bin" to path

pedestal-rest's People

Contributors

ruiyang avatar

Watchers

 avatar  avatar

Forkers

villadiegofj

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.