Fun JS is a NodeJS application created to learn and apply functional-programming principles for real-world applications. Any corrections or additional implementations are welcome!
- Sanctuary for a run-time type checking and helper functions;
- Fluture for a monadic data structure alterative to Promises;
- Koa for serving a Restful API;
- Postgres-Migrations for an immutable database migration system.
- Clone the app and install the packages;
- Install PostgreSQL, if you don't have it;
- Create a
.env
file in the root of the project. This file should contain the following keys:
// change the values as necessary
APP_PORT = 3000
PGHOST = localhost
PGUSER = postgres
PGPASSWORD = YOUR_POSTGRESQL_PASSWORD
PGPORT = 5432
PGDATABASE = fun_js
- Run
npm run migrate
; - Run
npm run serve
; - Enjoy ;)
There are current 2 routes available:
-
GET api/users
-
POST api/users
{
"email": "test@gmail.com",
"password": "1234567",
"fullname": "Test Name"
}
Try to change/remove the fields and see what happens :)
The idea of this app is to separate the algebra from the interpretation of the functions, as if we were using a strongly-typed language. I'm still not sure whether it's really make sense, so I created this application to test the concepts and get reviews and pull-requests from other people.