A small Node.js Fastify API.
- Create
.env
file with.env.example
structure and setSERVER_PORT
env variable. - Install dependencies
npm install
- Run server
npm start
Name | Route | Method | Required properties | Description |
---|---|---|---|---|
Home | / |
GET |
none | Return 'Hello World from API !' sentence. |
Say hello to someone | /hello |
POST |
name: string |
Return 'Hello name !'. |
Build image with Dockerfile
:
docker build -t hello-world-fastify-api:latest -f Dockerfile .
Run container with image :
docker run -it -p 3000:3000 hello-world-fastify-api:latest
You can update environment variables in Dockerfile
:
ENV SERVER_PORT=3000
ENV SERVER_HOST="0.0.0.0"