Coder Social home page Coder Social logo

fastify-hello-world's Introduction

Fastify Hello World

Simple REST API with Fastify web framework.

Development

Semantic Versioning and Conventional Commits specifications are enforced in this repository.
main branch is protected and changes must be merged via pull requests.

Clone the project.

  git clone [email protected]:altcatalin/fastify-hello-world.git

Go to the project directory.

  cd fastify-hello-world

Install pre-commit. Check pre-commit documentation for other options.

pip install pre-commit
pre-commit --version

Set up the git hook scripts.

pre-commit install

Install dependencies

npm install

(VS Code only) Install VS Code extensions: ESLint, Prettier ESLint and EditorConfig.

Run unit tests

npm run test

Start web server

npm run server

Build Azure Image

Create resource group

az group create -n fastify-hello-world --location germanywestcentral

Create service principal

# !!! Save the content of $AZURE_SECRETS in safe place for long-term storage
AZURE_SECRETS=$(az ad sp create-for-rbac -n "$USER@$(hostname -f)" --role Contributor --scopes /subscriptions/$(az account show --query "{ subscription_id: id }" | jq -r ".subscription_id") --query "{ client_id: appId, client_secret: password, tenant_id: tenant }")

Build image

packer init image.pkr.hcl

packer build \
  -var "subscription_id=$(az account show --query "{ subscription_id: id }" | jq -r ".subscription_id")" \
  -var "tenant_id=$(echo $AZURE_SECRETS | jq -r ".tenant_id")" \
  -var "client_id=$(echo $AZURE_SECRETS | jq -r ".client_id")" \
  -var "client_secret=$(echo $AZURE_SECRETS | jq -r ".client_secret")" \
  -var "version=sha-$(git rev-parse --short HEAD)" \
  image.pkr.hcl

Create VM

az vm create \
    --resource-group fastify-hello-world \
    --name fastify-hello-world \
    --image fastify-hello-world-sha-$(git rev-parse --short HEAD) \
    --size Standard_B2ats_v2 \
    --admin-username $USER \
    --ssh-key-values ~/.ssh/id_ed25519.pub

az vm open-port \
    --resource-group fastify-hello-world \
    --name fastify-hello-world \
    --port 3000

curl $(az vm list-ip-addresses --name fastify-hello-world --resource-group fastify-hello-world --query "[0].virtualMachine.network.publicIpAddresses[0].ipAddress" | jq -r):3000

az resource delete --ids $(az resource list -g fastify-hello-world --query "[].id" -o tsv)

fastify-hello-world's People

Contributors

altcatalin avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.