Skip to content

Commit 7a3ee56

Browse files
docs: document how to run the fastify demo. (#8)
* docs: document how to run the demo * docs: nit
1 parent 0e6dff1 commit 7a3ee56

File tree

2 files changed

+61
-14
lines changed

2 files changed

+61
-14
lines changed

README.md

Lines changed: 60 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
# Fastify Official Demo
22

33
![CI](https://github.com/fastify/demo/workflows/CI/badge.svg)
4-
[![js-standard-style](https://img.shields.io/badge/code%20style-standard-brightgreen.svg?style=flat)](https://standardjs.com/)
54

65
> :warning: **Please note:** This repository is still under active development.
76
@@ -10,30 +9,78 @@ The aim of this repository is to provide a concrete example of a Fastify applica
109
**Prerequisites:** You need to have Node.js version 22 or higher installed.
1110

1211
## Getting started
13-
1412
Install the dependencies:
15-
1613
```bash
1714
npm install
1815
```
1916

20-
## Available Scripts
17+
### Database
18+
You can run a MySQL instance with Docker:
19+
```bash
20+
docker compose up
21+
```
22+
23+
To run it in the background:
24+
```bash
25+
docker compose up -d
26+
```
27+
28+
To create and update the database schema, run the migrations:
29+
```bash
30+
npm run db:migrate
31+
```
2132

22-
In the project directory, you can run:
33+
To populate the database with initial data, run:
34+
```bash
35+
npm run db:seed
36+
```
2337

24-
### `npm run dev`
38+
### TypeScript
39+
To build the project:
40+
```bash
41+
npm run build
42+
```
2543

26-
To start the app in dev mode.\
44+
In dev mode, you can use:
45+
```bash
46+
npm run watch
47+
```
48+
49+
### Start the server
50+
In dev mode:
51+
```bash
52+
npm run dev
53+
```
2754
Open [http://localhost:3000](http://localhost:3000) to view it in the browser.
2855

29-
### `npm start`
56+
In production mode:
57+
```bash
58+
npm run start
59+
```
3060

31-
For production mode
61+
### Testing
62+
To run the tests:
63+
```bash
64+
npm run test
65+
```
3266

33-
### `npm run test`
67+
### Standalone
68+
`dev` and `start` leverage [fastify-cli](https://github.com/fastify/fastify-cli),
69+
but you can run the demo as a standalone executable (see [server.ts](./src/server.ts)):
70+
```bash
71+
npm run standalone
72+
```
3473

35-
Run the test cases.
74+
### Linting
75+
To check for linting errors:
76+
```bash
77+
npm run lint
78+
```
3679

37-
## Learn More
80+
To check and automatically fix linting errors:
81+
```bash
82+
npm run lint:fix
83+
```
3884

39-
To learn Fastify, check out the [Fastify documentation](https://fastify.dev/docs/latest/).
85+
## Learn More
86+
To learn more about Fastify, check out the [Fastify documentation](https://www.fastify.io/docs/latest/).

src/server.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/**
22
* This file is here only to show you how to proceed if you would
3-
* like to turn your application into a standalone executable.
3+
* like to run your application as a standalone executable.
44
*
55
* You can launch it with the command `npm run standalone`
66
*/

0 commit comments

Comments
 (0)