Skip to content
Modern webserver in Haskell: Graphql + Postgresql + Authentication + DB migration + Dotenv and more
Haskell PLpgSQL
Branch: master
Clone or download
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
app
db Updates. Jan 12, 2020
src
.env.default
.gitignore
.hindent.yaml
ChangeLog.md Add generic EntityT for inserted at and updated at Jan 12, 2020
README.md
package.yaml Update README, package.yaml Jan 8, 2020
schema.graphql Done refactor Jan 12, 2020
stack.yaml Update morpheus-graphql Jan 7, 2020
stack.yaml.lock Update morpheus-graphql Jan 7, 2020

README.md

Modern Haskell Webserver Boilerplate

  • Graphql API
      type User {
          id: Int!
          email: String!
          name: String!
          updatedAt: String!
          createdAt: String!
      }
    
      type Session {
          token: String!
          user: User!
      }
    
      type Query {
          login(email: String!, password: String!): Session!
          myUserInfo: User!
      }
    
      type Mutation {
          register(email: String!, password: String!, name: String!): Session!
          changePassword(oldPassword: String!, newPassword: String!): Boolean!
      }
  • Database:

This boilerplate wires up:

  • Reading .env using envy
  • Database
  • Graphql API
    • login(email: String, password: String) { token user { id } }
    • register(email: String, password: String, name: String) { token user { id } }
  • Authorization using JWT
  • Monad transformers

Running

  • Feed in you database & secret in .env:
    $ cp .env.default .env
    
    DATABASE_URL="postgres://Dandoh:dandoh@127.0.0.1:5432/webhaskell?sslmode=disable"
    JWT_SECRET="my_jwt_secret"
    
  • Migrations
    $ dbmate up
    
  • Run webserver
    $ stack run
    
You can’t perform that action at this time.