This repo is a starter repo for building an Express server using Fern.
Fern is an open source format for defining REST APIs. Fern makes it easy to:
- Define your API
- Implement your API on the backend
- Consume your API on the frontend
Most of the code for this server is auto-generated by Fern!
In a terminal, run:
npm install -g fern-api
fern generate
yarn install
yarn dev
Now you can cURL the server!
curl 'http://localhost:8080/movies/goodwill-hunting'
To get started, open a VSCode window for the root of this repo:
code .
Install the recommended extensions. These will give you a better experience in the IDE.
Install dependencies:
yarn install
Run the server:
yarn start
You can edit the server code, and the server will automatically reload.
Nearly all of the server code is generated by Fern when you run fern generate
.
The generated code lives in src/api/generated.
In addition to saving you time, the auto-generated code gives you compile-time safety
that your API is implemented correctly. For example, if you forget to define the getMovie
endpoint, you'll get a compile error:
The API is defined using Fern. The definition lives in the fern/ directory. You can edit these YAML files to update the API. Check out the docs to read more about defining APIs.
Most of the server code in this repo is automatically generated by Fern. You can regenerate the code using the Fern CLI:
npm install -g fern
fern generate
This will output newly generated code to src/api/generated.
When you change your API, you'll get compile errors if you're not implementing the API correctly.
If you run into any problems while using this ticket, plesae file an issue. Of course, PRs are welcome and encouraged!