err0r500 / realworld-app-backend-rescript-ts

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

RealWorld Rescript & Typescript App

Rescript codebase containing real world examples (CRUD, auth, advanced patterns, etc) that adheres to the RealWorld spec and API.

For more information on how to this works with other frontends/backends, head over to the RealWorld repo.

The purpose of this repo is to showcase a realworld example of how rescript can integrate a typescript codebase in order to ease its adoption (... and get the best of both worlds ?).

How it works

This project uses hexagonal architecture

Rescript is mainly used for domain modelling (domain & usecases)

TypeScript is used for adapters implementation

2-step compilation

compilation

rescript

.res & .resi are rescript files, they are normally built directly to javascript, ending up directly in the ./lib/js/ folder (not committed)

But rescript can also generate typescript files next to the rescript files containing some @genType decorators. These new files have a .gen.ts extension

typescript

Pure typescript files use the standard .ts extension and can make use of the .gen.ts previously generated for interop between the two languages (to get types).

Both .gen.ts & .ts files are built using tsc and will end up as javascript files in the ./lib/js/ folder

Getting started

npm install, npm build

start the server

npm run start
curl -XPOST -v localhost:3000/ -d '{"mail": "hello@bla.com", "name": "salut", "password": "myPass"}' -H "Content-Type: application/json"

Development

API contract documentation

About

License:MIT License


Languages

Language:ReScript 82.7%Language:TypeScript 12.3%Language:Gherkin 2.7%Language:Shell 2.3%