Giter Site home page Giter Site logo

sanjun1995 / example-nx-app Goto Github PK

View Code? Open in Web Editor NEW

This project forked from nestjs-shopify/example-nx-app

0.0 0.0 0.0 2.06 MB

Example monorepo app with @nest-shopify/nest-shopify using NestJS backend and NextJS frontend

JavaScript 4.80% TypeScript 95.20%

example-nx-app's Introduction

Example @nestjs-shopify application

Uses NX monorepo under the hood. An example Shopify application with a NestJS API backend, and a NextJS frontend.

Uses @nestjs-shopify/* packages.

Architecture

The NestJS api application is proxied via NX proxies to /api. The api application also contains a global prefix to /api.

Because we use NX proxies, we basically disable the usage of NextJS API requests in the pages/api folder because the requests are always proxied to the backend.

This application uses Mikro-ORM for it's database. When performing offline auth, the authenticated shop gets inserted into the shops table with an offline token. This token can then be used for webhook/background operations.

Setup

Install dependencies

npm install

Copy the example environment variables and fill in yours:

cp .env.example .env

The HOST env var should be your full Ngrok URL eg: https://7c350f27f75f.ngrok.io

Run the migrations:

cd apps/api
npx mikro-orm schema:update -r

Running

On terminal window 1:

npx nx run api:serve

On terminal window 2:

npx nx run web:serve

Visit https://<HOST>/?shop=<SHOP> to start the OAuth installation procedure of your app.

Authentication with Shopify

The application allows for both Online and Offline authentication. But Shopify recommends using offline auth for only installing your application, and online auth for loading data in your frontend.

The ProductsController in this application that returns the total product count in Shopify, utilizes @ShopifyOnlineAuth() decorator. That signals our application to look for online JWT tokens when calling the GET /api/products/count route.

The frontend utilizes @shopify/app-bridge to transparently fetch online tokens for us using the userLoggedInfetch helper function.

example-nx-app's People

Contributors

renovate[bot] avatar sanjun1995 avatar tolgap 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.