This is a learning project in order to set up a REST API with PureScript Payload and PostgreSQL. The specification follows
-
Install PureScript.
-
Install repository 's software:
- Run:
# 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
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.
-
Database Setup:
- Install PostgreSQL.
sql/CreateDB.sql
: Execute commands which set up a database calledconduit
.config/Server/{Dev|Prod}.json
: Change config files according to your db setup.sql/Functions.sql
: Execute commands which set up functions/triggers for Prod.sql/ResetTables.sql
: Activate the current timestamps by uncommenting-- TIMESTAMP
for Prod. This file can be executed with:
spago run -m Test.ResetTables
-
Jwt:
config/Server/Prod.json
: Change the token's secret key for Prod. -
Server:
src/Server/Main.purs
: Set the configuration file accordingly. -
Optional: Install HTTPie and httpie-jwt-auth for testing via command line.
-
Optional: Install a frontend like Real World Halogen.
-
Run the server:
spago run
-
API-SPEC.md lists HTTPie test calls to every request.
-
Run a frontend.
-
Run the unit tests
spago run -m Test.Main
APPROACH.md contains some comments about the decisions which were made.