Skip to content

Instantly share code, notes, and snippets.

@lewebsimple
Last active January 19, 2024 16:14
Show Gist options
  • Select an option

  • Save lewebsimple/6f69cf82946669beafa0d91ced00b777 to your computer and use it in GitHub Desktop.

Select an option

Save lewebsimple/6f69cf82946669beafa0d91ced00b777 to your computer and use it in GitHub Desktop.

Revisions

  1. lewebsimple revised this gist Jan 30, 2020. 1 changed file with 3 additions and 2 deletions.
    5 changes: 3 additions & 2 deletions nuxtjs-nestjs.md
    Original file line number Diff line number Diff line change
    @@ -439,10 +439,11 @@ import { envConfig } from '@nuxtnest/shared';
    console.log(envConfig.serverPort);
    ```

    # TypeGraphQL configuration
    # TypeGraphQL

    Inside `packages/server`, we install the necessary packages

    ```
    yarn add @nestjs/graphql apollo-server-express graphql-tools graphql type-graphql
    ```
    ```

  2. lewebsimple revised this gist Jan 30, 2020. 1 changed file with 8 additions and 2 deletions.
    10 changes: 8 additions & 2 deletions nuxtjs-nestjs.md
    Original file line number Diff line number Diff line change
    @@ -6,7 +6,8 @@ This is my take on fullstack development using [NuxtJS](https://nuxtjs.org) and
    - [x] Minimal NestJS server
    - [x] Minimal NuxtJS client
    - [x] Environment configuration
    - [ ] TypeGraphQL / TypeORM configuration
    - [ ] TypeGraphQL
    - [ ] TypeORM / MySQL
    - [ ] HTTP proxy middleware
    - [ ] Apollo Client
    - [ ] User datamodel, queries and mutations
    @@ -438,5 +439,10 @@ import { envConfig } from '@nuxtnest/shared';
    console.log(envConfig.serverPort);
    ```

    # TypeGraphQL / TypeORM configuration
    # TypeGraphQL configuration

    Inside `packages/server`, we install the necessary packages

    ```
    yarn add @nestjs/graphql apollo-server-express graphql-tools graphql type-graphql
    ```
  3. lewebsimple revised this gist Jan 30, 2020. 1 changed file with 1 addition and 0 deletions.
    1 change: 1 addition & 0 deletions nuxtjs-nestjs.md
    Original file line number Diff line number Diff line change
    @@ -439,3 +439,4 @@ console.log(envConfig.serverPort);
    ```

    # TypeGraphQL / TypeORM configuration

  4. lewebsimple revised this gist Jan 30, 2020. 1 changed file with 2 additions and 0 deletions.
    2 changes: 2 additions & 0 deletions nuxtjs-nestjs.md
    Original file line number Diff line number Diff line change
    @@ -437,3 +437,5 @@ Then we can import from anywhere using:
    import { envConfig } from '@nuxtnest/shared';
    console.log(envConfig.serverPort);
    ```

    # TypeGraphQL / TypeORM configuration
  5. lewebsimple revised this gist Jan 30, 2020. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion nuxtjs-nestjs.md
    Original file line number Diff line number Diff line change
    @@ -6,7 +6,7 @@ This is my take on fullstack development using [NuxtJS](https://nuxtjs.org) and
    - [x] Minimal NestJS server
    - [x] Minimal NuxtJS client
    - [x] Environment configuration
    - [ ] TypeGraphQL / TypeORM
    - [ ] TypeGraphQL / TypeORM configuration
    - [ ] HTTP proxy middleware
    - [ ] Apollo Client
    - [ ] User datamodel, queries and mutations
  6. lewebsimple revised this gist Jan 30, 2020. No changes.
  7. lewebsimple revised this gist Jan 30, 2020. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion nuxtjs-nestjs.md
    Original file line number Diff line number Diff line change
    @@ -6,7 +6,7 @@ This is my take on fullstack development using [NuxtJS](https://nuxtjs.org) and
    - [x] Minimal NestJS server
    - [x] Minimal NuxtJS client
    - [x] Environment configuration
    - [ ] GraphQL service based on Prisma2 / Nexus
    - [ ] TypeGraphQL / TypeORM
    - [ ] HTTP proxy middleware
    - [ ] Apollo Client
    - [ ] User datamodel, queries and mutations
  8. lewebsimple revised this gist Jan 30, 2020. 1 changed file with 7 additions and 1 deletion.
    8 changes: 7 additions & 1 deletion nuxtjs-nestjs.md
    Original file line number Diff line number Diff line change
    @@ -425,7 +425,13 @@ export const envConfig: EnvConfig = {
    };
    ```

    To use our new package from elsewhere in the project:
    To use our new package from elsewhere in the project, we first need to link the dependencies using Lerna (from the root of the project):

    ```
    lerna bootstrap
    ```

    Then we can import from anywhere using:

    ```
    import { envConfig } from '@nuxtnest/shared';
  9. lewebsimple revised this gist Dec 19, 2019. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion nuxtjs-nestjs.md
    Original file line number Diff line number Diff line change
    @@ -395,7 +395,7 @@ We want our environment configuration to have the following features:
    * Values stored inside the `.env` file at the root of the project
    * Values can be overridden by system environment variables
    * Sensible default values whenever possible (required otherwise)
    * Throw an error when required value is missing
    * Throw an error when a required value is missing

    We'll use [dotenv](https://www.npmjs.com/package/dotenv) and [env-var](https://www.npmjs.com/package/env-var) to help us achieve this:

  10. lewebsimple revised this gist Dec 19, 2019. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion nuxtjs-nestjs.md
    Original file line number Diff line number Diff line change
    @@ -381,7 +381,7 @@ Like before, we create `tsconfig.json` to configure TypeScript:
    }
    ```

    We use TypeScript watch mode (`tsc -w`) and we don't define a `start` script since this package is not to be executed.
    We use TypeScript watch mode (`tsc -w`) for `dev` and we don't define a `start` script since this package is not to be executed.

    Also, since we might need to share code for other purposes, we'll use `src/index.ts` as an entry point for the package and export `envconfig.ts` from there:

  11. lewebsimple revised this gist Dec 19, 2019. 1 changed file with 0 additions and 1 deletion.
    1 change: 0 additions & 1 deletion nuxtjs-nestjs.md
    Original file line number Diff line number Diff line change
    @@ -345,7 +345,6 @@ We won't create anything inside `pages/` for now as we only want to have a worki

    One of the advantages of using a monorepo is sharing code between packages, which can prove useful for defining common configuration values or secrets.


    Let's create a `shared` package for this purpose:

    ```
  12. lewebsimple revised this gist Dec 19, 2019. 1 changed file with 2 additions and 2 deletions.
    4 changes: 2 additions & 2 deletions nuxtjs-nestjs.md
    Original file line number Diff line number Diff line change
    @@ -310,11 +310,11 @@ We then configure TypeScript `tsconfig.json`:
    ```
    import { Configuration } from '@nuxt/types';
    const config: Configuration = {
    const nuxtConfig: Configuration = {
    buildModules: ['@nuxt/typescript-build'],
    };
    export default config;
    export default nuxtConfig;
    ```

    Finally we adjust `package.json` with the name prefix and scripts:
  13. lewebsimple revised this gist Dec 19, 2019. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion nuxtjs-nestjs.md
    Original file line number Diff line number Diff line change
    @@ -249,7 +249,7 @@ yarn dev
    yarn build && yarn start
    ```

    Navigating to `http://localhost:4000` shoud bring up the standard 404 response from NestJS (we don't have any controller).
    Navigating to `http://localhost:4000` shoud bring up the standard 404 response from NestJS.

    ## Minimal NuxtJS client

  14. lewebsimple revised this gist Dec 19, 2019. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion nuxtjs-nestjs.md
    Original file line number Diff line number Diff line change
    @@ -249,7 +249,7 @@ yarn dev
    yarn build && yarn start
    ```

    Navigating to `http://localhost:4000` shoud bring up the standard 404 response from NestJS.
    Navigating to `http://localhost:4000` shoud bring up the standard 404 response from NestJS (we don't have any controller).

    ## Minimal NuxtJS client

  15. lewebsimple revised this gist Dec 19, 2019. 1 changed file with 2 additions and 0 deletions.
    2 changes: 2 additions & 0 deletions nuxtjs-nestjs.md
    Original file line number Diff line number Diff line change
    @@ -249,6 +249,8 @@ yarn dev
    yarn build && yarn start
    ```

    Navigating to `http://localhost:4000` shoud bring up the standard 404 response from NestJS.

    ## Minimal NuxtJS client

    Let's create our client package:
  16. lewebsimple revised this gist Dec 19, 2019. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion nuxtjs-nestjs.md
    Original file line number Diff line number Diff line change
    @@ -175,7 +175,7 @@ Again, let's tweak the server's `package.json` for our needs:
    "name": "@nuxtnest/server",
    "version": "1.0.0",
    "private": true,
    "main": "dist/index.js",
    "main": "dist/main.js",
    "scripts": {
    "dev": "ts-node-dev --no-notify --transpileOnly src/main.ts",
    "build": "tsc",
  17. lewebsimple revised this gist Dec 19, 2019. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion nuxtjs-nestjs.md
    Original file line number Diff line number Diff line change
    @@ -20,7 +20,7 @@ We assume basic knowledge of [NodeJS](https://nodejs.org).

    ## Lerna monorepo

    We first install lerna globally, initialize a new git repository and turn it into a Lerna monorepo with independent versioning:
    We first install Lerna globally, initialize a new git repository and turn it into a monorepo with independent versioning:

    ```
    npm install --global lerna
  18. lewebsimple revised this gist Dec 19, 2019. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion nuxtjs-nestjs.md
    Original file line number Diff line number Diff line change
    @@ -14,7 +14,7 @@ This is my take on fullstack development using [NuxtJS](https://nuxtjs.org) and
    - [ ] Server-side authorization guards
    - [ ] Buefy / SCSS
    - [ ] Form handling and validation
    - [ ] Login / Registration / Profile forms
    - [ ] Login / Registration / Profile forms

    We assume basic knowledge of [NodeJS](https://nodejs.org).

  19. lewebsimple revised this gist Dec 19, 2019. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion nuxtjs-nestjs.md
    Original file line number Diff line number Diff line change
    @@ -5,7 +5,7 @@ This is my take on fullstack development using [NuxtJS](https://nuxtjs.org) and
    - [x] TypeScript linting and formatting
    - [x] Minimal NestJS server
    - [x] Minimal NuxtJS client
    - [ ] Environment configuration
    - [x] Environment configuration
    - [ ] GraphQL service based on Prisma2 / Nexus
    - [ ] HTTP proxy middleware
    - [ ] Apollo Client
  20. lewebsimple revised this gist Dec 19, 2019. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion nuxtjs-nestjs.md
    Original file line number Diff line number Diff line change
    @@ -235,7 +235,7 @@ import { AppModule } from './app.module';
    async function bootstrap() {
    const app = await NestFactory.create(AppModule);
    await app.listen(4000, 'localhost');
    await app.listen(4000);
    }
    bootstrap();
    ```
  21. lewebsimple revised this gist Dec 19, 2019. No changes.
  22. lewebsimple revised this gist Dec 19, 2019. 1 changed file with 8 additions and 1 deletion.
    9 changes: 8 additions & 1 deletion nuxtjs-nestjs.md
    Original file line number Diff line number Diff line change
    @@ -422,4 +422,11 @@ export const envConfig: EnvConfig = {
    clientPort: env.get('CLIENT_PORT', '3000').asPortNumber(),
    serverPort: env.get('SERVER_PORT', '4000').asPortNumber(),
    };
    ```
    ```

    To use our new package from elsewhere in the project:

    ```
    import { envConfig } from '@nuxtnest/shared';
    console.log(envConfig.serverPort);
    ```
  23. lewebsimple revised this gist Dec 19, 2019. 1 changed file with 1 addition and 0 deletions.
    1 change: 1 addition & 0 deletions nuxtjs-nestjs.md
    Original file line number Diff line number Diff line change
    @@ -406,6 +406,7 @@ yarn add -D @types/dotenv
    As a starting point, let's define client / server port numbers. For such a configuration, our `envconfig.ts` file would look something like this:

    ```
    // src/envconfig.ts
    import * as env from 'env-var';
    import { config } from 'dotenv';
    import { resolve } from 'path';
  24. lewebsimple revised this gist Dec 19, 2019. 1 changed file with 19 additions and 0 deletions.
    19 changes: 19 additions & 0 deletions nuxtjs-nestjs.md
    Original file line number Diff line number Diff line change
    @@ -403,3 +403,22 @@ yarn add dotenv env-var
    yarn add -D @types/dotenv
    ```

    As a starting point, let's define client / server port numbers. For such a configuration, our `envconfig.ts` file would look something like this:

    ```
    import * as env from 'env-var';
    import { config } from 'dotenv';
    import { resolve } from 'path';
    config({ path: resolve(__dirname, '../../../.env') });
    export interface EnvConfig {
    clientPort: number;
    serverPort: number;
    }
    export const envConfig: EnvConfig = {
    clientPort: env.get('CLIENT_PORT', '3000').asPortNumber(),
    serverPort: env.get('SERVER_PORT', '4000').asPortNumber(),
    };
    ```
  25. lewebsimple revised this gist Dec 19, 2019. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion nuxtjs-nestjs.md
    Original file line number Diff line number Diff line change
    @@ -396,7 +396,7 @@ We want our environment configuration to have the following features:
    * Sensible default values whenever possible (required otherwise)
    * Throw an error when required value is missing

    We'll use [dotenv])(https://www.npmjs.com/package/dotenv) and [env-var](https://www.npmjs.com/package/env-var) to help us achieve this:
    We'll use [dotenv](https://www.npmjs.com/package/dotenv) and [env-var](https://www.npmjs.com/package/env-var) to help us achieve this:

    ```
    yarn add dotenv env-var
  26. lewebsimple revised this gist Dec 19, 2019. 1 changed file with 14 additions and 4 deletions.
    18 changes: 14 additions & 4 deletions nuxtjs-nestjs.md
    Original file line number Diff line number Diff line change
    @@ -380,16 +380,26 @@ Like before, we create `tsconfig.json` to configure TypeScript:
    }
    ```

    We use TypeScript watch mode (`tsc -w`) and we don't define a `start` script since this package is not to be executed.

    Also, since we might need to share code for other purposes, we'll use `src/index.ts` as an entry point for the package and export `envconfig.ts` from there:

    ```
    // src/index.ts
    export * from './envconfig';
    ```

    We want our environment configuration to have the following features:
    * Type-safe via `interface EnvConfig`
    * Values stored inside the `.env` file at the root of the project
    * Values can be overridden by system environment variables
    * Sensible default values whenever possible (required otherwise)
    * Throw an error when required value is missing

    Since we might need to share code for other purposes, we'll use `src/index.ts` as an entry point for the package and export from there:
    We'll use [dotenv])(https://www.npmjs.com/package/dotenv) and [env-var](https://www.npmjs.com/package/env-var) to help us achieve this:

    ```
    // src/index.ts
    export * from './envconfig';
    ```
    yarn add dotenv env-var
    yarn add -D @types/dotenv
    ```

  27. lewebsimple revised this gist Dec 19, 2019. 1 changed file with 9 additions and 1 deletion.
    10 changes: 9 additions & 1 deletion nuxtjs-nestjs.md
    Original file line number Diff line number Diff line change
    @@ -343,7 +343,8 @@ We won't create anything inside `pages/` for now as we only want to have a worki

    One of the advantages of using a monorepo is sharing code between packages, which can prove useful for defining common configuration values or secrets.

    Let's create a `shared` package to serve this purpose:

    Let's create a `shared` package for this purpose:

    ```
    mkdir packages/shared && cd packages/shared
    @@ -385,3 +386,10 @@ We want our environment configuration to have the following features:
    * Values can be overridden by system environment variables
    * Sensible default values whenever possible (required otherwise)
    * Throw an error when required value is missing

    Since we might need to share code for other purposes, we'll use `src/index.ts` as an entry point for the package and export from there:

    ```
    // src/index.ts
    export * from './envconfig';
    ```
  28. lewebsimple revised this gist Dec 19, 2019. 1 changed file with 0 additions and 4 deletions.
    4 changes: 0 additions & 4 deletions nuxtjs-nestjs.md
    Original file line number Diff line number Diff line change
    @@ -385,7 +385,3 @@ We want our environment configuration to have the following features:
    * Values can be overridden by system environment variables
    * Sensible default values whenever possible (required otherwise)
    * Throw an error when required value is missing

    We want to define the environment configuration inside the `.env` file at the root of the project, which is excluded from source control since it might contain sensitive information.

    We also want to be able to override
  29. lewebsimple revised this gist Dec 19, 2019. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion nuxtjs-nestjs.md
    Original file line number Diff line number Diff line change
    @@ -383,7 +383,7 @@ We want our environment configuration to have the following features:
    * Type-safe via `interface EnvConfig`
    * Values stored inside the `.env` file at the root of the project
    * Values can be overridden by system environment variables
    * Sensible default values whenever possible, required otherwise
    * Sensible default values whenever possible (required otherwise)
    * Throw an error when required value is missing

    We want to define the environment configuration inside the `.env` file at the root of the project, which is excluded from source control since it might contain sensitive information.
  30. lewebsimple revised this gist Dec 19, 2019. 1 changed file with 10 additions and 1 deletion.
    11 changes: 10 additions & 1 deletion nuxtjs-nestjs.md
    Original file line number Diff line number Diff line change
    @@ -379,4 +379,13 @@ Like before, we create `tsconfig.json` to configure TypeScript:
    }
    ```

    We want to define the environment configuration inside the `.env` at the root of the project, which is excluded from source control since it might contain sensitive information.
    We want our environment configuration to have the following features:
    * Type-safe via `interface EnvConfig`
    * Values stored inside the `.env` file at the root of the project
    * Values can be overridden by system environment variables
    * Sensible default values whenever possible, required otherwise
    * Throw an error when required value is missing

    We want to define the environment configuration inside the `.env` file at the root of the project, which is excluded from source control since it might contain sensitive information.

    We also want to be able to override