Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/jim108dev/purescript-payload-realworld-example
Exemplary real world application built with PureScript + Payload + PostgreSQL
https://github.com/jim108dev/purescript-payload-realworld-example
jwt postgresql purescript purescript-payload purescript-selda realworld-backend
Last synced: about 1 month ago
JSON representation
Exemplary real world application built with PureScript + Payload + PostgreSQL
- Host: GitHub
- URL: https://github.com/jim108dev/purescript-payload-realworld-example
- Owner: jim108dev
- License: mit
- Created: 2021-02-01T09:24:46.000Z (almost 4 years ago)
- Default Branch: main
- Last Pushed: 2021-06-08T08:23:02.000Z (over 3 years ago)
- Last Synced: 2024-08-02T13:34:02.632Z (5 months ago)
- Topics: jwt, postgresql, purescript, purescript-payload, purescript-selda, realworld-backend
- Language: PureScript
- Homepage:
- Size: 3.68 MB
- Stars: 21
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# PureScript Payload RealWorld Example
This is a learning project in order to set up a REST API with [PureScript Payload](https://github.com/hoodunit/purescript-payload) and [PostgreSQL](https://www.postgresql.org). The specification follows
- [RealWorld API Spec](https://github.com/gothinkster/realworld/tree/master/api)
## Install
1. Install [PureScript](https://www.purescript.org/).
1. Install repository 's software:
1. Run:
```sh
# This repo
git clone https://github.com/jim108dev/purescript-payload-realworld-example.git
cd purescript-payload-realworld-example
npm install pg decimal.js xhr2 jsonwebtoken
spago install
spago build
```### Development/Test Mode
Please choose if you want to run the server in development/test (Dev) mode or in production mode (Prod). *Dev* operates with fixed timestamps which is required for the automated tests to run. *Prod* operates with the current system time.
1. Database Setup:
1. Install PostgreSQL.
1. `sql/CreateDB.sql`: Execute commands which set up a database called `conduit`.
1. `config/Server/{Dev|Prod}.json`: Change config files according to your db setup.
1. `sql/Functions.sql`: Execute commands which set up functions/triggers for *Prod*.
1. `sql/ResetTables.sql`: Activate the current timestamps by uncommenting `-- TIMESTAMP` for *Prod*. This file can be executed with:```sh
spago run -m Test.ResetTables
```1. Jwt: `config/Server/Prod.json`: Change the token's secret key for *Prod*.
1. Server: `src/Server/Main.purs`: Set the configuration file accordingly.
1. Optional: Install [HTTPie](https://httpie.io) and [httpie-jwt-auth](https://github.com/teracyhq/httpie-jwt-auth) for testing via command line.
1. Optional: Install a frontend like [Real World Halogen]().
## Usage
1. Run the server:
```sh
spago run
```1. [API-SPEC.md](./API-SPEC.md) lists HTTPie test calls to every request.
1. Run a frontend.
## Development
1. Run the unit tests
```sh
spago run -m Test.Main
```[APPROACH.md](./APPROACH.md) contains some comments about the decisions which were made.