Last active
January 19, 2024 16:14
-
-
Save lewebsimple/6f69cf82946669beafa0d91ced00b777 to your computer and use it in GitHub Desktop.
Revisions
-
lewebsimple revised this gist
Jan 30, 2020 . 1 changed file with 3 additions and 2 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -439,10 +439,11 @@ import { envConfig } from '@nuxtnest/shared'; console.log(envConfig.serverPort); ``` # TypeGraphQL Inside `packages/server`, we install the necessary packages ``` yarn add @nestjs/graphql apollo-server-express graphql-tools graphql type-graphql ``` -
lewebsimple revised this gist
Jan 30, 2020 . 1 changed file with 8 additions and 2 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal 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 / 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 configuration Inside `packages/server`, we install the necessary packages ``` yarn add @nestjs/graphql apollo-server-express graphql-tools graphql type-graphql ``` -
lewebsimple revised this gist
Jan 30, 2020 . 1 changed file with 1 addition and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -439,3 +439,4 @@ console.log(envConfig.serverPort); ``` # TypeGraphQL / TypeORM configuration -
lewebsimple revised this gist
Jan 30, 2020 . 1 changed file with 2 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal 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 -
lewebsimple revised this gist
Jan 30, 2020 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal 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 configuration - [ ] HTTP proxy middleware - [ ] Apollo Client - [ ] User datamodel, queries and mutations -
lewebsimple revised this gist
Jan 30, 2020 . No changes.There are no files selected for viewing
-
lewebsimple revised this gist
Jan 30, 2020 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal 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 - [ ] HTTP proxy middleware - [ ] Apollo Client - [ ] User datamodel, queries and mutations -
lewebsimple revised this gist
Jan 30, 2020 . 1 changed file with 7 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal 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, 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'; -
lewebsimple revised this gist
Dec 19, 2019 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal 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 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: -
lewebsimple revised this gist
Dec 19, 2019 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal 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`) 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: -
lewebsimple revised this gist
Dec 19, 2019 . 1 changed file with 0 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal 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: ``` -
lewebsimple revised this gist
Dec 19, 2019 . 1 changed file with 2 additions and 2 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal 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 nuxtConfig: Configuration = { buildModules: ['@nuxt/typescript-build'], }; export default nuxtConfig; ``` Finally we adjust `package.json` with the name prefix and scripts: -
lewebsimple revised this gist
Dec 19, 2019 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal 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. ## Minimal NuxtJS client -
lewebsimple revised this gist
Dec 19, 2019 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal 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). ## Minimal NuxtJS client -
lewebsimple revised this gist
Dec 19, 2019 . 1 changed file with 2 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal 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: -
lewebsimple revised this gist
Dec 19, 2019 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal 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/main.js", "scripts": { "dev": "ts-node-dev --no-notify --transpileOnly src/main.ts", "build": "tsc", -
lewebsimple revised this gist
Dec 19, 2019 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal 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 monorepo with independent versioning: ``` npm install --global lerna -
lewebsimple revised this gist
Dec 19, 2019 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal 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 We assume basic knowledge of [NodeJS](https://nodejs.org). -
lewebsimple revised this gist
Dec 19, 2019 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal 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 - [x] Environment configuration - [ ] GraphQL service based on Prisma2 / Nexus - [ ] HTTP proxy middleware - [ ] Apollo Client -
lewebsimple revised this gist
Dec 19, 2019 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal 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); } bootstrap(); ``` -
lewebsimple revised this gist
Dec 19, 2019 . No changes.There are no files selected for viewing
-
lewebsimple revised this gist
Dec 19, 2019 . 1 changed file with 8 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal 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); ``` -
lewebsimple revised this gist
Dec 19, 2019 . 1 changed file with 1 addition and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal 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'; -
lewebsimple revised this gist
Dec 19, 2019 . 1 changed file with 19 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal 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(), }; ``` -
lewebsimple revised this gist
Dec 19, 2019 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal 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: ``` yarn add dotenv env-var -
lewebsimple revised this gist
Dec 19, 2019 . 1 changed file with 14 additions and 4 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal 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 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 yarn add -D @types/dotenv ``` -
lewebsimple revised this gist
Dec 19, 2019 . 1 changed file with 9 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal 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 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'; ``` -
lewebsimple revised this gist
Dec 19, 2019 . 1 changed file with 0 additions and 4 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal 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 -
lewebsimple revised this gist
Dec 19, 2019 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal 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) * 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. -
lewebsimple revised this gist
Dec 19, 2019 . 1 changed file with 10 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -379,4 +379,13 @@ Like before, we create `tsconfig.json` to configure TypeScript: } ``` 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
NewerOlder