GithubHelp home page GithubHelp logo

nestjs-test-api's Introduction

NestJS Test API

Installation

# Install NPM packages
npm install

# Install Cloud SQL Proxy
curl -o cloud_sql_proxy https://dl.google.com/cloudsql/cloud_sql_proxy.darwin.arm64

chmod +x cloud_sql_proxy

Run

# Run local dev instance with hot reload, port 3000
npm run start:dev

# Build container (on Mac M1, targeting AMD64)
docker buildx build --platform linux/amd64 -t nestjs-test-api:v0.4.0 .

# Run local container, port 3000
docker run -it --env NODE_ENV=staging -p 3000:3000 nestjs-test-api:v0.4.0

Deploy

# Tag for GCP Artifact Registry
docker tag nestjs-test-api:v0.4.0 europe-west2-docker.pkg.dev/cloudpayroll-dev/nestjs-test/nestjs-test-api:v0.4.0

# Push to GCP Artifact Registry
docker push europe-west2-docker.pkg.dev/cloudpayroll-dev/nestjs-test/nestjs-test-api:v0.4.0

Database Connection

Local

For local development, run through the Cloud SQL Proxy secure tunnel. Note that you must be signed in on gcloud CLI.

# Install TypeORM bindings for PostgreSQL
npm install @nestjs/typeorm typeorm pg

# Run Cloud SQL Proxy, connect hosted Cloud SQL, via localhost:1234
# Note: Must be signed in on gcloud CLI
# Note: Scripted to `npm run proxy`
./cloud_sql_proxy -instances=cloudpayroll-dev:europe-west2:nestjs-test-db=tcp:0.0.0.0:1234

# Configure use of dotenv
npm i --save @nestjs/config

Misc

Use cross-env to standardise use of env vars across Unix, macOS, Windows. Install with npm install cross-env

Todo

  • Integrate Google Secret Manager
  • Blog Post

nestjs-test-api's People

Contributors

darrenbarklie 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.